diff --git a/app/menu.c b/app/menu.c index 6cccc77..42c34f9 100644 --- a/app/menu.c +++ b/app/menu.c @@ -474,10 +474,12 @@ void MENU_AcceptSetting(void) gUpdateStatus = true; break; - case MENU_PASSWORD: - gEeprom.POWER_ON_PASSWORD = MIN(gSubMenuSelection, 9999); - gUpdateStatus = true; - break; + #ifdef ENABLE_PWRON_PASSWORD + case MENU_PASSWORD: + gEeprom.POWER_ON_PASSWORD = MIN(gSubMenuSelection, PASSWORD_OFF); + gUpdateStatus = true; + break; + #endif case MENU_W_N: gTxVfo->CHANNEL_BANDWIDTH = gSubMenuSelection; @@ -908,9 +910,11 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gEeprom.RX_OFFSET; break; - case MENU_PASSWORD: - gSubMenuSelection = gEeprom.POWER_ON_PASSWORD; - break; + #ifdef ENABLE_PWRON_PASSWORD + case MENU_PASSWORD: + gSubMenuSelection = gEeprom.POWER_ON_PASSWORD; + break; + #endif case MENU_W_N: gSubMenuSelection = gTxVfo->CHANNEL_BANDWIDTH; @@ -1268,16 +1272,17 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gInputBoxIndex = 0; return; } + #ifdef ENABLE_PWRON_PASSWORD + if (UI_MENU_GetCurrentMenuId() == MENU_PASSWORD) + { + // get 4 digits + if (gInputBoxIndex < 4) { return; } - if (UI_MENU_GetCurrentMenuId() == MENU_PASSWORD) - { - // get 4 digits - if (gInputBoxIndex < 4) { return; } - - uint32_t Password; - Password = StrToUL(INPUTBOX_GetAscii()); - gSubMenuSelection = Password; - } + uint32_t Password; + Password = StrToUL(INPUTBOX_GetAscii()); + gSubMenuSelection = Password; + } + #endif if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || @@ -1670,6 +1675,13 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) gRequestDisplayScreen = DISPLAY_MENU; return; } + #ifdef ENABLE_PWRON_PASSWORD + if (UI_MENU_GetCurrentMenuId() == MENU_PASSWORD) + { + gSubMenuSelection = PASSWORD_OFF; + gRequestDisplayScreen = DISPLAY_MENU; + } + #endif VFO = 0; diff --git a/main.c b/main.c index c51d526..d4d4d26 100644 --- a/main.c +++ b/main.c @@ -174,7 +174,7 @@ void Main(void) } #ifdef ENABLE_PWRON_PASSWORD - if (gEeprom.POWER_ON_PASSWORD < 10000) + if (gEeprom.POWER_ON_PASSWORD < PASSWORD_OFF) { bIsInLockScreen = true; UI_DisplayLock(); diff --git a/misc.h b/misc.h index 08a901e..e053833 100644 --- a/misc.h +++ b/misc.h @@ -51,6 +51,12 @@ enum { LAST_CHANNEL }; +#ifdef ENABLE_PWRON_PASSWORD +enum { + PASSWORD_OFF = 10000u +}; +#endif + enum { FLASHLIGHT_OFF = 0, FLASHLIGHT_ON, diff --git a/ui/menu.c b/ui/menu.c index d2299f7..0a26563 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -109,7 +109,9 @@ const t_menu_item MenuList[] = #endif {"BatVol", VOICE_ID_INVALID, MENU_VOL }, // was "VOL" {"RxMode", VOICE_ID_DUAL_STANDBY, MENU_TDR }, +#ifdef ENABLE_PWRON_PASSWORD {"Passwd", VOICE_ID_INVALID, MENU_PASSWORD }, // power on password +#endif {"Sql", VOICE_ID_SQUELCH, MENU_SQL }, // hidden menu items from here on // enabled if pressing both the PTT and upper side button at power-on @@ -560,22 +562,28 @@ void UI_DisplayMenu(void) already_printed = true; break; - - case MENU_PASSWORD: - if (!gIsInSubMenu || gInputBoxIndex == 0) - { - sprintf(String, "%4d", gSubMenuSelection); + #ifdef ENABLE_PWRON_PASSWORD + case MENU_PASSWORD: + if (!gIsInSubMenu || gInputBoxIndex == 0) + { + if(gSubMenuSelection >= PASSWORD_OFF) + { + sprintf(String, "OFF"); + } + else + { + sprintf(String, "****"); + } + } + else + { + const char * ascii = INPUTBOX_GetAscii(); + sprintf(String, "%.4s ",ascii); + } UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8); - } - else - { - const char * ascii = INPUTBOX_GetAscii(); - sprintf(String, "%.4s ",ascii); - UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8); - } - - already_printed = true; - break; + already_printed = true; + break; + #endif case MENU_W_N: strcpy(String, bwNames[gSubMenuSelection]); diff --git a/ui/menu.h b/ui/menu.h index 47ef91e..ff13387 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -59,7 +59,9 @@ enum MENU_ABR_MIN, MENU_ABR_MAX, MENU_TDR, +#ifdef ENABLE_PWRON_PASSWORD MENU_PASSWORD, +#endif MENU_BEEP, #ifdef ENABLE_VOICE MENU_VOICE,