Add SetLck

This commit is contained in:
Armel FAUVEAU
2024-02-11 03:47:31 +01:00
parent 2307976c17
commit d6a57be4c4
8 changed files with 46 additions and 1 deletions

View File

@@ -1756,7 +1756,14 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN;
#ifdef ENABLE_FEAT_F4HWN // Disable PTT if KEY_LOCK
if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT)
bool lck_condition = false;
if(gSetting_set_lck)
lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT;
else
lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT;
if (lck_condition)
#else
if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT)
#endif

View File

@@ -388,6 +388,10 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
break;
case MENU_SET_LCK:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_LCK) - 1;
break;
#endif
default:
@@ -852,6 +856,9 @@ void MENU_AcceptSetting(void)
case MENU_SET_INV:
gSetting_set_inv = gSubMenuSelection;
break;
case MENU_SET_LCK:
gSetting_set_lck = gSubMenuSelection;
break;
#endif
}
@@ -1238,6 +1245,9 @@ void MENU_ShowCurrentSetting(void)
case MENU_SET_INV:
gSubMenuSelection = gSetting_set_inv;
break;
case MENU_SET_LCK:
gSubMenuSelection = gSetting_set_lck;
break;
#endif
default:

1
misc.c
View File

@@ -102,6 +102,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
uint8_t gSetting_set_ctr = 11;
bool gSetting_set_inv = false;
uint8_t gSetting_set_eot = 0;
bool gSetting_set_lck = false;
bool gSetting_set_ptt_session;
#endif

1
misc.h
View File

@@ -163,6 +163,7 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern uint8_t gSetting_set_ctr;
extern bool gSetting_set_inv;
extern uint8_t gSetting_set_eot;
extern bool gSetting_set_lck;
extern bool gSetting_set_ptt_session;
#endif

View File

@@ -296,6 +296,8 @@ void SETTINGS_InitEEPROM(void)
gSetting_set_inv = (((Data[5] & 0xF0) >> 4) < 2) ? ((Data[5] & 0xF0) >> 4) : 0;
gSetting_set_ctr = (((Data[5] & 0x0F)) < 16) ? ((Data[5] & 0x0F)) : 5;
gSetting_set_lck = (Data[4] < 2) ? (Data[4]) : 0;
// And set special session settings for actions
gSetting_set_ptt_session = gSetting_set_ptt;
#endif
@@ -624,6 +626,7 @@ void SETTINGS_SaveSettings(void)
#ifdef ENABLE_FEAT_F4HWN
memset(State, 0xFF, sizeof(State));
State[4] = gSetting_set_lck;
State[5] = ((gSetting_set_inv << 4) | (gSetting_set_ctr & 0x0F));
State[6] = ((gSetting_set_tot << 4) | (gSetting_set_eot & 0x0F));
State[7] = ((gSetting_set_low << 4) | (gSetting_set_ptt & 0x0F));

View File

@@ -518,6 +518,7 @@ void UI_DisplayMain(void)
return;
}
#ifndef ENABLE_FEAT_F4HWN
if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
{ // tell user how to unlock the keyboard
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
@@ -525,6 +526,15 @@ void UI_DisplayMain(void)
ST7565_BlitFullScreen();
return;
}
#else
if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
{ // tell user how to unlock the keyboard
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
SYSTEM_DelayMs(50);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
SYSTEM_DelayMs(50);
}
#endif
unsigned int activeTxVFO = gRxVfoIsActive ? gEeprom.RX_VFO : gEeprom.TX_VFO;

View File

@@ -132,6 +132,7 @@ const t_menu_item MenuList[] =
{"SetEot", VOICE_ID_INVALID, MENU_SET_EOT },
{"SetCtr", VOICE_ID_INVALID, MENU_SET_CTR },
{"SetInv", VOICE_ID_INVALID, MENU_SET_INV },
{"SetLck", VOICE_ID_INVALID, MENU_SET_LCK },
#endif
// hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-on
@@ -370,6 +371,12 @@ const char gSubMenu_SCRAMBLER[][7] =
"VISUAL",
"ALL"
};
const char gSubMenu_SET_LCK[][9] =
{
"KEYS",
"KEYS+PTT"
};
#endif
const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
@@ -922,6 +929,10 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
ST7565_ContrastAndInv();
break;
case MENU_SET_LCK:
strcpy(String, gSubMenu_SET_LCK[gSubMenuSelection]);
break;
#endif
}

View File

@@ -128,6 +128,7 @@ enum
MENU_SET_EOT,
MENU_SET_CTR,
MENU_SET_INV,
MENU_SET_LCK,
#endif
MENU_BATCAL, // battery voltage calibration
MENU_F1SHRT,
@@ -165,6 +166,7 @@ extern const char gSubMenu_D_RSP[4][11];
extern const char gSubMenu_SET_LOW[5][7];
extern const char gSubMenu_SET_PTT[2][8];
extern const char gSubMenu_SET_TOT[4][7];
extern const char gSubMenu_SET_LCK[2][9];
#endif
extern const char* const gSubMenu_PTT_ID[5];