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; bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN;
#ifdef ENABLE_FEAT_F4HWN // Disable PTT if KEY_LOCK #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 #else
if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT)
#endif #endif

View File

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

1
misc.c
View File

@@ -102,6 +102,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
uint8_t gSetting_set_ctr = 11; uint8_t gSetting_set_ctr = 11;
bool gSetting_set_inv = false; bool gSetting_set_inv = false;
uint8_t gSetting_set_eot = 0; uint8_t gSetting_set_eot = 0;
bool gSetting_set_lck = false;
bool gSetting_set_ptt_session; bool gSetting_set_ptt_session;
#endif #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 uint8_t gSetting_set_ctr;
extern bool gSetting_set_inv; extern bool gSetting_set_inv;
extern uint8_t gSetting_set_eot; extern uint8_t gSetting_set_eot;
extern bool gSetting_set_lck;
extern bool gSetting_set_ptt_session; extern bool gSetting_set_ptt_session;
#endif #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_inv = (((Data[5] & 0xF0) >> 4) < 2) ? ((Data[5] & 0xF0) >> 4) : 0;
gSetting_set_ctr = (((Data[5] & 0x0F)) < 16) ? ((Data[5] & 0x0F)) : 5; 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 // And set special session settings for actions
gSetting_set_ptt_session = gSetting_set_ptt; gSetting_set_ptt_session = gSetting_set_ptt;
#endif #endif
@@ -624,6 +626,7 @@ void SETTINGS_SaveSettings(void)
#ifdef ENABLE_FEAT_F4HWN #ifdef ENABLE_FEAT_F4HWN
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[4] = gSetting_set_lck;
State[5] = ((gSetting_set_inv << 4) | (gSetting_set_ctr & 0x0F)); State[5] = ((gSetting_set_inv << 4) | (gSetting_set_ctr & 0x0F));
State[6] = ((gSetting_set_tot << 4) | (gSetting_set_eot & 0x0F)); State[6] = ((gSetting_set_tot << 4) | (gSetting_set_eot & 0x0F));
State[7] = ((gSetting_set_low << 4) | (gSetting_set_ptt & 0x0F)); State[7] = ((gSetting_set_low << 4) | (gSetting_set_ptt & 0x0F));

View File

@@ -518,6 +518,7 @@ void UI_DisplayMain(void)
return; return;
} }
#ifndef ENABLE_FEAT_F4HWN
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
{ // tell user how to unlock the keyboard { // tell user how to unlock the keyboard
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8); UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
@@ -525,6 +526,15 @@ void UI_DisplayMain(void)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
return; 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; 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 }, {"SetEot", VOICE_ID_INVALID, MENU_SET_EOT },
{"SetCtr", VOICE_ID_INVALID, MENU_SET_CTR }, {"SetCtr", VOICE_ID_INVALID, MENU_SET_CTR },
{"SetInv", VOICE_ID_INVALID, MENU_SET_INV }, {"SetInv", VOICE_ID_INVALID, MENU_SET_INV },
{"SetLck", VOICE_ID_INVALID, MENU_SET_LCK },
#endif #endif
// hidden menu items from here on // hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-on // enabled if pressing both the PTT and upper side button at power-on
@@ -370,6 +371,12 @@ const char gSubMenu_SCRAMBLER[][7] =
"VISUAL", "VISUAL",
"ALL" "ALL"
}; };
const char gSubMenu_SET_LCK[][9] =
{
"KEYS",
"KEYS+PTT"
};
#endif #endif
const t_sidefunction gSubMenu_SIDEFUNCTIONS[] = const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
@@ -922,6 +929,10 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
ST7565_ContrastAndInv(); ST7565_ContrastAndInv();
break; break;
case MENU_SET_LCK:
strcpy(String, gSubMenu_SET_LCK[gSubMenuSelection]);
break;
#endif #endif
} }

View File

@@ -128,6 +128,7 @@ enum
MENU_SET_EOT, MENU_SET_EOT,
MENU_SET_CTR, MENU_SET_CTR,
MENU_SET_INV, MENU_SET_INV,
MENU_SET_LCK,
#endif #endif
MENU_BATCAL, // battery voltage calibration MENU_BATCAL, // battery voltage calibration
MENU_F1SHRT, 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_LOW[5][7];
extern const char gSubMenu_SET_PTT[2][8]; extern const char gSubMenu_SET_PTT[2][8];
extern const char gSubMenu_SET_TOT[4][7]; extern const char gSubMenu_SET_TOT[4][7];
extern const char gSubMenu_SET_LCK[2][9];
#endif #endif
extern const char* const gSubMenu_PTT_ID[5]; extern const char* const gSubMenu_PTT_ID[5];