diff --git a/app/menu.c b/app/menu.c index 8a0fb90..826c709 100644 --- a/app/menu.c +++ b/app/menu.c @@ -280,7 +280,6 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_S_LIST: *pMin = 0; -// *pMax = 1; *pMax = 2; break; @@ -326,6 +325,14 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = 2200; // 2300 break; + case MENU_F1SHRT: + case MENU_F1LONG: + case MENU_F2SHRT: + case MENU_F2LONG: + *pMin = 0; + *pMax = gSubMenu_SIDEFUNCTIONS_size-1; + break; + default: return -1; } @@ -745,23 +752,30 @@ void MENU_AcceptSetting(void) case MENU_BATCAL: { - uint16_t buf[4]; - gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below gBatteryCalibration[1] = (700ul * gSubMenuSelection) / 760; // 7.00V, ~5%, 1 bars above this value gBatteryCalibration[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value gBatteryCalibration[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value gBatteryCalibration[5] = 2300; - EEPROM_WriteBuffer(0x1F40, gBatteryCalibration); - - EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf)); - buf[0] = gBatteryCalibration[4]; - buf[1] = gBatteryCalibration[5]; - EEPROM_WriteBuffer(0x1F48, buf); - - break; + SETTINGS_SaveBatteryCalibration(gBatteryCalibration); + return; } + + case MENU_F1SHRT: + case MENU_F1LONG: + case MENU_F2SHRT: + case MENU_F2LONG: + { + 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}; + *fun[GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id; + } + break; + } gRequestSaveSettings = true; @@ -1128,6 +1142,28 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gBatteryCalibration[3]; break; + case MENU_F1SHRT: + case MENU_F1LONG: + case MENU_F2SHRT: + case MENU_F2LONG: + { + 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}; + uint8_t id = *fun[GetCurrentMenuId()-MENU_F1SHRT]; + + for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) { + if(gSubMenu_SIDEFUNCTIONS[i].id==id) { + gSubMenuSelection = i; + break; + } + + } + break; + } + default: return; } diff --git a/settings.c b/settings.c index 1910c55..81a69c4 100644 --- a/settings.c +++ b/settings.c @@ -251,6 +251,16 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, } } +void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration) +{ + uint16_t buf[4]; + EEPROM_WriteBuffer(0x1F40, batteryCalibration); + EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf)); + buf[0] = batteryCalibration[4]; + buf[1] = batteryCalibration[5]; + EEPROM_WriteBuffer(0x1F48, buf); +} + void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) { #ifdef ENABLE_NOAA diff --git a/settings.h b/settings.h index 6ead31b..0d30239 100644 --- a/settings.h +++ b/settings.h @@ -229,6 +229,7 @@ extern EEPROM_Config_t gEeprom; void SETTINGS_SaveVfoIndices(void); void SETTINGS_SaveSettings(void); void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); +void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration); void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep); #endif diff --git a/ui/menu.c b/ui/menu.c index b12a92b..19884c8 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -66,6 +66,11 @@ const t_menu_item MenuList[] = {"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S }, #endif + {"F1Shrt", VOICE_ID_INVALID, MENU_F1SHRT }, + {"F1Long", VOICE_ID_INVALID, MENU_F1LONG }, + {"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT }, + {"F2Long", VOICE_ID_INVALID, MENU_F2LONG }, + {"KeyLck", VOICE_ID_INVALID, MENU_AUTOLK }, // was "AUTOLk" {"TxTOut", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT" {"BatSav", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE" @@ -185,10 +190,10 @@ const char gSubMenu_TOT[11][7] = const char* gSubMenu_RXMode[4] = { - "MAIN\nONLY", // TX and RX on main only + "MAIN\nONLY", // TX and RX on main only "DUAL RX\nRESPOND", // Watch both and respond - "CROSS\nBAND", // TX on main, RX on secondary - "MAIN TX\nDUAL RX" // always TX on main, but RX on both + "CROSS\nBAND", // TX on main, RX on secondary + "MAIN TX\nDUAL RX" // always TX on main, but RX on both }; #ifdef ENABLE_VOICE @@ -248,7 +253,7 @@ const char gSubMenu_PONMSG[4][8] = "NONE" }; -const char gSubMenu_ROGER[3][9] = +const char* gSubMenu_ROGER[3] = { "OFF", "ROGER", @@ -323,6 +328,30 @@ const char gSubMenu_SCRAMBLER[11][7] = "3500Hz" }; + +const t_sidefunction SIDEFUNCTIONS[] = +{ + {"NONE", ACTION_OPT_NONE}, + {"FLASH\nLIGHT", ACTION_OPT_FLASHLIGHT}, + {"POWER", ACTION_OPT_POWER}, + {"MONITOR", ACTION_OPT_MONITOR}, + {"SCAN", ACTION_OPT_SCAN}, +#ifdef ENABLE_VOX + {"VOX", ACTION_OPT_VOX}, +#endif +#ifdef ENABLE_ALARM + {"ALARM", ACTION_OPT_ALARM}, +#endif +#ifdef ENABLE_FMRADIO + {"FM RADIO", ACTION_OPT_FM}, +#endif +#ifdef ENABLE_TX1750 + {"1750HZ", ACTION_OPT_1750}, +#endif +}; +const t_sidefunction* gSubMenu_SIDEFUNCTIONS = SIDEFUNCTIONS; +const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS); + bool gIsInSubMenu; uint8_t gMenuCursor; int GetCurrentMenuId() { @@ -798,6 +827,14 @@ void UI_DisplayMenu(void) sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection); break; } + + case MENU_F1SHRT: + case MENU_F1LONG: + case MENU_F2SHRT: + case MENU_F2LONG: + strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name); + break; + } if (!already_printed) diff --git a/ui/menu.h b/ui/menu.h index b2069e9..efcbbe8 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -102,9 +102,6 @@ enum MENU_NOAA_S, #endif MENU_RESET, - - // items after here are normally hidden - MENU_F_LOCK, MENU_200TX, MENU_350TX, @@ -116,7 +113,11 @@ enum #ifdef ENABLE_F_CAL_MENU MENU_F_CALI, // reference xtal calibration #endif - MENU_BATCAL // battery voltage calibration + MENU_BATCAL, // battery voltage calibration + MENU_F1SHRT, + MENU_F1LONG, + MENU_F2SHRT, + MENU_F2LONG }; extern const uint8_t FIRST_HIDDEN_MENU_ITEM; @@ -141,7 +142,7 @@ extern const char* gSubMenu_MDF[4]; extern const char gSubMenu_D_RSP[4][11]; extern const char* gSubMenu_PTT_ID[5]; extern const char gSubMenu_PONMSG[4][8]; -extern const char gSubMenu_ROGER[3][9]; +extern const char* gSubMenu_ROGER[3]; extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_F_LOCK[6][4]; extern const char gSubMenu_BACKLIGHT[8][7]; @@ -152,6 +153,10 @@ extern const char gSubMenu_RX_TX[4][6]; extern const char gSubMenu_BAT_TXT[3][8]; extern const char gSubMenu_SCRAMBLER[11][7]; + +typedef struct {char* name; uint8_t id;} t_sidefunction; +extern const uint8_t gSubMenu_SIDEFUNCTIONS_size; +extern const t_sidefunction* gSubMenu_SIDEFUNCTIONS; extern bool gIsInSubMenu;