From 364f8d4e46e825d1f840fa20c8d12c40edffe0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Thu, 28 Jan 2021 12:51:22 +0100 Subject: [PATCH] Add squelch visualization and control from macro menu --- openrtx/include/state.h | 1 + openrtx/src/ui/ui.c | 15 +++++++++++++++ openrtx/src/ui/ui_menu.c | 9 ++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/openrtx/include/state.h b/openrtx/include/state.h index db679c93..d1d62fc0 100644 --- a/openrtx/include/state.h +++ b/openrtx/include/state.h @@ -54,6 +54,7 @@ typedef struct channel_t channel; channel_t vfo_channel; uint8_t rtxStatus; + // Squelch steps from 0 to 15 uint8_t sqlLevel; uint8_t voxLevel; diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 4ddf8653..ffb1da20 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -72,6 +72,7 @@ #include #include #include +#include /* UI main screen functions, their implementation is in "ui_main.c" */ extern void _ui_drawMainBackground(); @@ -534,6 +535,20 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) { platform_setBacklightLevel(state.backlight_level); break; } + +#ifdef HAS_ABSOLUTE_KNOB // If the radio has an absolute position knob + state.sqlLevel = platform_getChSelector(); + printf("New squelch value: %d\n\r", state.sqlLevel); +#else // Use left and right buttons or relative position knob + if(msg.keys && KEY_LEFT) { + state.sqlLevel++; + state.sqlLevel = (state.sqlLevel > 15) 15 : state.sqlLevel; + } + else if(msg.keys && KEY_RIGHT) { + state.sqlLevel--; + state.sqlLevel = (state.sqlLevel < 0) 0 : state.sqlLevel; + } +#endif } void ui_updateFSM(event_t event, bool *sync_rtx) diff --git a/openrtx/src/ui/ui_menu.c b/openrtx/src/ui/ui_menu.c index 2aafeb49..9e7ce7f7 100644 --- a/openrtx/src/ui/ui_menu.c +++ b/openrtx/src/ui/ui_menu.c @@ -304,5 +304,12 @@ bool _ui_drawMacroMenu(state_t* last_state) { yellow_fab413); gfx_print(layout.line3_right, "Sav", layout.top_font, TEXT_ALIGN_RIGHT, color_white); - return true; + // Squelch bar + uint16_t squelch_width = SCREEN_WIDTH / 16 * last_state->sqlLevel; + point_t squelch_pos = { layout.bottom_left.x, layout.bottom_left.y + + layout.status_v_pad + + layout.text_v_offset - + layout.bottom_h }; + gfx_drawRect(squelch_pos, squelch_width, layout.bottom_h, color_white, true); + return true; }