0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Pulled in egzumer's battery percentage !

This commit is contained in:
OneOfEleven
2023-10-01 22:14:45 +01:00
parent 1fc1a102ea
commit a9aa37e043
10 changed files with 62 additions and 20 deletions

View File

@ -752,8 +752,13 @@ void UI_DisplayMain(void)
else
if (gChargingWithTypeC)
{ // charging .. show the battery state
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
//const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
//const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
//sprintf(String, "Charge %u.%02uV %u%%", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, percent);
//UI_PrintStringSmall(String, 2, 0, 3);
const uint16_t percent = BATTERY_VoltsToPercent(gBatteryVoltageAverage);
sprintf(String, "Charge %u.%02uV %u%%", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, percent);
UI_PrintStringSmall(String, 2, 0, 3);
}

View File

@ -734,9 +734,7 @@ void UI_DisplayMenu(void)
{ // 2nd text line .. percentage
UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8);
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
sprintf(String, "%u%%", percent);
sprintf(String, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
UI_PrintString(String, menu_item_x1, menu_item_x2, 3, 8);
#if 0
sprintf(String, "Curr %u", gBatteryCurrent); // needs scaling into mA

View File

@ -169,10 +169,7 @@ void UI_DisplayStatus(const bool test_display)
case 2: // percentage
{
const uint16_t voltage = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t percent = (100 * (voltage - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
// const uint16_t percent = gBatteryDisplayLevel;
sprintf(s, "%u%%", percent);
sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
space_needed = (7 * strlen(s));
if (x2 >= (x1 + space_needed))
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);

View File

@ -65,15 +65,11 @@ void UI_DisplayWelcome(void)
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_VOLTAGE)
{
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v :
(gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v :
gBatteryVoltageAverage;
strcpy(WelcomeString0, "VOLTAGE");
sprintf(WelcomeString1, "%u.%02uV %u%%",
gBatteryVoltageAverage / 100,
gBatteryVoltageAverage % 100,
(100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
#if 0
sprintf(WelcomeString2, "Current %u", gBatteryCurrent); // needs scaling into mA