diff --git a/app/action.c b/app/action.c index 8ce66c5..3f39642 100644 --- a/app/action.c +++ b/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 funcLong = ACTION_OPT_NONE; - if (Key == KEY_SIDE1) - { - funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION; - funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION; - } - else if (Key == KEY_SIDE2) - { - funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION; - funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION; + switch(Key) { + case KEY_SIDE1: + funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION; + funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION; + break; + case KEY_SIDE2: + funcShort = gEeprom.KEY_2_SHORT_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 { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; return; } // 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 { diff --git a/app/app.c b/app/app.c index efc31b4..b6bb2ee 100644 --- a/app/app.c +++ b/app/app.c @@ -2050,9 +2050,14 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) 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; // keypad is locked, tell the user diff --git a/app/main.c b/app/main.c index edba67e..2e8b9e7 100644 --- a/app/main.c +++ b/app/main.c @@ -599,6 +599,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) gWasFKeyPressed = false; gUpdateStatus = true; + ACTION_Handle(KEY_MENU, bKeyPressed, bKeyHeld); } } diff --git a/app/menu.c b/app/menu.c index f74c63d..60e99a0 100644 --- a/app/menu.c +++ b/app/menu.c @@ -329,6 +329,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_F1LONG: case MENU_F2SHRT: case MENU_F2LONG: + case MENU_MLONG: *pMin = 0; *pMax = gSubMenu_SIDEFUNCTIONS_size-1; break; @@ -766,12 +767,14 @@ void MENU_AcceptSetting(void) case MENU_F1LONG: case MENU_F2SHRT: case MENU_F2LONG: + case MENU_MLONG: { uint8_t * fun[]= { &gEeprom.KEY_1_SHORT_PRESS_ACTION, &gEeprom.KEY_1_LONG_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; } break; @@ -1146,12 +1149,14 @@ void MENU_ShowCurrentSetting(void) case MENU_F1LONG: case MENU_F2SHRT: case MENU_F2LONG: + case MENU_MLONG: { uint8_t * fun[]= { &gEeprom.KEY_1_SHORT_PRESS_ACTION, &gEeprom.KEY_1_LONG_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]; for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) { diff --git a/board.c b/board.c index b907cc5..6a1f07e 100644 --- a/board.c +++ b/board.c @@ -590,7 +590,8 @@ void BOARD_EEPROM_Init(void) // 0E90..0E97 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_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; diff --git a/helper/boot.c b/helper/boot.c index a0e6d6d..bb20dab 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -84,6 +84,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) gEeprom.KEY_1_LONG_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_M_LONG_PRESS_ACTION = ACTION_OPT_NONE; RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500); diff --git a/settings.c b/settings.c index 81a69c4..29933fd 100644 --- a/settings.c +++ b/settings.c @@ -107,6 +107,7 @@ void SETTINGS_SaveSettings(void) EEPROM_WriteBuffer(0x0E78, State); State[0] = gEeprom.BEEP_CONTROL; + State[0] |= gEeprom.KEY_M_LONG_PRESS_ACTION << 1; State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION; State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION; State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION; diff --git a/settings.h b/settings.h index 8805846..6436092 100644 --- a/settings.h +++ b/settings.h @@ -226,7 +226,7 @@ typedef struct { uint8_t field78_0x96; uint8_t field79_0x97; - uint8_t _pad[1]; + uint8_t KEY_M_LONG_PRESS_ACTION; } EEPROM_Config_t; extern EEPROM_Config_t gEeprom; diff --git a/ui/menu.c b/ui/menu.c index e472023..7f93122 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -70,6 +70,7 @@ const t_menu_item MenuList[] = {"F1Long", VOICE_ID_INVALID, MENU_F1LONG }, {"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT }, {"F2Long", VOICE_ID_INVALID, MENU_F2LONG }, + {"M Long", VOICE_ID_INVALID, MENU_MLONG }, {"KeyLck", VOICE_ID_INVALID, MENU_AUTOLK }, // was "AUTOLk" {"TxTOut", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT" @@ -834,6 +835,7 @@ void UI_DisplayMenu(void) case MENU_F1LONG: case MENU_F2SHRT: case MENU_F2LONG: + case MENU_MLONG: strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name); break; diff --git a/ui/menu.h b/ui/menu.h index efcbbe8..2c9fd5e 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -117,7 +117,8 @@ enum MENU_F1SHRT, MENU_F1LONG, MENU_F2SHRT, - MENU_F2LONG + MENU_F2LONG, + MENU_MLONG }; extern const uint8_t FIRST_HIDDEN_MENU_ITEM;