From 397561e0e1c142ae8fa5dc486f9ccd59cc79cdf2 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Wed, 13 Nov 2024 06:17:32 +0100 Subject: [PATCH] Add SetKey for RescueOps --- app/menu.c | 16 ++++++++++++++++ helper/boot.c | 4 ++-- main.c | 13 ++++++++----- settings.c | 3 ++- settings.h | 1 + ui/menu.c | 20 ++++++++++++++++++++ ui/menu.h | 6 ++++++ 7 files changed, 55 insertions(+), 8 deletions(-) diff --git a/app/menu.c b/app/menu.c index b8cbd6a..03e7252 100644 --- a/app/menu.c +++ b/app/menu.c @@ -432,6 +432,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = 63; break; #endif + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + case MENU_SET_KEY: + //*pMin = 0; + *pMax = 4; + break; + #endif #endif default: @@ -945,6 +951,11 @@ void MENU_AcceptSetting(void) gEeprom.VOLUME_GAIN = gSubMenuSelection; break; #endif + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + case MENU_SET_KEY: + gEeprom.SET_KEY = gSubMenuSelection; + break; + #endif case MENU_SET_TMR: gSetting_set_tmr = gSubMenuSelection; break; @@ -1391,6 +1402,11 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gEeprom.VOLUME_GAIN; break; #endif + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + case MENU_SET_KEY: + gSubMenuSelection = gEeprom.SET_KEY; + break; + #endif case MENU_SET_TMR: gSubMenuSelection = gSetting_set_tmr; break; diff --git a/helper/boot.c b/helper/boot.c index 27cc369..049cc40 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -45,9 +45,9 @@ BOOT_Mode_t BOOT_GetMode(void) } #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK - if (Keys[0] == KEY_MENU) + if (Keys[0] == (10 + gEeprom.SET_KEY)) { - return BOOT_MODE_MENU_LOCK; // Menu pressed + return BOOT_MODE_MENU_LOCK; // Secret KEY pressed } #endif diff --git a/main.c b/main.c index 8b0794a..3253976 100644 --- a/main.c +++ b/main.c @@ -164,11 +164,14 @@ void Main(void) #ifndef ENABLE_VOX gMenuCursor = 65; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar #else - #ifdef ENABLE_FEAT_F4HWN_SLEEP - gMenuCursor = 68; // move to hidden section, fix me if change... !!! - #else - gMenuCursor = 67; // move to hidden section, fix me if change... !!! - #endif + gMenuCursor = 68; // move to hidden section, fix me if change... !!! + #endif + + #ifdef ENABLE_NOAA + gMenuCursor += 1; // move to hidden section, fix me if change... !!! + #endif + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + gMenuCursor += 1; // move to hidden section, fix me if change... !!! #endif gSubMenuSelection = gSetting_F_LOCK; #endif diff --git a/settings.c b/settings.c index 9c7e0e9..d7a052e 100644 --- a/settings.c +++ b/settings.c @@ -54,6 +54,7 @@ void SETTINGS_InitEEPROM(void) #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0; gEeprom.MENU_LOCK = (Data[4] & 0x02) != 0; + gEeprom.SET_KEY = (Data[4] >> 2) & 0x0F; #else gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; #endif @@ -597,7 +598,7 @@ void SETTINGS_SaveSettings(void) #endif #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK - State[4] = (gEeprom.KEY_LOCK ? 0x01 : 0) | (gEeprom.MENU_LOCK ? 0x02 :0); + State[4] = (gEeprom.KEY_LOCK ? 0x01 : 0) | (gEeprom.MENU_LOCK ? 0x02 :0) | ((gEeprom.SET_KEY & 0x0F) << 2); #else State[4] = gEeprom.KEY_LOCK; #endif diff --git a/settings.h b/settings.h index bec443b..e2859da 100644 --- a/settings.h +++ b/settings.h @@ -188,6 +188,7 @@ typedef struct { #endif #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK bool MENU_LOCK; + uint8_t SET_KEY; #endif bool VOX_SWITCH; uint8_t VOX_LEVEL; diff --git a/ui/menu.c b/ui/menu.c index 704f30b..f753435 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -158,6 +158,9 @@ const t_menu_item MenuList[] = #ifdef ENABLE_FEAT_F4HWN_VOL {"SetVol", MENU_SET_VOL }, #endif +#ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + {"SetKey", MENU_SET_KEY }, +#endif #endif // hidden menu items from here on // enabled if pressing both the PTT and upper side button at power-on @@ -397,6 +400,17 @@ const char gSubMenu_SCRAMBLER[][7] = "NARROWER" }; #endif + + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + const char gSubMenu_SET_KEY[][9] = + { + "KEY_MENU", + "KEY_UP", + "KEY_DOWN", + "KEY_EXIT", + "KEY_STAR" + }; + #endif #endif const t_sidefunction gSubMenu_SIDEFUNCTIONS[] = @@ -1065,6 +1079,12 @@ void UI_DisplayMenu(void) (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) break; #endif + + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + case MENU_SET_KEY: + strcpy(String, gSubMenu_SET_KEY[gSubMenuSelection]); + break; + #endif #endif } diff --git a/ui/menu.h b/ui/menu.h index b7efb20..5379204 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -147,6 +147,9 @@ enum #ifdef ENABLE_FEAT_F4HWN_VOL MENU_SET_VOL, #endif + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + MENU_SET_KEY, + #endif #endif MENU_BATCAL, // battery voltage calibration MENU_F1SHRT, @@ -187,6 +190,9 @@ extern const char gSubMenu_D_RSP[4][11]; #ifdef ENABLE_FEAT_F4HWN_NARROWER extern const char gSubMenu_SET_NFM[2][9]; #endif + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + extern const char gSubMenu_SET_KEY[][9]; + #endif #endif extern const char* const gSubMenu_PTT_ID[5];