diff --git a/helper/battery.c b/helper/battery.c index 7076492..1401d54 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -82,6 +82,7 @@ const uint16_t Voltage2PercentageTable[][7][2] = { static_assert(ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_1600_MAH]) == ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH])); + unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV) { const uint16_t (*crv)[2] = Voltage2PercentageTable[gEeprom.BATTERY_TYPE]; @@ -99,8 +100,7 @@ unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV) } #endif - -void BATTERY_GetReadings(bool bDisplayBatteryLevel) +/*void BATTERY_GetReadings(bool bDisplayBatteryLevel) { uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4; uint8_t PreviousBatteryLevel = gBatteryDisplayLevel; @@ -130,109 +130,8 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel) if (!gLowBattery && bDisplayBatteryLevel) UI_DisplayBattery(gBatteryDisplayLevel); } -} -//////2 -/* -void BATTERY_GetReadings(bool bDisplayBatteryLevel) -{ - uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4; - uint8_t PreviousBatteryLevel = gBatteryDisplayLevel; - - if (Voltage >= gBatteryCalibration[5]) gBatteryDisplayLevel = 6; - else if (Voltage >= gBatteryCalibration[4]) gBatteryDisplayLevel = 5; - else if (Voltage >= gBatteryCalibration[3]) gBatteryDisplayLevel = 4; - else if (Voltage >= gBatteryCalibration[2]) gBatteryDisplayLevel = 3; - else if (Voltage >= gBatteryCalibration[1]) gBatteryDisplayLevel = 2; - else if (Voltage >= gBatteryCalibration[0]) gBatteryDisplayLevel = 1; - else gBatteryDisplayLevel = 0; - - gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; - - if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL) gUpdateDisplay = true; - - if (gBatteryCurrent < 501) { - if (gChargingWithTypeC) { - gUpdateStatus = true; - gChargingWithTypeC = 0; - } - } else { - if (!gChargingWithTypeC) { - gUpdateStatus = true; - BACKLIGHT_TurnOn(); - gChargingWithTypeC = 1; - } - } - - if (PreviousBatteryLevel != gBatteryDisplayLevel) { - gLowBattery = (gBatteryDisplayLevel < 2); - gLowBatteryCountdown = 0; - - if (!gLowBattery && bDisplayBatteryLevel) { - UI_DisplayBattery(gBatteryDisplayLevel); - } - } -} -*/ -////2 -/* -void BATTERY_GetReadings(bool bDisplayBatteryLevel) -{ - uint16_t Voltage; - uint8_t PreviousBatteryLevel; - - PreviousBatteryLevel = gBatteryDisplayLevel; - - Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4; - - if (gBatteryCalibration[5] < Voltage) { - gBatteryDisplayLevel = 6; - } else if (gBatteryCalibration[4] < Voltage) { - gBatteryDisplayLevel = 5; - } else if (gBatteryCalibration[3] < Voltage) { - gBatteryDisplayLevel = 4; - } else if (gBatteryCalibration[2] < Voltage) { - gBatteryDisplayLevel = 3; - } else if (gBatteryCalibration[1] < Voltage) { - gBatteryDisplayLevel = 2; - } else if (gBatteryCalibration[0] < Voltage) { - gBatteryDisplayLevel = 1; - } else { - gBatteryDisplayLevel = 0; - } - - gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; - - if ((gScreenToDisplay == DISPLAY_MENU) && gMenuCursor == MENU_VOL) { - gUpdateDisplay = true; - } - if (gBatteryCurrent < 501) { - if (gChargingWithTypeC) { - gUpdateStatus = true; - } - gChargingWithTypeC = 0; - } else { - if (!gChargingWithTypeC) { - gUpdateStatus = true; - BACKLIGHT_TurnOn(); - } - gChargingWithTypeC = 1; - } +}*/ - if (PreviousBatteryLevel != gBatteryDisplayLevel) { - if (gBatteryDisplayLevel < 2) { - gLowBattery = true; - } else { - gLowBattery = false; - if (bDisplayBatteryLevel) { - UI_DisplayBattery(gBatteryDisplayLevel); - } - } - gLowBatteryCountdown = 0; - } -} -*/ -////1 -/* void BATTERY_GetReadings(bool bDisplayBatteryLevel) { uint8_t PreviousBatteryLevel = gBatteryDisplayLevel; uint16_t Voltage = Mid(gBatteryVoltages, ARRAY_SIZE(gBatteryVoltages)); @@ -242,7 +141,7 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel) { for (int i = ARRAY_SIZE(gBatteryCalibration) - 1; i >= 0; --i) { if (Voltage > gBatteryCalibration[i]) { // old config gBatteryDisplayLevel = i + 1; - gBatteryDisplayLevel = i + 1; + gBatteryDisplayLevel = i + 3/5; break; } } @@ -273,6 +172,4 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel) { } gLowBatteryCountdown = 0; } -} -*/ - +} \ No newline at end of file