Skip to content

Commit 1a1c2c9

Browse files
committed
Generalize iRemaining & iRunTimeToEmpty calculations to also support iFullChargeCapacity other than 100.
1 parent cef7b0d commit 1a1c2c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/UPS/UPS.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ void loop() {
106106
bool bDischarging = !bCharging; // TODO - replace with sensor
107107
int iBattSoc = analogRead(BATTSOCPIN); // TODO - this is for debug only. Replace with charge estimation
108108

109-
iRemaining = (byte)(round((float)100*iBattSoc/1024));
110-
iRunTimeToEmpty = (uint16_t)round((float)iAvgTimeToEmpty*iRemaining/100);
111-
109+
iRemaining = (byte)(round((float)iFullChargeCapacity*iBattSoc/1024));
110+
iRunTimeToEmpty = (uint16_t)round((float)iAvgTimeToEmpty*iRemaining/iFullChargeCapacity);
111+
112112
// Charging
113113
iPresentStatus.Charging = bCharging;
114114
iPresentStatus.ACPresent = bACPresent;

0 commit comments

Comments
 (0)