ui: refactor CTCSS entries in macro menu to be more user friendly

This change makes it so that the macro menu shows the current tone and
change the tone setting with macro 1, then change tone frequency with
macro 2 and 3. This is a clearer UX.

Co-authored-by: Ryan Turner <ryan@turnrye.com>
Acked-by: Silvano Seva <silseva@fastwebnet.it>
This commit is contained in:
imostlylurk 2024-03-24 02:20:30 -04:00 committed by Silvano Seva
parent a30dae357d
commit 2df9addccc
2 changed files with 56 additions and 57 deletions

View File

@ -915,7 +915,23 @@ static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
case 1: case 1:
if(state.channel.mode == OPMODE_FM) if(state.channel.mode == OPMODE_FM)
{ {
if(state.channel.fm.txTone == 0) tone_flags++;
tone_flags %= 4;
tone_tx_enable = tone_flags >> 1;
tone_rx_enable = tone_flags & 1;
state.channel.fm.txToneEn = tone_tx_enable;
state.channel.fm.rxToneEn = tone_rx_enable;
*sync_rtx = true;
vp_announceCTCSS(
state.channel.fm.rxToneEn, state.channel.fm.rxTone,
state.channel.fm.txToneEn, state.channel.fm.txTone,
queueFlags | vpqIncludeDescriptions);
}
break;
case 2:
if (state.channel.mode == OPMODE_FM)
{
if (state.channel.fm.txTone == 0)
{ {
state.channel.fm.txTone = CTCSS_FREQ_NUM-1; state.channel.fm.txTone = CTCSS_FREQ_NUM-1;
} }
@ -935,30 +951,13 @@ static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
} }
break; break;
case 2: case 3:
if(state.channel.mode == OPMODE_FM) if(state.channel.mode == OPMODE_FM)
{ {
state.channel.fm.txTone++; state.channel.fm.txTone++;
state.channel.fm.txTone %= CTCSS_FREQ_NUM; state.channel.fm.txTone %= CTCSS_FREQ_NUM;
state.channel.fm.rxTone = state.channel.fm.txTone; state.channel.fm.rxTone = state.channel.fm.txTone;
*sync_rtx = true; *sync_rtx = true;
vp_announceCTCSS(state.channel.fm.rxToneEn,
state.channel.fm.rxTone,
state.channel.fm.txToneEn,
state.channel.fm.txTone,
queueFlags);
}
break;
case 3:
if(state.channel.mode == OPMODE_FM)
{
tone_flags++;
tone_flags %= 4;
tone_tx_enable = tone_flags >> 1;
tone_rx_enable = tone_flags & 1;
state.channel.fm.txToneEn = tone_tx_enable;
state.channel.fm.rxToneEn = tone_rx_enable;
*sync_rtx = true;
vp_announceCTCSS(state.channel.fm.rxToneEn, vp_announceCTCSS(state.channel.fm.rxToneEn,
state.channel.fm.rxTone, state.channel.fm.rxTone,
state.channel.fm.txToneEn, state.channel.fm.txToneEn,
@ -2356,6 +2355,7 @@ void ui_updateFSM(bool *sync_rtx)
} }
break; break;
#endif #endif
case SETTINGS_ACCESSIBILITY: case SETTINGS_ACCESSIBILITY:
if(msg.keys & KEY_LEFT || (ui_state.edit_mode && if(msg.keys & KEY_LEFT || (ui_state.edit_mode &&
(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT))) (msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)))

View File

@ -1100,18 +1100,31 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state)
#endif // CONFIG_UI_NO_KEYBOARD #endif // CONFIG_UI_NO_KEYBOARD
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT, gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413, "1"); yellow_fab413, "1");
if (last_state.channel.mode == OPMODE_FM)
{
char encdec_str[9] = {0};
bool tone_tx_enable = last_state.channel.fm.txToneEn;
bool tone_rx_enable = last_state.channel.fm.rxToneEn;
if (tone_tx_enable && tone_rx_enable)
sniprintf(encdec_str, 9, " B ");
else if (tone_tx_enable && !tone_rx_enable)
sniprintf(encdec_str, 9, " E ");
else if (!tone_tx_enable && tone_rx_enable)
sniprintf(encdec_str, 9, " D ");
else
sniprintf(encdec_str, 9, " N ");
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, encdec_str);
uint16_t tone = ctcss_tone[last_state.channel.fm.txTone]; uint16_t tone = ctcss_tone[last_state.channel.fm.txTone];
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT, gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, " T- %d.%d", (tone / 10), (tone % 10)); color_white, " %d.%d", (tone / 10), (tone % 10));
#if defined(CONFIG_UI_NO_KEYBOARD) #if defined(CONFIG_UI_NO_KEYBOARD)
if (ui_state->macro_menu_selected == 1) if (ui_state->macro_menu_selected == 1)
#endif // CONFIG_UI_NO_KEYBOARD #endif // CONFIG_UI_NO_KEYBOARD
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER, gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
yellow_fab413, "2"); yellow_fab413, "2");
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER, gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
color_white, " T+"); color_white, " T-");
} }
#ifdef CONFIG_M17 #ifdef CONFIG_M17
else if (last_state.channel.mode == OPMODE_M17) else if (last_state.channel.mode == OPMODE_M17)
@ -1129,22 +1142,8 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state)
#endif // CONFIG_UI_NO_KEYBOARD #endif // CONFIG_UI_NO_KEYBOARD
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT, gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT,
yellow_fab413, "3 "); yellow_fab413, "3 ");
if (last_state.channel.mode == OPMODE_FM)
{
char encdec_str[9] = { 0 };
bool tone_tx_enable = last_state.channel.fm.txToneEn;
bool tone_rx_enable = last_state.channel.fm.rxToneEn;
if (tone_tx_enable && tone_rx_enable)
sniprintf(encdec_str, 9, " E+D");
else if (tone_tx_enable && !tone_rx_enable)
sniprintf(encdec_str, 9, " E ");
else if (!tone_tx_enable && tone_rx_enable)
sniprintf(encdec_str, 9, " D ");
else
sniprintf(encdec_str, 9, " ");
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT, gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT,
color_white, encdec_str); color_white, " T+");
} }
#ifdef CONFIG_M17 #ifdef CONFIG_M17
else if (last_state.channel.mode == OPMODE_M17) else if (last_state.channel.mode == OPMODE_M17)
@ -1172,10 +1171,10 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state)
switch (last_state.channel.bandwidth) switch (last_state.channel.bandwidth)
{ {
case BW_12_5: case BW_12_5:
sniprintf(bw_str, 12, " BW 12.5"); sniprintf(bw_str, 12, " BW12.5");
break; break;
case BW_25: case BW_25:
sniprintf(bw_str, 12, " BW 25 "); sniprintf(bw_str, 12, " BW 25");
break; break;
} }
@ -1201,14 +1200,14 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state)
switch(last_state.channel.mode) switch(last_state.channel.mode)
{ {
case OPMODE_FM: case OPMODE_FM:
sniprintf(mode_str, 12," FM"); gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER, color_white, " FM");
break; break;
case OPMODE_DMR: case OPMODE_DMR:
sniprintf(mode_str, 12," DMR"); gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER, color_white, " DMR");
break; break;
#ifdef CONFIG_M17 #ifdef CONFIG_M17
case OPMODE_M17: case OPMODE_M17:
sniprintf(mode_str, 12," M17"); gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER, color_white, " M17");
break; break;
#endif #endif
} }