There are many valid ways to approach state machine code. I did a write up on our system in a post here. Might give you some ideas:
There are many valid ways to approach state machine code. I did a write up on our system in a post here. Might give you some ideas: