jonblack / arduino-fsm

Arduino library for implementing a finite state machine.
MIT License
200 stars 97 forks source link

Allow dynamic time transitions #12

Open jonblack opened 8 years ago

jonblack commented 8 years ago

A user left a comment on the blog asking for the ability to set the timed transition interval dynamically. I need a good use case example for this.

Thelmos commented 8 years ago

This feature would be nice in my current project, my FSM stays in a state while playing sounds, I have a timed transition adjusted to longest sound duration that come back to previous state once played. It would be nice the ability to change timed transition timer into on_state() function to the length of the currently played sound.

Can be as easy as passing an interface to set current state properties as an on_state parameter.

Something like:

on_state(current_state){
   ...
   current_state.setTimeout(600);
   ...
}

This way even on_enter() and on_exit() events could be changed on the fly.