Reset timestamps when leaving their state

This commit is contained in:
Jasper Blanckenburg 2023-03-12 23:01:13 +01:00
parent 838c6195bb
commit 9355595b73
1 changed files with 2 additions and 0 deletions

View File

@ -79,6 +79,7 @@ TSState ts_sm_update_precharge() {
if (precharge_95_reached_timestamp == 0) { if (precharge_95_reached_timestamp == 0) {
precharge_95_reached_timestamp = now; precharge_95_reached_timestamp = now;
} else if (now - precharge_95_reached_timestamp >= PRECHARGE_95_DURATION) { } else if (now - precharge_95_reached_timestamp >= PRECHARGE_95_DURATION) {
precharge_95_reached_timestamp = 0;
return TS_ACTIVE; return TS_ACTIVE;
} }
} }
@ -98,6 +99,7 @@ TSState ts_sm_update_error() {
if (no_error_since == 0) { if (no_error_since == 0) {
no_error_since = now; no_error_since = now;
} else if (now - no_error_since > NO_ERROR_TIME) { } else if (now - no_error_since > NO_ERROR_TIME) {
no_error_since = 0;
return TS_INACTIVE; return TS_INACTIVE;
} }
} }