We have a small project here and I decided to take the opportunity to teach
one of my employees a little more about microcontrollers so we're actually
using an Arduino for the task. I needed a good state machine
implementation and discovered that the QP framework has been ported to
Arduino (there was already a nice AVR port). State machines are incredibly
useful for anyone wanting to do anything 'serious' (or even no-so-serious)
with uCs, and I know the Arduino is the go-to platform for a lot of
hobbyists, so if anyone in the group hasn't had the opportunity to play
around with them I'd recommend taking a look at QP. It's open-source, runs
on just about any platform under the sun (including DOS of all things), and
can has versions for both C and C++. The online documentation is a bit
sparse - and even confusing - but there is a decent companion book ("Practical
UML Statecharts in C/C++, Second
Edition<http://www.state-machine.com/doxygen/qpcpp/index.html#PSiCC2>")
that is available on Safari Online so if you have a membership you can read
it for free. As a bonus, the book covers UML state machine concepts in
detail. And no, I'm not affiliated in any way with the QP project :)
The QP website is: http://www.state-machine.com/index.php
The Arduino port can be found here: http://arduino.cc/playground/Code/QP
There is another FSM implementation on the Arduino Playground there, but
unfortunately it hasn't been updated for v1.0 of the Arduino environment.
It is much simpler than QP, but QP is a much more robust implementation
which supports both FSMs (Finite State Machines) and HSMs (Hierarchical
State Machines). Also, I should mention that QP includes a little
preemptive kernel for multitasking.
Enjoy!
-N
P.S. If none of you have heard of Safari Books, it is awesome. I wonder
if they would be open to providing a group membership for CGW?