Change macro latching behavior

Latch macro menu when macro button is long pressed
Unlatch macro menu when macro button is pressed again
This commit is contained in:
Marco 2023-08-08 20:20:14 +02:00 committed by Silvano Seva
parent 29b6eb08ff
commit 8399dcd3a3
3 changed files with 14 additions and 6 deletions

View File

@ -207,8 +207,8 @@ typedef struct ui_state_t
ui_state_t; ui_state_t;
extern layout_t layout; extern layout_t layout;
// Copy of the radio state
extern state_t last_state; extern state_t last_state;
extern bool macro_latched;
extern const char *menu_items[]; extern const char *menu_items[];
extern const char *settings_items[]; extern const char *settings_items[];
extern const char *display_items[]; extern const char *display_items[];

View File

@ -256,6 +256,7 @@ const color_t yellow_fab413 = {250, 180, 19, 255};
layout_t layout; layout_t layout;
state_t last_state; state_t last_state;
bool macro_latched;
static ui_state_t ui_state; static ui_state_t ui_state;
static bool macro_menu = false; static bool macro_menu = false;
static bool layout_ready = false; static bool layout_ready = false;
@ -1268,17 +1269,19 @@ void ui_updateFSM(bool *sync_rtx)
// If MONI is pressed, activate MACRO functions // If MONI is pressed, activate MACRO functions
bool moniPressed = (msg.keys & KEY_MONI) ? true : false; bool moniPressed = (msg.keys & KEY_MONI) ? true : false;
if(moniPressed || FunctionKeyIsLatched()) if(moniPressed || macro_latched)
{ {
macro_menu = true; macro_menu = true;
// long press moni on its own latches function. // long press moni on its own latches function.
if (moniPressed && msg.long_press && !input_getPressedNumber(msg)) if (moniPressed && msg.long_press && !macro_latched)
{ {
SetFunctionLatchTimer(); // 3000 ms. macro_latched = true;
vp_beep(BEEP_FUNCTION_LATCH_ON, LONG_BEEP);
} }
else else if (moniPressed && macro_latched)
{ {
ReleaseFunctionLatchIfNeeded(); macro_latched = false;
vp_beep(BEEP_FUNCTION_LATCH_OFF, LONG_BEEP);
} }
_ui_fsm_menuMacro(msg, sync_rtx); _ui_fsm_menuMacro(msg, sync_rtx);
return; return;

View File

@ -877,6 +877,11 @@ bool _ui_drawMacroMenu()
// Header // Header
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER, gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
color_white, currentLanguage->macroMenu); color_white, currentLanguage->macroMenu);
if (macro_latched)
{
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, "L");
}
// First row // First row
if (last_state.channel.mode == OPMODE_FM) if (last_state.channel.mode == OPMODE_FM)
{ {