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
Library to display menus on TextLCDs. Interaction with functions Up,Down and Select (Buttons or RPG) Based on menu-library from pyeh9
Revision 4:67097127da6c, committed 2015-01-01
- Comitter:
- charly
- Date:
- Thu Jan 01 23:00:06 2015 +0000
- Parent:
- 3:cfc36b42ae75
- Child:
- 5:91b1bc68290b
- Commit message:
- removed old code for poll method
Changed in this revision
| Navigator.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Navigator.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Navigator.cpp Thu Jan 01 22:27:30 2015 +0000
+++ b/Navigator.cpp Thu Jan 01 23:00:06 2015 +0000
@@ -1,12 +1,10 @@
#include "Navigator.h"
-Navigator::Navigator(Menu *root, /*RPG &rpg,*/ TextLCD_Base *lcd) : activeMenu(root), /*rpg(rpg), */ lcd(lcd)
+Navigator::Navigator(Menu *root, TextLCD_Base *lcd) : activeMenu(root), lcd(lcd)
{
bottom = root->selections.size();
cursorPos = 0;
cursorLine = 1;
- button = 0;
- lastButton = 0;
printMenu();
printCursor();
@@ -49,29 +47,7 @@
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;
-*/
+ // no longer needed
}
void Navigator::select()
--- a/Navigator.h Thu Jan 01 22:27:30 2015 +0000
+++ b/Navigator.h Thu Jan 01 23:00:06 2015 +0000
@@ -4,30 +4,51 @@
#include "mbed.h"
#include "Menu.h"
#include "TextLCD.h"
-//#include "RPG.h"
+
+class Navigator
+{
+private:
+
+ 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
+
+public:
+ Navigator(Menu *, TextLCD_Base *);
+ Menu *activeMenu; // the current menu - can change when RPG is pushed on selection with child menu
+
+ TextLCD_Base *lcd;
+
+ /** no longer used!
+ *
+ */
+ void poll(); // no longer needed!
-class Navigator {
- private:
-
- public:
- Navigator(Menu *, /*RPG &,*/ TextLCD_Base *);
- Menu *activeMenu; // the current menu - can change when RPG is pushed on selection with child menu
-// RPG rpg;
- TextLCD_Base *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 select();
- void printMenu();
- void printCursor();
+ /** Move up one line in menu
+ * call this method when user moves up one line
+ * can be triggered by RPG or Button (PinDetect)
+ */
+ void moveUp();
+
+ /** Move down one line in menu
+ * call this method when user moves down one line
+ * can be triggered by RPG or Button (PinDetect)
+ */
+ void moveDown();
+
+ /** User presses Select Button
+ * call this method when user wans to select an item
+ * can be triggered by RPG or Button (PinDetect)
+ */
+ void select();
+
+ /** print the menu on LCD
+ */
+ void printMenu();
+
+ /** print cursor on the beginning of line
+ */
+ void printCursor();
};
-#endif
\ No newline at end of file
+#endif
\ No newline at end of file
