??? 07/02/10 15:24 Read: times |
#177064 - Uart user menu via switch/case state machine |
I'm implementing a user menu in my project to show logs, change settings, etc... Currently the user menu is a frequently called task from main in a round robin style multitasking environment. The menu itself is a state machine that either prints or looks for input and then exits.
This user menu function is getting quite large, and the general wisdom is to break up functions larger than (your favorite arbitrary line count here). Each state is a page or less with non-state related actions broken out into functions (user input and validations routines for instance), but the collection of states is growing quickly as more menu items are needed. I have two questions. 1> Is there any value in breaking up a state machine even though it spans multiple pages? It might be a little more "presentable" but adds more overhead in additional state variables and return value checks. 2> Is a state machine the a good way to code multi-level user menus? It was my first inclination, and does work, but if there is a more industry standard way to do such things, I'd like to know. These questions are very implementation-specific I know, so I'm just looking for the best general discussion we can have on this while lacking details. Thanks all! --David |