Library to display menus on TextLCDs. Interaction with functions Up,Down and Select (Buttons or RPG) Based on menu-library from pyeh9

Fork of Menu by Peihsun Yeh

Library to display menus on TextLCDs. Interaction with functions Up,Down and Select (Buttons or RPG) Based on menu-library from pyeh9

Revision:
3:cfc36b42ae75
Parent:
2:2654dc659298
Child:
4:67097127da6c
diff -r 2654dc659298 -r cfc36b42ae75 Navigator.cpp
--- a/Navigator.cpp	Tue Mar 05 21:24:37 2013 +0000
+++ b/Navigator.cpp	Thu Jan 01 22:27:30 2015 +0000
@@ -1,6 +1,6 @@
 #include "Navigator.h"
 
-Navigator::Navigator(Menu *root, RPG &rpg, TextLCD *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) 
+Navigator::Navigator(Menu *root, /*RPG &rpg,*/ TextLCD_Base *lcd) : activeMenu(root), /*rpg(rpg), */ lcd(lcd) 
 {
     bottom = root->selections.size();
     cursorPos = 0;
@@ -16,14 +16,16 @@
 { 
     lcd->cls();
     if(bottom == 1){ // the current Menu only has one selection
-        lcd->printf("%s\n", activeMenu->selections[0].selText);
+        lcd->printf(" %s", activeMenu->selections[0].selText);
     } else {
         if(cursorLine == 2){ // if we're at the bottom
-            lcd->printf("%s\n", activeMenu->selections[cursorPos-1].selText);
-            lcd->printf("%s\n", activeMenu->selections[cursorPos].selText);
+            lcd->printf(" %s", activeMenu->selections[cursorPos-1].selText);
+            lcd->locate(0,1);
+            lcd->printf(" %s", activeMenu->selections[cursorPos].selText);
         } else {
-            lcd->printf("%s\n", activeMenu->selections[cursorPos].selText);
-            lcd->printf("%s\n", activeMenu->selections[cursorPos+1].selText);
+            lcd->printf(" %s", activeMenu->selections[cursorPos].selText);
+            lcd->locate(0,1);
+            lcd->printf(" %s", activeMenu->selections[cursorPos+1].selText);
         }
     }
 }
@@ -47,6 +49,7 @@
 
 void Navigator::poll()
 {
+/*    
     if((direction = rpg.dir())!=0){ //Get Dir
         wait(0.2); 
         if(direction == 1) moveDown();
@@ -68,8 +71,23 @@
         }
     }
     lastButton = button;
+*/    
 }
 
+void Navigator::select()
+{
+        if(activeMenu->selections[cursorPos].fun != NULL){
+            (activeMenu->selections[cursorPos].fun)();
+        }
+        if(activeMenu->selections[cursorPos].childMenu != NULL){
+            activeMenu = activeMenu->selections[cursorPos].childMenu;
+            bottom = activeMenu->selections.size();
+            cursorPos = 0;
+            cursorLine = 1;
+            printMenu();
+            printCursor();
+        }
+}
 void Navigator::moveUp()
 {
     if(cursorLine == 1){