Skip to content

Commit 6f6442f

Browse files
authored
Merge pull request #30 from forderud/remaining-scale
Generalize iRemaining & iRunTimeToEmpty calculations to support capacities != 100
2 parents cef7b0d + 1a1c2c9 commit 6f6442f

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)