prevent bat from going negative

This commit is contained in:
smayzy 2026-05-03 16:04:32 +02:00
parent 66002a0e1d
commit 45dffd54ad

View File

@ -218,6 +218,7 @@ void calc_data(Tel *t, Bat_state *b, long now) {
b->previous_ms = now; b->previous_ms = now;
b->wh_used += (float)t->power.data * (float)dt / 3600000.0f; b->wh_used += (float)t->power.data * (float)dt / 3600000.0f;
if (b->wh_used > b->wh_total) b->wh_used = b->wh_total;
} }
long now_ms(void) { long now_ms(void) {