mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-16 04:31:04 +00:00
use duetimer and fix bug where if the next state is the same the exit function would still get called
This commit is contained in:
@@ -33,6 +33,11 @@ __UINT8_TYPE__ statemachine_init()
|
||||
|
||||
void statemachine_loop()
|
||||
{
|
||||
if (states[current_state_id].next == current_state_id)
|
||||
{
|
||||
next = 0;
|
||||
}
|
||||
|
||||
if (next)
|
||||
{
|
||||
next = 0;
|
||||
@@ -41,13 +46,13 @@ void statemachine_loop()
|
||||
{
|
||||
states[current_state_id].on_exit();
|
||||
}
|
||||
if (states[current_state_id].next >= 0 && states[current_state_id].next != current_state_id)
|
||||
if (states[current_state_id].next >= 0)
|
||||
{
|
||||
current_state_id = states[current_state_id].next;
|
||||
}
|
||||
states[current_state_id].on_enter();
|
||||
}
|
||||
|
||||
|
||||
if (states[current_state_id].on_run != NULL)
|
||||
{
|
||||
states[current_state_id].on_run();
|
||||
|
||||
Reference in New Issue
Block a user