0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 14:21:25 +03:00

Updated menu battery cal from egzumer

This commit is contained in:
OneOfEleven 2023-10-02 01:09:35 +01:00
parent 4333fdeb3a
commit aea80cb046
6 changed files with 30 additions and 21 deletions

View File

@ -290,11 +290,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
*pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1; *pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1;
break; break;
case MENU_VOL:
*pMin = 1760; // 0
*pMax = 2000; // 2300
break;
case MENU_BAT_TXT: case MENU_BAT_TXT:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1; *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; *pMax = +50;
break; break;
case MENU_BATCAL:
*pMin = 1760; // 0
*pMax = 2000; // 2300
break;
default: default:
return -1; return -1;
} }
@ -616,11 +616,6 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
case MENU_VOL:
if (gF_LOCK)
EEPROM_WriteBuffer(0x1F40, gBatteryCalibration);
break;
case MENU_BAT_TXT: case MENU_BAT_TXT:
gSetting_battery_text = gSubMenuSelection; gSetting_battery_text = gSubMenuSelection;
break; break;
@ -734,6 +729,11 @@ void MENU_AcceptSetting(void)
if (gF_LOCK) if (gF_LOCK)
writeXtalFreqCal(gSubMenuSelection); writeXtalFreqCal(gSubMenuSelection);
return; return;
case MENU_BATCAL:
gBatteryCalibration[3] = gSubMenuSelection;
EEPROM_WriteBuffer(0x1F40, gBatteryCalibration);
break;
} }
gRequestSaveSettings = true; gRequestSaveSettings = true;
@ -1009,10 +1009,6 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gTxVfo->DTMF_PTT_ID_TX_MODE; gSubMenuSelection = gTxVfo->DTMF_PTT_ID_TX_MODE;
break; break;
case MENU_VOL:
gSubMenuSelection = gBatteryCalibration[3];
return;
case MENU_BAT_TXT: case MENU_BAT_TXT:
gSubMenuSelection = gSetting_battery_text; gSubMenuSelection = gSetting_battery_text;
return; return;
@ -1098,6 +1094,13 @@ void MENU_ShowCurrentSetting(void)
case MENU_F_CALI: case MENU_F_CALI:
gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW; gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW;
break; break;
case MENU_BATCAL:
gSubMenuSelection = gBatteryCalibration[3];
break;
default:
return;
} }
// if (gFlagBackupSetting) // if (gFlagBackupSetting)
@ -1286,14 +1289,11 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
// *********************** // ***********************
// restore original value // restore original value
if (gMenuCursor == MENU_VOL) if (gMenuCursor == MENU_BATCAL)
{ {
if (gF_LOCK) if (gF_LOCK)
{ {
EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 8); EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 8);
// gBatteryCalibration[3] = gSubMenuSelection_original;
BATTERY_GetReadings(true); BATTERY_GetReadings(true);
} }
} }

Binary file not shown.

Binary file not shown.

2
main.c
View File

@ -112,7 +112,7 @@ void Main(void)
if (BootMode == BOOT_MODE_F_LOCK) if (BootMode == BOOT_MODE_F_LOCK)
gF_LOCK = true; // flag to say use the hidden menu items gF_LOCK = true; // flag to say use the hidden menu items
else 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 // wait for user to release all butts before moving on
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||

View File

@ -127,6 +127,7 @@ const t_menu_item MenuList[] =
{"TX-EN", VOICE_ID_INVALID, MENU_TX_EN }, // enable TX {"TX-EN", VOICE_ID_INVALID, MENU_TX_EN }, // enable TX
{"F-CALI", VOICE_ID_INVALID, MENU_F_CALI }, // reference xtal calibration {"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 {"", 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); xtal_Hz / 1000000, xtal_Hz % 1000000);
} }
break; 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) if (!already_printed)

View File

@ -113,7 +113,8 @@ enum
MENU_SCREN, MENU_SCREN,
MENU_TX_EN, // enable TX 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[]; extern const t_menu_item MenuList[];