ui: settings: introduce FM settings menu option
This seeks to create a place for settings on the FM mode that complement the quick actions available from the macro menu. This way as more FM mode features are added, there is a menu to configure them in. Co-authored-by: Ryan Turner <ryan@turnrye.com> Acked-by: Silvano Seva <silseva@fastwebnet.it>
This commit is contained in:
parent
2df9addccc
commit
f7e5e45d09
|
|
@ -97,5 +97,6 @@ const stringsTable_t englishStrings =
|
||||||
.macroLatching = "Macro Latch",
|
.macroLatching = "Macro Latch",
|
||||||
.noGps = "No GPS",
|
.noGps = "No GPS",
|
||||||
.batteryIcon = "Battery Icon",
|
.batteryIcon = "Battery Icon",
|
||||||
|
.CTCSSTone = "CTCSS Frequency",
|
||||||
};
|
};
|
||||||
#endif // ENGLISHSTRINGS_H
|
#endif // ENGLISHSTRINGS_H
|
||||||
|
|
|
||||||
|
|
@ -98,5 +98,6 @@ const stringsTable_t spanishStrings =
|
||||||
.macroLatching = "Macro Latching",
|
.macroLatching = "Macro Latching",
|
||||||
.noGps = "Ningún GPS",
|
.noGps = "Ningún GPS",
|
||||||
.batteryIcon = "Icon de batteria",
|
.batteryIcon = "Icon de batteria",
|
||||||
|
.CTCSSTone = "Tono CTCSS",
|
||||||
};
|
};
|
||||||
#endif // SPANISHSTRINGS_H
|
#endif // SPANISHSTRINGS_H
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ enum uiScreen
|
||||||
SETTINGS_GPS,
|
SETTINGS_GPS,
|
||||||
SETTINGS_RADIO,
|
SETTINGS_RADIO,
|
||||||
SETTINGS_M17,
|
SETTINGS_M17,
|
||||||
|
SETTINGS_FM,
|
||||||
SETTINGS_ACCESSIBILITY,
|
SETTINGS_ACCESSIBILITY,
|
||||||
SETTINGS_RESET2DEFAULTS,
|
SETTINGS_RESET2DEFAULTS,
|
||||||
LOW_BAT
|
LOW_BAT
|
||||||
|
|
@ -101,6 +102,7 @@ enum settingsItems
|
||||||
#ifdef CONFIG_M17
|
#ifdef CONFIG_M17
|
||||||
S_M17,
|
S_M17,
|
||||||
#endif
|
#endif
|
||||||
|
S_FM,
|
||||||
S_ACCESSIBILITY,
|
S_ACCESSIBILITY,
|
||||||
S_RESET2DEFAULTS,
|
S_RESET2DEFAULTS,
|
||||||
};
|
};
|
||||||
|
|
@ -153,6 +155,11 @@ enum settingsM17Items
|
||||||
M17_CAN_RX
|
M17_CAN_RX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum settingsFMItems
|
||||||
|
{
|
||||||
|
CTCSS_Tone
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Struct containing a set of positions and sizes that get
|
* Struct containing a set of positions and sizes that get
|
||||||
* calculated for the selected display size.
|
* calculated for the selected display size.
|
||||||
|
|
@ -243,8 +250,8 @@ extern const char *display_items[];
|
||||||
extern const char *settings_gps_items[];
|
extern const char *settings_gps_items[];
|
||||||
extern const char *settings_radio_items[];
|
extern const char *settings_radio_items[];
|
||||||
extern const char *settings_m17_items[];
|
extern const char *settings_m17_items[];
|
||||||
|
extern const char *settings_fm_items[];
|
||||||
extern const char * settings_accessibility_items[];
|
extern const char * settings_accessibility_items[];
|
||||||
|
|
||||||
extern const char *backup_restore_items[];
|
extern const char *backup_restore_items[];
|
||||||
extern const char *info_items[];
|
extern const char *info_items[];
|
||||||
extern const char *authors[];
|
extern const char *authors[];
|
||||||
|
|
@ -254,6 +261,7 @@ extern const uint8_t display_num;
|
||||||
extern const uint8_t settings_gps_num;
|
extern const uint8_t settings_gps_num;
|
||||||
extern const uint8_t settings_radio_num;
|
extern const uint8_t settings_radio_num;
|
||||||
extern const uint8_t settings_m17_num;
|
extern const uint8_t settings_m17_num;
|
||||||
|
extern const uint8_t settings_fm_num;
|
||||||
extern const uint8_t settings_accessibility_num;
|
extern const uint8_t settings_accessibility_num;
|
||||||
extern const uint8_t backup_restore_num;
|
extern const uint8_t backup_restore_num;
|
||||||
extern const uint8_t info_num;
|
extern const uint8_t info_num;
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ typedef struct
|
||||||
const char* macroLatching;
|
const char* macroLatching;
|
||||||
const char* noGps;
|
const char* noGps;
|
||||||
const char* batteryIcon;
|
const char* batteryIcon;
|
||||||
|
const char* CTCSSTone;
|
||||||
}
|
}
|
||||||
stringsTable_t;
|
stringsTable_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ extern void _ui_drawSettingsTimeDateSet(ui_state_t* ui_state);
|
||||||
#endif
|
#endif
|
||||||
extern void _ui_drawSettingsDisplay(ui_state_t* ui_state);
|
extern void _ui_drawSettingsDisplay(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
|
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
|
||||||
|
extern void _ui_drawSettingsFM(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsVoicePrompts(ui_state_t* ui_state);
|
extern void _ui_drawSettingsVoicePrompts(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
|
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsRadio(ui_state_t* ui_state);
|
extern void _ui_drawSettingsRadio(ui_state_t* ui_state);
|
||||||
|
|
@ -145,6 +146,7 @@ const char *settings_items[] =
|
||||||
#ifdef CONFIG_M17
|
#ifdef CONFIG_M17
|
||||||
"M17",
|
"M17",
|
||||||
#endif
|
#endif
|
||||||
|
"FM",
|
||||||
"Accessibility",
|
"Accessibility",
|
||||||
"Default Settings"
|
"Default Settings"
|
||||||
};
|
};
|
||||||
|
|
@ -184,6 +186,11 @@ const char * settings_m17_items[] =
|
||||||
"CAN RX Check"
|
"CAN RX Check"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* settings_fm_items[] =
|
||||||
|
{
|
||||||
|
"CTCSS Tone"
|
||||||
|
};
|
||||||
|
|
||||||
const char * settings_accessibility_items[] =
|
const char * settings_accessibility_items[] =
|
||||||
{
|
{
|
||||||
"Macro Latch",
|
"Macro Latch",
|
||||||
|
|
@ -268,6 +275,7 @@ const uint8_t settings_radio_num = sizeof(settings_radio_items)/sizeof(settings_
|
||||||
#ifdef CONFIG_M17
|
#ifdef CONFIG_M17
|
||||||
const uint8_t settings_m17_num = sizeof(settings_m17_items)/sizeof(settings_m17_items[0]);
|
const uint8_t settings_m17_num = sizeof(settings_m17_items)/sizeof(settings_m17_items[0]);
|
||||||
#endif
|
#endif
|
||||||
|
const uint8_t settings_fm_num = sizeof(settings_fm_items) / sizeof(settings_fm_items[0]);
|
||||||
const uint8_t settings_accessibility_num = sizeof(settings_accessibility_items)/sizeof(settings_accessibility_items[0]);
|
const uint8_t settings_accessibility_num = sizeof(settings_accessibility_items)/sizeof(settings_accessibility_items[0]);
|
||||||
const uint8_t backup_restore_num = sizeof(backup_restore_items)/sizeof(backup_restore_items[0]);
|
const uint8_t backup_restore_num = sizeof(backup_restore_items)/sizeof(backup_restore_items[0]);
|
||||||
const uint8_t info_num = sizeof(info_items)/sizeof(info_items[0]);
|
const uint8_t info_num = sizeof(info_items)/sizeof(info_items[0]);
|
||||||
|
|
@ -1932,6 +1940,9 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
state.ui_screen = SETTINGS_M17;
|
state.ui_screen = SETTINGS_M17;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case S_FM:
|
||||||
|
state.ui_screen = SETTINGS_FM;
|
||||||
|
break;
|
||||||
case S_ACCESSIBILITY:
|
case S_ACCESSIBILITY:
|
||||||
state.ui_screen = SETTINGS_ACCESSIBILITY;
|
state.ui_screen = SETTINGS_ACCESSIBILITY;
|
||||||
break;
|
break;
|
||||||
|
|
@ -2355,6 +2366,64 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case SETTINGS_FM:
|
||||||
|
if (ui_state.edit_mode)
|
||||||
|
{
|
||||||
|
if (msg.keys & KEY_ESC)
|
||||||
|
ui_state.edit_mode = false;
|
||||||
|
|
||||||
|
switch (ui_state.menu_selected)
|
||||||
|
{
|
||||||
|
case CTCSS_Tone:
|
||||||
|
if (msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)
|
||||||
|
{
|
||||||
|
if (state.channel.fm.txTone == 0)
|
||||||
|
{
|
||||||
|
state.channel.fm.txTone =
|
||||||
|
CTCSS_FREQ_NUM - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state.channel.fm.txTone--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state.channel.fm.txTone %= CTCSS_FREQ_NUM;
|
||||||
|
state.channel.fm.rxTone = state.channel.fm.txTone;
|
||||||
|
*sync_rtx = true;
|
||||||
|
vp_announceCTCSS(state.channel.fm.rxToneEn,
|
||||||
|
state.channel.fm.rxTone,
|
||||||
|
state.channel.fm.txToneEn,
|
||||||
|
state.channel.fm.txTone,
|
||||||
|
queueFlags);
|
||||||
|
|
||||||
|
if (msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)
|
||||||
|
{
|
||||||
|
state.channel.fm.txTone++;
|
||||||
|
state.channel.fm.txTone %= CTCSS_FREQ_NUM;
|
||||||
|
state.channel.fm.rxTone = state.channel.fm.txTone;
|
||||||
|
*sync_rtx = true;
|
||||||
|
vp_announceCTCSS(state.channel.fm.rxToneEn,
|
||||||
|
state.channel.fm.rxTone,
|
||||||
|
state.channel.fm.txToneEn,
|
||||||
|
state.channel.fm.txTone,
|
||||||
|
queueFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msg.keys & KEY_UP || msg.keys & KNOB_LEFT)
|
||||||
|
_ui_menuUp(settings_fm_num);
|
||||||
|
else if (msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
|
||||||
|
_ui_menuDown(settings_fm_num);
|
||||||
|
else if (msg.keys & KEY_ENTER)
|
||||||
|
ui_state.edit_mode = !ui_state.edit_mode;
|
||||||
|
else if (msg.keys & KEY_ESC)
|
||||||
|
_ui_menuBack(MENU_SETTINGS);
|
||||||
|
else if (msg.keys & KEY_ENTER)
|
||||||
|
ui_state.edit_mode = !ui_state.edit_mode;
|
||||||
|
else if (msg.keys & KEY_ESC)
|
||||||
|
_ui_menuBack(MENU_SETTINGS);
|
||||||
|
break;
|
||||||
|
|
||||||
case SETTINGS_ACCESSIBILITY:
|
case SETTINGS_ACCESSIBILITY:
|
||||||
if(msg.keys & KEY_LEFT || (ui_state.edit_mode &&
|
if(msg.keys & KEY_LEFT || (ui_state.edit_mode &&
|
||||||
|
|
@ -2581,6 +2650,10 @@ bool ui_updateGUI()
|
||||||
_ui_drawSettingsM17(&ui_state);
|
_ui_drawSettingsM17(&ui_state);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
// FM settings screen
|
||||||
|
case SETTINGS_FM:
|
||||||
|
_ui_drawSettingsFM(&ui_state);
|
||||||
|
break;
|
||||||
case SETTINGS_ACCESSIBILITY:
|
case SETTINGS_ACCESSIBILITY:
|
||||||
_ui_drawSettingsAccessibility(&ui_state);
|
_ui_drawSettingsAccessibility(&ui_state);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,31 @@ int _ui_getM17ValueName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int _ui_getFMEntryName(char* buf, uint8_t max_len, uint8_t index)
|
||||||
|
{
|
||||||
|
if (index >= settings_fm_num)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
sniprintf(buf, max_len, "%s", settings_fm_items[index]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _ui_getFMValueName(char* buf, uint8_t max_len, uint8_t index)
|
||||||
|
{
|
||||||
|
if (index >= settings_fm_num)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch (index) {
|
||||||
|
case CTCSS_Tone: {
|
||||||
|
uint16_t tone = ctcss_tone[last_state.channel.fm.txTone];
|
||||||
|
sniprintf(buf, max_len, "%d.%d", (tone / 10), (tone % 10));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int _ui_getAccessibilityEntryName(char *buf, uint8_t max_len, uint8_t index)
|
int _ui_getAccessibilityEntryName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
{
|
{
|
||||||
if(index >= settings_accessibility_num) return -1;
|
if(index >= settings_accessibility_num) return -1;
|
||||||
|
|
@ -969,6 +994,17 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void _ui_drawSettingsFM(ui_state_t* ui_state)
|
||||||
|
{
|
||||||
|
gfx_clearScreen();
|
||||||
|
// Print "FM Settings" on top bar
|
||||||
|
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER, color_white,
|
||||||
|
currentLanguage->fm);
|
||||||
|
// Print FM settings entries
|
||||||
|
_ui_drawMenuListValue(ui_state, ui_state->menu_selected, _ui_getFMEntryName,
|
||||||
|
_ui_getFMValueName);
|
||||||
|
}
|
||||||
|
|
||||||
void _ui_drawSettingsAccessibility(ui_state_t* ui_state)
|
void _ui_drawSettingsAccessibility(ui_state_t* ui_state)
|
||||||
{
|
{
|
||||||
gfx_clearScreen();
|
gfx_clearScreen();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue