user config

Fork of Menu by Peihsun Yeh

required for StormXalike

Files at this revision

API Documentation at this revision

Comitter:
rakware
Date:
Thu Mar 05 17:38:35 2015 +0000
Parent:
2:2654dc659298
Commit message:
user config

Changed in this revision

Navigator.cpp Show diff for this revision Revisions of this file
Navigator.cpp.txt Show annotated file Show diff for this revision Revisions of this file
Navigator.h Show diff for this revision Revisions of this file
Navigator.h.txt Show annotated file Show diff for this revision Revisions of this file
diff -r 2654dc659298 -r 742c6553f5f7 Navigator.cpp
--- a/Navigator.cpp	Tue Mar 05 21:24:37 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-#include "Navigator.h"
-
-Navigator::Navigator(Menu *root, RPG &rpg, TextLCD *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) 
-{
-    bottom = root->selections.size();
-    cursorPos = 0;
-    cursorLine = 1;
-    button = 0;
-    lastButton = 0;
-    
-    printMenu();
-    printCursor();
-}
-
-void Navigator::printMenu()
-{ 
-    lcd->cls();
-    if(bottom == 1){ // the current Menu only has one selection
-        lcd->printf("%s\n", 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);
-        } else {
-            lcd->printf("%s\n", activeMenu->selections[cursorPos].selText);
-            lcd->printf("%s\n", 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);
-     
-    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('>');
-    }
-}
-
-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
-        wait(0.2);
-        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();
-        }
-    }
-    lastButton = button;
-}
-
-void Navigator::moveUp()
-{
-    if(cursorLine == 1){
-        printMenu();
-    } else if(cursorLine == 2){
-        cursorLine = 1;
-    }
-    
-    if(cursorPos != 0){
-        cursorPos--;
-        printMenu();
-    }
-    printCursor();
-}
-
-void Navigator::moveDown()
-{
-    if(cursorLine == 1){
-        cursorLine = 2;
-    } else if(cursorLine == 2){
-        printMenu();
-    }
-    
-    if(cursorPos != (bottom-1)){
-        cursorPos++;
-        printMenu();
-    }
-    printCursor();
-}
\ No newline at end of file
diff -r 2654dc659298 -r 742c6553f5f7 Navigator.cpp.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Navigator.cpp.txt	Thu Mar 05 17:38:35 2015 +0000
@@ -0,0 +1,101 @@
+#include "Navigator.h"
+
+Navigator::Navigator(Menu *root, RPG &rpg, TextLCD *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) 
+{
+    bottom = root->selections.size();
+    cursorPos = 0;
+    cursorLine = 1;
+    button = 0;
+    lastButton = 0;
+    
+    printMenu();
+    printCursor();
+}
+
+void Navigator::printMenu()
+{ 
+    lcd->cls();
+    if(bottom == 1){ // the current Menu only has one selection
+        lcd->printf("%s\n", 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);
+        } else {
+            lcd->printf("%s\n", activeMenu->selections[cursorPos].selText);
+            lcd->printf("%s\n", 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);
+     
+    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('>');
+    }
+}
+
+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
+        wait(0.2);
+        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();
+        }
+    }
+    lastButton = button;
+}
+
+void Navigator::moveUp()
+{
+    if(cursorLine == 1){
+        printMenu();
+    } else if(cursorLine == 2){
+        cursorLine = 1;
+    }
+    
+    if(cursorPos != 0){
+        cursorPos--;
+        printMenu();
+    }
+    printCursor();
+}
+
+void Navigator::moveDown()
+{
+    if(cursorLine == 1){
+        cursorLine = 2;
+    } else if(cursorLine == 2){
+        printMenu();
+    }
+    
+    if(cursorPos != (bottom-1)){
+        cursorPos++;
+        printMenu();
+    }
+    printCursor();
+}
\ No newline at end of file
diff -r 2654dc659298 -r 742c6553f5f7 Navigator.h
--- a/Navigator.h	Tue Mar 05 21:24:37 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#ifndef NAVIGATOR_H
-#define NAVIGATOR_H
-
-#include "mbed.h"
-#include "Menu.h"
-#include "TextLCD.h"
-#include "RPG.h"
-
-class Navigator {   
-    private: 
-               
-    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; 
-        
-        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();
-};
-
-#endif 
\ No newline at end of file
diff -r 2654dc659298 -r 742c6553f5f7 Navigator.h.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Navigator.h.txt	Thu Mar 05 17:38:35 2015 +0000
@@ -0,0 +1,32 @@
+#ifndef NAVIGATOR_H
+#define NAVIGATOR_H
+
+#include "mbed.h"
+#include "Menu.h"
+#include "TextLCD.h"
+#include "RPG.h"
+
+class Navigator {   
+    private: 
+               
+    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; 
+        
+        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();
+};
+
+#endif 
\ No newline at end of file