Update battery percentage calculation so it calculates a percentage
between minimum voltage and maximum voltage instead of 0 and maximum voltage.
This commit is contained in:
parent
d45432ba5d
commit
2461169114
|
@ -112,5 +112,5 @@ void updateCurrentMeter(int32_t lastUpdateAt)
|
|||
|
||||
uint32_t calculateBatteryPercentage(void)
|
||||
{
|
||||
return ((uint32_t)(vbat) * 100) / (batteryConfig->vbatmaxcellvoltage * batteryCellCount);
|
||||
return (((uint32_t)vbat - (batteryConfig->vbatmincellvoltage * batteryCellCount)) * 100) / ((batteryConfig->vbatmaxcellvoltage - batteryConfig->vbatmincellvoltage) * batteryCellCount);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue