Made charge tracker get time stamps from data poller instead of internally.

This commit is contained in:
Hendrik van Wyk
2015-02-28 15:46:55 +02:00
parent 70bdaa99eb
commit 0c04eab1c1
2 changed files with 3 additions and 3 deletions

View File

@@ -49,8 +49,8 @@ func NewChargeTracker(fullLevel float64) *ChargeTracker {
}
}
func (c *ChargeTracker) Update(amp float64) {
newNow := time.Now()
func (c *ChargeTracker) Update(amp float64, timestamp time.Time) {
newNow := timestamp
elapsed := newNow.Sub(c.lastUpdate).Hours()
c.lastUpdate = newNow
c.currentLevel -= elapsed * amp

View File

@@ -180,7 +180,7 @@ func (w *WebGui) dataPoll(batteryCapacity float64) {
} else {
statusP.status = s.MpStatus
statusP.err = nil
tracker.Update(s.MpStatus.BatCurrent)
tracker.Update(s.MpStatus.BatCurrent, s.Time)
if s.MpStatus.Leds[Float] == 1 {
tracker.Reset()
}