menu v1

Fork of Menu by Peihsun Yeh

Revision:
3:3cdd377f5899
Parent:
2:2654dc659298
--- a/Navigator.cpp	Tue Mar 05 21:24:37 2013 +0000
+++ b/Navigator.cpp	Wed May 13 11:40:22 2015 +0000
@@ -1,6 +1,10 @@
 #include "Navigator.h"
+#include "SMARTGPU.h"
+ //
+ #include <stdio.h>
+#include <iostream>
 
-Navigator::Navigator(Menu *root, RPG &rpg, TextLCD *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) 
+Navigator::Navigator(Menu *root, RPG &rpg, SMARTGPU *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) 
 {
     bottom = root->selections.size();
     cursorPos = 0;
@@ -14,46 +18,78 @@
 
 void Navigator::printMenu()
 { 
-    lcd->cls();
+   lcd->erase();
+
     if(bottom == 1){ // the current Menu only has one selection
-        lcd->printf("%s\n", activeMenu->selections[0].selText);
+        //lcd->printf("%s\n", activeMenu->selections[0].selText);
+        //activeMenu->selections[0].selText;
+        lcd->string(70,10,300,220,YELLOW,FONT4,TRANS,activeMenu->selections[0].selText);  //write a string on the screen
     } 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);
-        } else {
-            lcd->printf("%s\n", activeMenu->selections[cursorPos].selText);
-            lcd->printf("%s\n", activeMenu->selections[cursorPos+1].selText);
-        }
+       // if(cursorLine == 4){ // if we're at the bottom
+           // lcd->printf("%s\n", activeMenu->selections[cursorPos-1].selText);
+          lcd->string(5,5,300,220,WHITE,FONT6,TRANS,activeMenu->selections[4].selText);  //write a string on the screen
+            lcd->string(30,40,300,220,WHITE,FONT6,TRANS,(activeMenu->selections[0].selText));  //write a string on the screen
+             lcd->string(30,80,300,220,WHITE,FONT6,TRANS,activeMenu->selections[1].selText);  //write a string on the screen
+            lcd->string(30,120,300,220,WHITE,FONT6,TRANS,(activeMenu->selections[2].selText));  //write a string on the screen
+            lcd->string(30,160,300,220,WHITE,FONT6,TRANS,activeMenu->selections[3].selText);  //write a string on the screen
+            
+      //  } else {
+           
+           // lcd->string(30,30,300,220,WHITE,FONT6,TRANS,activeMenu->selections[0].selText);  //write a string on the screen
+           //  lcd->string(30,70,300,220,WHITE,FONT6,TRANS,activeMenu->selections[1].selText);  //write a string on the screen
+           //  lcd->string(30,110,300,220,WHITE,FONT6,TRANS,(activeMenu->selections[2].selText));  //write a string on the screen
+            // lcd->string(30,150,300,220,WHITE,FONT6,TRANS,activeMenu->selections[3].selText);  //write a string on the screen
+        //}
     }
 }
 
 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("No child menu\n");
+        lcd->string(10,200,300,220,WHITE,FONT2,TRANS,"_      ");  //write a string on the screen
+        
+    else 
+        lcd->string(10,200,300,220,WHITE,FONT2,TRANS, activeMenu->selections[cursorPos].childMenu->menuID);  //write a string on the screen
+     
+        //printf("child menu: %s\n", activeMenu->selections[cursorPos].childMenu->menuID);
      
-    lcd->locate(0,0);
-    if(cursorLine == 1){
-        lcd->putc('>');
-        lcd->locate(0,1);
-        lcd->putc(' ');
-    } else if(cursorLine == 2){
-        lcd->putc(' ');
-        lcd->locate(0,1);
-        lcd->putc('>');
+ //   lcd->locate(0,0); cursorPos  cursorLine
+    if(cursorPos == 0){
+        lcd->string(15,40,300,220,WHITE,FONT6,TRANS,">"); 
+        lcd->string(15,80,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,120,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,160,300,220,WHITE,FONT6,TRANS," "); 
+    } else if(cursorPos == 1){
+        lcd->string(15,40,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,80,300,220,WHITE,FONT6,TRANS,">"); 
+        lcd->string(15,120,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,160,300,220,WHITE,FONT6,TRANS," "); 
+    } else if(cursorPos == 2){
+        lcd->string(15,40,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,80,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,120,300,220,WHITE,FONT6,TRANS,">"); 
+        lcd->string(15,160,300,220,WHITE,FONT6,TRANS," "); 
+    } else if(cursorPos == 3){
+        lcd->string(15,40,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,80,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,120,300,220,WHITE,FONT6,TRANS," "); 
+        lcd->string(15,160,300,220,WHITE,FONT6,TRANS,">"); 
     }
 }
 
 void Navigator::poll()
 {
+ 
     if((direction = rpg.dir())!=0){ //Get Dir
         wait(0.2); 
         if(direction == 1) moveDown();
         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)();
@@ -74,7 +110,7 @@
 {
     if(cursorLine == 1){
         printMenu();
-    } else if(cursorLine == 2){
+    } else if(cursorLine == 5){
         cursorLine = 1;
     }
     
@@ -88,8 +124,8 @@
 void Navigator::moveDown()
 {
     if(cursorLine == 1){
-        cursorLine = 2;
-    } else if(cursorLine == 2){
+        cursorLine = 5;
+    } else if(cursorLine == 5){
         printMenu();
     }