Serial LCD Menu system with buttons instead of RPG. Based on Peihsun Yeh's work

Fork of Menu by Peihsun Yeh

Revision:
3:920157b558db
Parent:
2:2654dc659298
Child:
4:343f2993a66b
--- a/Navigator.cpp	Tue Mar 05 21:24:37 2013 +0000
+++ b/Navigator.cpp	Sun Aug 04 15:18:35 2013 +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, SerialLCD *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) 
 {
     bottom = root->selections.size();
     cursorPos = 0;
@@ -11,37 +11,39 @@
     printMenu();
     printCursor();
 }
-
+DigitalIn pushbutton(p21);
 void Navigator::printMenu()
 { 
-    lcd->cls();
+    lcd->clear();
     if(bottom == 1){ // the current Menu only has one selection
-        lcd->printf("%s\n", activeMenu->selections[0].selText);
+        lcd->printf("Mark", 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("line2", activeMenu->selections[cursorPos-1].selText);
+            lcd->setPosition(0,2);
+            lcd->printf("line22", 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->setPosition(0,2);
+            lcd->printf("%s", activeMenu->selections[cursorPos+1].selText);
         }
     }
 }
 
 void Navigator::printCursor()
 {   
-    if(activeMenu->selections[cursorPos].childMenu == NULL) printf("No child menu\n");
-    else printf("child menu: %s\n", activeMenu->selections[cursorPos].childMenu->menuID);
+    if(activeMenu->selections[cursorPos].childMenu == NULL) printf("Ncm");
+    else printf("child menu: %s", activeMenu->selections[cursorPos].childMenu->menuID);
      
-    lcd->locate(0,0);
+    lcd->setPosition(0,0);
     if(cursorLine == 1){
-        lcd->putc('>');
-        lcd->locate(0,1);
-        lcd->putc(' ');
+        lcd->printf(">");
+        lcd->setPosition(0,1);
+        lcd->printf(" ");
     } else if(cursorLine == 2){
-        lcd->putc(' ');
-        lcd->locate(0,1);
-        lcd->putc('>');
+        lcd->printf(" ");
+        lcd->setPosition(0,1);
+        lcd->printf(">1");
     }
 }
 
@@ -53,7 +55,7 @@
         else if(direction == -1) moveUp();
     }
        
-    if ((button = rpg.pb()) && !lastButton){ //prevents multiple selections when button is held down
+    if ((button == rpg.pb()) && !lastButton){ //prevents multiple selections when button is held down
         wait(0.2);
         if(activeMenu->selections[cursorPos].fun != NULL){
             (activeMenu->selections[cursorPos].fun)();