Custom menu

Fork of Menu by Peihsun Yeh

Revision:
3:3fceb6ff921e
Parent:
2:2654dc659298
--- a/Navigator.h	Tue Mar 05 21:24:37 2013 +0000
+++ b/Navigator.h	Thu Feb 26 11:57:11 2015 +0000
@@ -4,29 +4,36 @@
 #include "mbed.h"
 #include "Menu.h"
 #include "TextLCD.h"
-#include "RPG.h"
 
-class Navigator {   
-    private: 
-               
+class Navigator {
     public:
-        Navigator(Menu *, RPG &, TextLCD *);
-        Menu *activeMenu; // the current menu - can change when RPG is pushed on selection with child menu
-        RPG rpg;
-        TextLCD *lcd; 
+        Navigator(Menu *root, TextLCD *lcd);
+
+        void printMenu();
         
-        bool lastButton, button;
-        int direction;  // 1 = CW, -1 = CCW
-        
-        int bottom;     // the index of the last item of current menu
-        int cursorPos;  // what selection the cursor points to
-        int cursorLine; // what line of the lcd the cursor is on. 1 = first line, 2 = second line
-        
-        void poll();    // repeatedly call this function to determine if RPG is being used
-        void moveUp();
-        void moveDown();
-        void printMenu();
-        void printCursor();
+        void actionNone();
+        void actionUp();
+        void actionDown();
+        void actionBack();
+        void actionEnter();
+        void actionHome();
+
+    private:
+
+        typedef enum {
+            none, up, down, back, enter, home
+        } Status;
+
+        Menu *root;
+        TextLCD *_lcd;
+
+        /// the current menu can change when RPG is pushed on selection with child menu
+        Menu *activeMenu;
+
+        ///The last action
+        Status _lastAction;
+        ///which selection the cursor points to
+        uint16_t cursorPos;
 };
 
-#endif 
\ No newline at end of file
+#endif