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

Committer:
shimniok
Date:
2018-11-30
Revision:
25:bb5356402687
Parent:
0:a6a169de725f

File content as of revision 25:bb5356402687:

#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];
};