diff --git a/src/main.c b/src/main.c index ccd2971..943775a 100644 --- a/src/main.c +++ b/src/main.c @@ -175,6 +175,8 @@ void calc_data(Tel *t, Bat_state *b, long now) { } long dt = now - b->previous_ms; + if (dt < 0) dt = 0; + b->previous_ms = now; b->wh_used += (float)t->power.data * (float)dt / 3600000.0f; }