I've spent the last weekend learning how finite state machines (FSM) work and how I could implement one. I plan to use one to keep track of the state of a menu system for my bulb-ramper project. After browsing stackoverflow.com and Google, I found that it's actually fairly easy to implement. My code is based off of the code
here. I have a list of possible states (e.g. menu1, menu1_entered, menu2, menu2_entered, ...) and a list of possible actions (e.g. button press, encoder turn, ...). I then create an array that contains the action that should be performed when a certain event has happened and what state to transition to based on the current state.
I also wanted to test SyntaxHighlighter (for any code I post here; 2020 Update: SyntaxHighlighter is now replaced with prism):
int test = 0;
No comments:
Post a Comment