Added function buttons configuration to menu

This commit is contained in:
Krzysiek Egzmont
2023-10-17 18:29:12 +02:00
parent 4dd2445833
commit 96144af9e9
5 changed files with 109 additions and 20 deletions

View File

@@ -280,7 +280,6 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_S_LIST: case MENU_S_LIST:
*pMin = 0; *pMin = 0;
// *pMax = 1;
*pMax = 2; *pMax = 2;
break; break;
@@ -326,6 +325,14 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
*pMax = 2200; // 2300 *pMax = 2200; // 2300
break; break;
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
*pMin = 0;
*pMax = gSubMenu_SIDEFUNCTIONS_size-1;
break;
default: default:
return -1; return -1;
} }
@@ -745,23 +752,30 @@ void MENU_AcceptSetting(void)
case MENU_BATCAL: case MENU_BATCAL:
{ {
uint16_t buf[4];
gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below 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[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[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value
gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 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[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value
gBatteryCalibration[5] = 2300; gBatteryCalibration[5] = 2300;
EEPROM_WriteBuffer(0x1F40, gBatteryCalibration); SETTINGS_SaveBatteryCalibration(gBatteryCalibration);
return;
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
buf[0] = gBatteryCalibration[4];
buf[1] = gBatteryCalibration[5];
EEPROM_WriteBuffer(0x1F48, buf);
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};
*fun[GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id;
}
break;
} }
gRequestSaveSettings = true; gRequestSaveSettings = true;
@@ -1128,6 +1142,28 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gBatteryCalibration[3]; gSubMenuSelection = gBatteryCalibration[3];
break; 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: default:
return; return;
} }

View File

@@ -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) void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA

View File

@@ -229,6 +229,7 @@ extern EEPROM_Config_t gEeprom;
void SETTINGS_SaveVfoIndices(void); void SETTINGS_SaveVfoIndices(void);
void SETTINGS_SaveSettings(void); void SETTINGS_SaveSettings(void);
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); 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); void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep);
#endif #endif

View File

@@ -66,6 +66,11 @@ const t_menu_item MenuList[] =
{"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S }, {"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S },
#endif #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" {"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"
{"BatSav", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE" {"BatSav", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE"
@@ -185,10 +190,10 @@ const char gSubMenu_TOT[11][7] =
const char* gSubMenu_RXMode[4] = 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 "DUAL RX\nRESPOND", // Watch both and respond
"CROSS\nBAND", // TX on main, RX on secondary "CROSS\nBAND", // TX on main, RX on secondary
"MAIN TX\nDUAL RX" // always TX on main, but RX on both "MAIN TX\nDUAL RX" // always TX on main, but RX on both
}; };
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@@ -248,7 +253,7 @@ const char gSubMenu_PONMSG[4][8] =
"NONE" "NONE"
}; };
const char gSubMenu_ROGER[3][9] = const char* gSubMenu_ROGER[3] =
{ {
"OFF", "OFF",
"ROGER", "ROGER",
@@ -323,6 +328,30 @@ const char gSubMenu_SCRAMBLER[11][7] =
"3500Hz" "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; bool gIsInSubMenu;
uint8_t gMenuCursor; uint8_t gMenuCursor;
int GetCurrentMenuId() { int GetCurrentMenuId() {
@@ -798,6 +827,14 @@ void UI_DisplayMenu(void)
sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection); sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection);
break; break;
} }
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name);
break;
} }
if (!already_printed) if (!already_printed)

View File

@@ -102,9 +102,6 @@ enum
MENU_NOAA_S, MENU_NOAA_S,
#endif #endif
MENU_RESET, MENU_RESET,
// items after here are normally hidden
MENU_F_LOCK, MENU_F_LOCK,
MENU_200TX, MENU_200TX,
MENU_350TX, MENU_350TX,
@@ -116,7 +113,11 @@ enum
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
MENU_F_CALI, // reference xtal calibration MENU_F_CALI, // reference xtal calibration
#endif #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; 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_D_RSP[4][11];
extern const char* gSubMenu_PTT_ID[5]; extern const char* gSubMenu_PTT_ID[5];
extern const char gSubMenu_PONMSG[4][8]; 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_RESET[2][4];
extern const char gSubMenu_F_LOCK[6][4]; extern const char gSubMenu_F_LOCK[6][4];
extern const char gSubMenu_BACKLIGHT[8][7]; extern const char gSubMenu_BACKLIGHT[8][7];
@@ -153,6 +154,10 @@ extern const char gSubMenu_BAT_TXT[3][8];
extern const char gSubMenu_SCRAMBLER[11][7]; 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; extern bool gIsInSubMenu;
extern uint8_t gMenuCursor; extern uint8_t gMenuCursor;