From 9355595b73e35de55fec661f7126bb3357ac74f7 Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Sun, 12 Mar 2023 23:01:13 +0100 Subject: [PATCH] Reset timestamps when leaving their state --- Core/Src/ts_state_machine.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/Src/ts_state_machine.c b/Core/Src/ts_state_machine.c index d885519..66fbc3b 100644 --- a/Core/Src/ts_state_machine.c +++ b/Core/Src/ts_state_machine.c @@ -79,6 +79,7 @@ TSState ts_sm_update_precharge() { if (precharge_95_reached_timestamp == 0) { precharge_95_reached_timestamp = now; } else if (now - precharge_95_reached_timestamp >= PRECHARGE_95_DURATION) { + precharge_95_reached_timestamp = 0; return TS_ACTIVE; } } @@ -98,6 +99,7 @@ TSState ts_sm_update_error() { if (no_error_since == 0) { no_error_since = now; } else if (now - no_error_since > NO_ERROR_TIME) { + no_error_since = 0; return TS_INACTIVE; } }