![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
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
UI/Menu/Menu.h@0:a6a169de725f, 2013-05-27 (annotated)
- Committer:
- shimniok
- Date:
- Mon May 27 13:26:03 2013 +0000
- Revision:
- 0:a6a169de725f
Working version with priorities set and update time display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | #define _ITEM_MAX 10 |
shimniok | 0:a6a169de725f | 2 | #define NAMESIZ 20 |
shimniok | 0:a6a169de725f | 3 | |
shimniok | 0:a6a169de725f | 4 | typedef int (*FunctionPtr)(); |
shimniok | 0:a6a169de725f | 5 | |
shimniok | 0:a6a169de725f | 6 | /** Simple menu interface model |
shimniok | 0:a6a169de725f | 7 | */ |
shimniok | 0:a6a169de725f | 8 | class Menu { |
shimniok | 0:a6a169de725f | 9 | public: |
shimniok | 0:a6a169de725f | 10 | |
shimniok | 0:a6a169de725f | 11 | /** Create a new menu model |
shimniok | 0:a6a169de725f | 12 | */ |
shimniok | 0:a6a169de725f | 13 | Menu(); |
shimniok | 0:a6a169de725f | 14 | |
shimniok | 0:a6a169de725f | 15 | /** add a new menu item |
shimniok | 0:a6a169de725f | 16 | */ |
shimniok | 0:a6a169de725f | 17 | void add(char *name, FunctionPtr f); |
shimniok | 0:a6a169de725f | 18 | |
shimniok | 0:a6a169de725f | 19 | /** select the next menu item as the current item |
shimniok | 0:a6a169de725f | 20 | */ |
shimniok | 0:a6a169de725f | 21 | void next(void); |
shimniok | 0:a6a169de725f | 22 | |
shimniok | 0:a6a169de725f | 23 | /** select the previous menu item as the current item |
shimniok | 0:a6a169de725f | 24 | */ |
shimniok | 0:a6a169de725f | 25 | void prev(void); |
shimniok | 0:a6a169de725f | 26 | |
shimniok | 0:a6a169de725f | 27 | /** run the function associated with the current item |
shimniok | 0:a6a169de725f | 28 | */ |
shimniok | 0:a6a169de725f | 29 | void select(void); |
shimniok | 0:a6a169de725f | 30 | |
shimniok | 0:a6a169de725f | 31 | /** return the text for the current item |
shimniok | 0:a6a169de725f | 32 | */ |
shimniok | 0:a6a169de725f | 33 | char *getItemName(void); |
shimniok | 0:a6a169de725f | 34 | |
shimniok | 0:a6a169de725f | 35 | /** return text for a specified item |
shimniok | 0:a6a169de725f | 36 | */ |
shimniok | 0:a6a169de725f | 37 | char *getItemName(int i); |
shimniok | 0:a6a169de725f | 38 | |
shimniok | 0:a6a169de725f | 39 | /** print all the menu items |
shimniok | 0:a6a169de725f | 40 | */ |
shimniok | 0:a6a169de725f | 41 | void printAll(void); |
shimniok | 0:a6a169de725f | 42 | |
shimniok | 0:a6a169de725f | 43 | private: |
shimniok | 0:a6a169de725f | 44 | short _item; |
shimniok | 0:a6a169de725f | 45 | short _itemCount; |
shimniok | 0:a6a169de725f | 46 | char _name[_ITEM_MAX][NAMESIZ]; |
shimniok | 0:a6a169de725f | 47 | FunctionPtr _exec[_ITEM_MAX]; |
shimniok | 0:a6a169de725f | 48 | }; |
shimniok | 0:a6a169de725f | 49 |