add waiting for ELM327 before init state

This commit is contained in:
Sem van der Hoeven
2024-01-21 13:59:49 +01:00
parent 3f19ab4b7d
commit 5fbafa3dc9
5 changed files with 29 additions and 10 deletions

View File

@@ -3,6 +3,7 @@
int current_state_id = 0;
state_t states[STATE_AMOUNT] = {NULL, NULL};
__UINT8_TYPE__ next = 0;
static char has_init = 0;
__UINT8_TYPE__ statemachine_register_state(state_t *state, int index)
{
@@ -28,11 +29,17 @@ __UINT8_TYPE__ statemachine_init()
}
}
current_state_id = 0;
states[current_state_id].on_enter();
}
void statemachine_loop()
{
if (has_init == 0)
{
has_init = 1;
states[current_state_id].on_enter();
}
if (states[current_state_id].next == current_state_id)
{
next = 0;