Add menu configurable long-press function for MENU button
This commit is contained in:
19
app/action.c
19
app/action.c
@@ -358,26 +358,31 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
uint8_t funcShort = ACTION_OPT_NONE;
|
uint8_t funcShort = ACTION_OPT_NONE;
|
||||||
uint8_t funcLong = ACTION_OPT_NONE;
|
uint8_t funcLong = ACTION_OPT_NONE;
|
||||||
if (Key == KEY_SIDE1)
|
switch(Key) {
|
||||||
{
|
case KEY_SIDE1:
|
||||||
funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||||
funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
||||||
}
|
break;
|
||||||
else if (Key == KEY_SIDE2)
|
case KEY_SIDE2:
|
||||||
{
|
|
||||||
funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
||||||
funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION;
|
funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION;
|
||||||
|
break;
|
||||||
|
case KEY_MENU:
|
||||||
|
funcLong = gEeprom.KEY_M_LONG_PRESS_ACTION;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bKeyHeld && bKeyPressed) // button pushed
|
if (!bKeyHeld && bKeyPressed) // button pushed
|
||||||
{
|
{
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// held or released beyond this point
|
// held or released beyond this point
|
||||||
|
|
||||||
|
if(!(bKeyHeld && !bKeyPressed)) // don't beep on released after hold
|
||||||
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
if (bKeyHeld || bKeyPressed) // held
|
if (bKeyHeld || bKeyPressed) // held
|
||||||
{
|
{
|
||||||
|
@@ -2050,9 +2050,14 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
|
// KEY_MENU has a special treatment here, because we want to pass hold event to ACTION_Handle
|
||||||
|
// but we don't want it to complain when initial press happens
|
||||||
|
// we want to react on realese instead
|
||||||
|
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && // pass side buttons
|
||||||
|
!(Key == KEY_MENU && bKeyHeld)) // pass KEY_MENU held
|
||||||
{
|
{
|
||||||
if (!bKeyPressed || bKeyHeld) // released or held
|
if ((!bKeyPressed || bKeyHeld || (Key == KEY_MENU && bKeyPressed)) && // prevent released or held, prevent KEY_MENU pressed
|
||||||
|
!(Key == KEY_MENU && !bKeyPressed)) // pass KEY_MENU released
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// keypad is locked, tell the user
|
// keypad is locked, tell the user
|
||||||
|
@@ -599,6 +599,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
gWasFKeyPressed = false;
|
gWasFKeyPressed = false;
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
|
|
||||||
|
ACTION_Handle(KEY_MENU, bKeyPressed, bKeyHeld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -329,6 +329,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
|
|||||||
case MENU_F1LONG:
|
case MENU_F1LONG:
|
||||||
case MENU_F2SHRT:
|
case MENU_F2SHRT:
|
||||||
case MENU_F2LONG:
|
case MENU_F2LONG:
|
||||||
|
case MENU_MLONG:
|
||||||
*pMin = 0;
|
*pMin = 0;
|
||||||
*pMax = gSubMenu_SIDEFUNCTIONS_size-1;
|
*pMax = gSubMenu_SIDEFUNCTIONS_size-1;
|
||||||
break;
|
break;
|
||||||
@@ -766,12 +767,14 @@ void MENU_AcceptSetting(void)
|
|||||||
case MENU_F1LONG:
|
case MENU_F1LONG:
|
||||||
case MENU_F2SHRT:
|
case MENU_F2SHRT:
|
||||||
case MENU_F2LONG:
|
case MENU_F2LONG:
|
||||||
|
case MENU_MLONG:
|
||||||
{
|
{
|
||||||
uint8_t * fun[]= {
|
uint8_t * fun[]= {
|
||||||
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
|
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
|
||||||
&gEeprom.KEY_1_LONG_PRESS_ACTION,
|
&gEeprom.KEY_1_LONG_PRESS_ACTION,
|
||||||
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
|
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
|
||||||
&gEeprom.KEY_2_LONG_PRESS_ACTION};
|
&gEeprom.KEY_2_LONG_PRESS_ACTION,
|
||||||
|
&gEeprom.KEY_M_LONG_PRESS_ACTION};
|
||||||
*fun[GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id;
|
*fun[GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1146,12 +1149,14 @@ void MENU_ShowCurrentSetting(void)
|
|||||||
case MENU_F1LONG:
|
case MENU_F1LONG:
|
||||||
case MENU_F2SHRT:
|
case MENU_F2SHRT:
|
||||||
case MENU_F2LONG:
|
case MENU_F2LONG:
|
||||||
|
case MENU_MLONG:
|
||||||
{
|
{
|
||||||
uint8_t * fun[]= {
|
uint8_t * fun[]= {
|
||||||
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
|
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
|
||||||
&gEeprom.KEY_1_LONG_PRESS_ACTION,
|
&gEeprom.KEY_1_LONG_PRESS_ACTION,
|
||||||
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
|
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
|
||||||
&gEeprom.KEY_2_LONG_PRESS_ACTION};
|
&gEeprom.KEY_2_LONG_PRESS_ACTION,
|
||||||
|
&gEeprom.KEY_M_LONG_PRESS_ACTION};
|
||||||
uint8_t id = *fun[GetCurrentMenuId()-MENU_F1SHRT];
|
uint8_t id = *fun[GetCurrentMenuId()-MENU_F1SHRT];
|
||||||
|
|
||||||
for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) {
|
for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) {
|
||||||
|
3
board.c
3
board.c
@@ -590,7 +590,8 @@ void BOARD_EEPROM_Init(void)
|
|||||||
|
|
||||||
// 0E90..0E97
|
// 0E90..0E97
|
||||||
EEPROM_ReadBuffer(0x0E90, Data, 8);
|
EEPROM_ReadBuffer(0x0E90, Data, 8);
|
||||||
gEeprom.BEEP_CONTROL = (Data[0] < 2) ? Data[0] : true;
|
gEeprom.BEEP_CONTROL = Data[0] & 1;
|
||||||
|
gEeprom.KEY_M_LONG_PRESS_ACTION = ((Data[0] >> 1) < ACTION_OPT_LEN) ? (Data[0] >> 1) : ACTION_OPT_NONE;
|
||||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
|
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
|
||||||
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
|
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
|
||||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
|
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
|
||||||
|
@@ -84,6 +84,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
|
|||||||
gEeprom.KEY_1_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
gEeprom.KEY_1_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
||||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = ACTION_OPT_NONE;
|
gEeprom.KEY_2_SHORT_PRESS_ACTION = ACTION_OPT_NONE;
|
||||||
gEeprom.KEY_2_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
gEeprom.KEY_2_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
||||||
|
gEeprom.KEY_M_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
||||||
|
|
||||||
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500);
|
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500);
|
||||||
|
|
||||||
|
@@ -107,6 +107,7 @@ void SETTINGS_SaveSettings(void)
|
|||||||
EEPROM_WriteBuffer(0x0E78, State);
|
EEPROM_WriteBuffer(0x0E78, State);
|
||||||
|
|
||||||
State[0] = gEeprom.BEEP_CONTROL;
|
State[0] = gEeprom.BEEP_CONTROL;
|
||||||
|
State[0] |= gEeprom.KEY_M_LONG_PRESS_ACTION << 1;
|
||||||
State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||||
State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
||||||
State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
||||||
|
@@ -226,7 +226,7 @@ typedef struct {
|
|||||||
uint8_t field78_0x96;
|
uint8_t field78_0x96;
|
||||||
uint8_t field79_0x97;
|
uint8_t field79_0x97;
|
||||||
|
|
||||||
uint8_t _pad[1];
|
uint8_t KEY_M_LONG_PRESS_ACTION;
|
||||||
} EEPROM_Config_t;
|
} EEPROM_Config_t;
|
||||||
|
|
||||||
extern EEPROM_Config_t gEeprom;
|
extern EEPROM_Config_t gEeprom;
|
||||||
|
@@ -70,6 +70,7 @@ const t_menu_item MenuList[] =
|
|||||||
{"F1Long", VOICE_ID_INVALID, MENU_F1LONG },
|
{"F1Long", VOICE_ID_INVALID, MENU_F1LONG },
|
||||||
{"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT },
|
{"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT },
|
||||||
{"F2Long", VOICE_ID_INVALID, MENU_F2LONG },
|
{"F2Long", VOICE_ID_INVALID, MENU_F2LONG },
|
||||||
|
{"M Long", VOICE_ID_INVALID, MENU_MLONG },
|
||||||
|
|
||||||
{"KeyLck", VOICE_ID_INVALID, MENU_AUTOLK }, // was "AUTOLk"
|
{"KeyLck", VOICE_ID_INVALID, MENU_AUTOLK }, // was "AUTOLk"
|
||||||
{"TxTOut", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
|
{"TxTOut", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
|
||||||
@@ -834,6 +835,7 @@ void UI_DisplayMenu(void)
|
|||||||
case MENU_F1LONG:
|
case MENU_F1LONG:
|
||||||
case MENU_F2SHRT:
|
case MENU_F2SHRT:
|
||||||
case MENU_F2LONG:
|
case MENU_F2LONG:
|
||||||
|
case MENU_MLONG:
|
||||||
strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name);
|
strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user