Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
UI/Menu/Menu.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | #define _ITEM_MAX 10 |
shimniok | 0:826c6171fc1b | 2 | #define NAMESIZ 20 |
shimniok | 0:826c6171fc1b | 3 | |
shimniok | 0:826c6171fc1b | 4 | typedef int (*FunctionPtr)(); |
shimniok | 0:826c6171fc1b | 5 | |
shimniok | 0:826c6171fc1b | 6 | /** Simple menu interface model |
shimniok | 0:826c6171fc1b | 7 | */ |
shimniok | 0:826c6171fc1b | 8 | class Menu { |
shimniok | 0:826c6171fc1b | 9 | public: |
shimniok | 0:826c6171fc1b | 10 | |
shimniok | 0:826c6171fc1b | 11 | /** Create a new menu model |
shimniok | 0:826c6171fc1b | 12 | */ |
shimniok | 0:826c6171fc1b | 13 | Menu(); |
shimniok | 0:826c6171fc1b | 14 | |
shimniok | 0:826c6171fc1b | 15 | /** add a new menu item |
shimniok | 0:826c6171fc1b | 16 | */ |
shimniok | 0:826c6171fc1b | 17 | void add(char *name, FunctionPtr f); |
shimniok | 0:826c6171fc1b | 18 | |
shimniok | 0:826c6171fc1b | 19 | /** select the next menu item as the current item |
shimniok | 0:826c6171fc1b | 20 | */ |
shimniok | 0:826c6171fc1b | 21 | void next(void); |
shimniok | 0:826c6171fc1b | 22 | |
shimniok | 0:826c6171fc1b | 23 | /** select the previous menu item as the current item |
shimniok | 0:826c6171fc1b | 24 | */ |
shimniok | 0:826c6171fc1b | 25 | void prev(void); |
shimniok | 0:826c6171fc1b | 26 | |
shimniok | 0:826c6171fc1b | 27 | /** run the function associated with the current item |
shimniok | 0:826c6171fc1b | 28 | */ |
shimniok | 0:826c6171fc1b | 29 | void select(void); |
shimniok | 0:826c6171fc1b | 30 | |
shimniok | 0:826c6171fc1b | 31 | /** return the text for the current item |
shimniok | 0:826c6171fc1b | 32 | */ |
shimniok | 0:826c6171fc1b | 33 | char *getItemName(void); |
shimniok | 0:826c6171fc1b | 34 | |
shimniok | 0:826c6171fc1b | 35 | /** return text for a specified item |
shimniok | 0:826c6171fc1b | 36 | */ |
shimniok | 0:826c6171fc1b | 37 | char *getItemName(int i); |
shimniok | 0:826c6171fc1b | 38 | |
shimniok | 0:826c6171fc1b | 39 | /** print all the menu items |
shimniok | 0:826c6171fc1b | 40 | */ |
shimniok | 0:826c6171fc1b | 41 | void printAll(void); |
shimniok | 0:826c6171fc1b | 42 | |
shimniok | 0:826c6171fc1b | 43 | private: |
shimniok | 0:826c6171fc1b | 44 | short _item; |
shimniok | 0:826c6171fc1b | 45 | short _itemCount; |
shimniok | 0:826c6171fc1b | 46 | char _name[_ITEM_MAX][NAMESIZ]; |
shimniok | 0:826c6171fc1b | 47 | FunctionPtr _exec[_ITEM_MAX]; |
shimniok | 0:826c6171fc1b | 48 | }; |
shimniok | 0:826c6171fc1b | 49 |