Changed statemachine to only check for transitions if the lockout timer is not running

This commit is contained in:
dario
2023-10-30 17:25:09 +01:00
parent 9f4c772437
commit 4de63ced98

View File

@@ -32,13 +32,15 @@ namespace sta
} }
void Statemachine::func() void Statemachine::func()
{
if (!lockoutTimer_.isRunning())
{ {
uint16_t next = transitionFunc_(currentState_); uint16_t next = transitionFunc_(currentState_);
STA_ASSERT(next < STA_TACOS_NUM_STATES); STA_ASSERT(next < STA_TACOS_NUM_STATES);
// Check if a state change is desired. Block if the lockoutTimer is still running. // Check if a state change is desired. Block if the lockoutTimer is still running.
if (next != currentState_ && !lockoutTimer_.isRunning()) if (next != currentState_)
{ {
if (failsafeTimer_.isRunning()) if (failsafeTimer_.isRunning())
{ {
@@ -53,6 +55,7 @@ namespace sta
Statemachine::stateChangeEvent.set(EventFlags::NORMAL); Statemachine::stateChangeEvent.set(EventFlags::NORMAL);
Statemachine::stateChangeEvent.clear(EventFlags::ALL); Statemachine::stateChangeEvent.clear(EventFlags::ALL);
} }
}
osThreadYield(); osThreadYield();
} }