diff --git a/app/menu.c b/app/menu.c index 722a461..aeca884 100644 --- a/app/menu.c +++ b/app/menu.c @@ -290,11 +290,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1; break; - case MENU_VOL: - *pMin = 1760; // 0 - *pMax = 2000; // 2300 - break; - case MENU_BAT_TXT: *pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1; @@ -320,6 +315,11 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) *pMax = +50; break; + case MENU_BATCAL: + *pMin = 1760; // 0 + *pMax = 2000; // 2300 + break; + default: return -1; } @@ -616,11 +616,6 @@ void MENU_AcceptSetting(void) gRequestSaveChannel = 1; return; - case MENU_VOL: - if (gF_LOCK) - EEPROM_WriteBuffer(0x1F40, gBatteryCalibration); - break; - case MENU_BAT_TXT: gSetting_battery_text = gSubMenuSelection; break; @@ -734,6 +729,11 @@ void MENU_AcceptSetting(void) if (gF_LOCK) writeXtalFreqCal(gSubMenuSelection); return; + + case MENU_BATCAL: + gBatteryCalibration[3] = gSubMenuSelection; + EEPROM_WriteBuffer(0x1F40, gBatteryCalibration); + break; } gRequestSaveSettings = true; @@ -1009,10 +1009,6 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gTxVfo->DTMF_PTT_ID_TX_MODE; break; - case MENU_VOL: - gSubMenuSelection = gBatteryCalibration[3]; - return; - case MENU_BAT_TXT: gSubMenuSelection = gSetting_battery_text; return; @@ -1098,6 +1094,13 @@ void MENU_ShowCurrentSetting(void) case MENU_F_CALI: gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW; break; + + case MENU_BATCAL: + gSubMenuSelection = gBatteryCalibration[3]; + break; + + default: + return; } // if (gFlagBackupSetting) @@ -1286,14 +1289,11 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) // *********************** // restore original value - if (gMenuCursor == MENU_VOL) + if (gMenuCursor == MENU_BATCAL) { if (gF_LOCK) { EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 8); - -// gBatteryCalibration[3] = gSubMenuSelection_original; - BATTERY_GetReadings(true); } } diff --git a/firmware.bin b/firmware.bin index 6734d79..005ff71 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 48a816b..8639629 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/main.c b/main.c index 93561e0..9f1c9d6 100644 --- a/main.c +++ b/main.c @@ -112,7 +112,7 @@ void Main(void) if (BootMode == BOOT_MODE_F_LOCK) gF_LOCK = true; // flag to say use the hidden menu items else - gMenuListCount -= 8; // hide the last few menu items + gMenuListCount -= 9; // hide the last few menu items // wait for user to release all butts before moving on if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || diff --git a/ui/menu.c b/ui/menu.c index 56ac599..313d7f6 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -127,7 +127,8 @@ const t_menu_item MenuList[] = {"TX-EN", VOICE_ID_INVALID, MENU_TX_EN }, // enable TX {"F-CALI", VOICE_ID_INVALID, MENU_F_CALI }, // reference xtal calibration - + {"BATCAL", VOICE_ID_INVALID, MENU_BATCAL }, // battery voltage calibration + {"", VOICE_ID_INVALID, 0xff } // end of list - DO NOT delete or move this this }; @@ -770,6 +771,13 @@ void UI_DisplayMenu(void) xtal_Hz / 1000000, xtal_Hz % 1000000); } break; + + case MENU_BATCAL: + { + const uint16_t vol = (uint32_t)gBatteryVoltageAverage * gBatteryCalibration[3] / gSubMenuSelection; + sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection); + break; + } } if (!already_printed) diff --git a/ui/menu.h b/ui/menu.h index e9e1e5d..156c72d 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -113,7 +113,8 @@ enum MENU_SCREN, MENU_TX_EN, // enable TX - MENU_F_CALI // reference xtal calibration + MENU_F_CALI, // reference xtal calibration + MENU_BATCAL // battery voltage calibration }; extern const t_menu_item MenuList[];