power on password on/off from menu.

This commit is contained in:
Nunu 2024-01-13 16:42:19 +01:00
parent 545692b2f0
commit aed640620f
5 changed files with 60 additions and 32 deletions

View File

@ -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;

2
main.c
View File

@ -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();

6
misc.h
View File

@ -51,6 +51,12 @@ enum {
LAST_CHANNEL
};
#ifdef ENABLE_PWRON_PASSWORD
enum {
PASSWORD_OFF = 10000u
};
#endif
enum {
FLASHLIGHT_OFF = 0,
FLASHLIGHT_ON,

View File

@ -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]);

View File

@ -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,