Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
Diff: UI/Menu/Menu.h
- Revision:
- 0:a6a169de725f
diff -r 000000000000 -r a6a169de725f UI/Menu/Menu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/Menu/Menu.h Mon May 27 13:26:03 2013 +0000 @@ -0,0 +1,49 @@ +#define _ITEM_MAX 10 +#define NAMESIZ 20 + +typedef int (*FunctionPtr)(); + +/** Simple menu interface model + */ +class Menu { +public: + + /** Create a new menu model + */ + Menu(); + + /** add a new menu item + */ + void add(char *name, FunctionPtr f); + + /** select the next menu item as the current item + */ + void next(void); + + /** select the previous menu item as the current item + */ + void prev(void); + + /** run the function associated with the current item + */ + void select(void); + + /** return the text for the current item + */ + char *getItemName(void); + + /** return text for a specified item + */ + char *getItemName(int i); + + /** print all the menu items + */ + void printAll(void); + +private: + short _item; + short _itemCount; + char _name[_ITEM_MAX][NAMESIZ]; + FunctionPtr _exec[_ITEM_MAX]; +}; +