I've created a new arduino library called arduino-fsm for implementing a finite state machine1
. It's similar to this library2
; however, the user triggers a transition by sending an event, allowing the client to remove the need for complex switch statements in their code. This is really an implementation of the State design pattern, using callbacks instead of inheritence.
The code is available on github: https://github.com/jonblack/arduino-fsm
See the example code for a guide on using it. I'll follow up with a blog post soon. It's worth noting the following callbacks:
* on_enter (when a state is entered)
* on_exit (when a state is exited)
* on_transition (when transitioning from one state to another)
Each callback is optional.
Questions? Post here. Clear bugs? See the github issue tracker.