You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include"Fsm.h"
#defineSTATE_1_TO_2_EVENT1
#defineSTATE_2_TO_1_EVENT2voidon_state_1_on_enter()
{
Serial.println("Entering State 1");
}
voidon_state_1_in_state()
{
Serial.println("State 1");
}
voidon_state_1_on_exit()
{
Serial.println("Exiting State 1");
}
voidon_state_2_on_enter()
{
Serial.println("Entering State 2");
}
voidon_state_2_in_state()
{
Serial.println("State 2");
}
voidon_state_2_on_exit()
{
Serial.println("Exiting State 2");
}
State state_1(&on_state_1_on_enter, &on_state_1_in_state, &on_state_1_on_exit);
State state_2(&on_state_2_on_enter, &on_state_2_in_state, &on_state_2_on_exit);
Fsm fsm(&state_1);
voidon_trans_1_to_2() {
Serial.println("State 1 -> State 2");
}
voidon_trans_2_to_1() {
Serial.println("State 2 -> State 1");
}
// standard arduino functionsvoidsetup()
{
Serial.begin(9600);
fsm.add_transition(&state_1, &state_2,
STATE_1_TO_2_EVENT,
&on_trans_1_to_2);
fsm.add_transition(&state_2, &state_1,
STATE_2_TO_1_EVENT,
&on_trans_2_to_1);
fsm.run_machine();
}
voidloop()
{
delay(2000);
fsm.trigger(STATE_1_TO_2_EVENT);
delay(2000);
fsm.trigger(STATE_2_TO_1_EVENT);
}
If I run the example the serial console output is as follows:
Entering State 1
State 1
Exiting State 1
State 1 -> State 2
Entering State 2
Exiting State 2
State 2 -> State 1
Entering State 1
Exiting State 1
State 1 -> State 2
Entering State 2
Exiting State 2
(...)
The "in state" callback function for state 1 on_state_1_in_state() is executed only once, implicitly as part of Fsm fsm(&state_1);. The callback function for state 2 on_state_2_in_state() is not executed at all. Have I not used the API correctly?
The text was updated successfully, but these errors were encountered:
I've created the following example.
If I run the example the serial console output is as follows:
The "in state" callback function for state 1
on_state_1_in_state()
is executed only once, implicitly as part ofFsm fsm(&state_1);
. The callback function for state 2on_state_2_in_state()
is not executed at all. Have I not used the API correctly?The text was updated successfully, but these errors were encountered: