From 2df9addcccdfd3d0b6be42c6e4ad7e19295bc615 Mon Sep 17 00:00:00 2001 From: imostlylurk <164062014+imostlylurk@users.noreply.github.com> Date: Sun, 24 Mar 2024 02:20:30 -0400 Subject: [PATCH] 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 Acked-by: Silvano Seva --- openrtx/src/ui/default/ui.c | 38 ++++++++-------- openrtx/src/ui/default/ui_menu.c | 75 ++++++++++++++++---------------- 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/openrtx/src/ui/default/ui.c b/openrtx/src/ui/default/ui.c index 1733b8ed..46c0dbef 100644 --- a/openrtx/src/ui/default/ui.c +++ b/openrtx/src/ui/default/ui.c @@ -915,7 +915,23 @@ static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) case 1: 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; } @@ -935,30 +951,13 @@ static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) } break; - case 2: + case 3: if(state.channel.mode == OPMODE_FM) { 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); - } - 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, state.channel.fm.rxTone, state.channel.fm.txToneEn, @@ -2356,6 +2355,7 @@ void ui_updateFSM(bool *sync_rtx) } break; #endif + case SETTINGS_ACCESSIBILITY: if(msg.keys & KEY_LEFT || (ui_state.edit_mode && (msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT))) diff --git a/openrtx/src/ui/default/ui_menu.c b/openrtx/src/ui/default/ui_menu.c index 93beb6fc..82672aff 100644 --- a/openrtx/src/ui/default/ui_menu.c +++ b/openrtx/src/ui/default/ui_menu.c @@ -1097,21 +1097,34 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state) */ #if defined(CONFIG_UI_NO_KEYBOARD) if (ui_state->macro_menu_selected == 0) -#endif // CONFIG_UI_NO_KEYBOARD - gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT, - yellow_fab413, "1"); - - uint16_t tone = ctcss_tone[last_state.channel.fm.txTone]; - gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT, - color_white, " T- %d.%d", (tone / 10), (tone % 10)); - +#endif // CONFIG_UI_NO_KEYBOARD + gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT, + 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]; + gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT, + color_white, " %d.%d", (tone / 10), (tone % 10)); #if defined(CONFIG_UI_NO_KEYBOARD) if (ui_state->macro_menu_selected == 1) #endif // CONFIG_UI_NO_KEYBOARD gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER, yellow_fab413, "2"); gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER, - color_white, " T+"); + color_white, " T-"); } #ifdef CONFIG_M17 else if (last_state.channel.mode == OPMODE_M17) @@ -1125,26 +1138,12 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state) } #endif #if defined(CONFIG_UI_NO_KEYBOARD) - if (ui_state->macro_menu_selected == 2) -#endif // CONFIG_UI_NO_KEYBOARD - gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT, - 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, " "); + if (ui_state->macro_menu_selected == 2) +#endif // CONFIG_UI_NO_KEYBOARD + gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT, + yellow_fab413, "3 "); gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT, - color_white, encdec_str); + color_white, " T+"); } #ifdef CONFIG_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) { case BW_12_5: - sniprintf(bw_str, 12, " BW 12.5"); + sniprintf(bw_str, 12, " BW12.5"); break; case BW_25: - sniprintf(bw_str, 12, " BW 25 "); + sniprintf(bw_str, 12, " BW 25"); break; } @@ -1201,15 +1200,15 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state) switch(last_state.channel.mode) { case OPMODE_FM: - sniprintf(mode_str, 12," FM"); - break; + gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER, color_white, " FM"); + break; case OPMODE_DMR: - sniprintf(mode_str, 12," DMR"); - break; + gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER, color_white, " DMR"); + break; #ifdef CONFIG_M17 case OPMODE_M17: - sniprintf(mode_str, 12," M17"); - break; + gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER, color_white, " M17"); + break; #endif } @@ -1237,7 +1236,7 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state) yellow_fab413, "7"); #ifdef CONFIG_SCREEN_BRIGHTNESS gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_LEFT, - color_white, " B-"); + color_white, " B-"); gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_LEFT, color_white, " %5d", state.settings.brightness); @@ -1250,7 +1249,7 @@ bool _ui_drawMacroMenu(ui_state_t* ui_state) yellow_fab413, "8"); #ifdef CONFIG_SCREEN_BRIGHTNESS gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_CENTER, - color_white, " B+"); + color_white, " B+"); #endif #if defined(CONFIG_UI_NO_KEYBOARD)