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
Diff: Navigator.h
- Revision:
- 5:91b1bc68290b
- Parent:
- 4:67097127da6c
- Child:
- 8:fbaeab73fe1a
--- a/Navigator.h Thu Jan 01 23:00:06 2015 +0000
+++ b/Navigator.h Fri Jan 02 15:41:09 2015 +0000
@@ -5,17 +5,44 @@
#include "Menu.h"
#include "TextLCD.h"
+/** Class Navigator does the Navigation in the menu and updates the display.
+ * Interaction from outside is done by calling moveUp(), moveDown() or select().
+ * Could be done by an RPG or via Buttons.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * #include "Selection.h"
+ * #include "Menu.h"
+ * #include "Navigator.h"
+ * #include <vector>
+ * #include <string>
+ * PinDetect T1 ( p21,PullNone); //Button 1 - UP
+ * PinDetect T2 ( p22,PullNone); //Button 2 - Down
+ * PinDetect T3 ( p23,PullNone); //Button 3 - Select
+ * ...
+ * // Here is the heart of the system: the navigator.
+ * // The navigator takes in a reference to the root and a reference to an lcd
+ * Navigator navigator(&rootMenu, &lcd);
+ *
+ * // attach the methods for buttons Up, Down, Select to the navigator
+ * T1.attach_asserted( &navigator, &Navigator::moveUp);
+ * T2.attach_asserted( &navigator, &Navigator::moveDown);
+ * T3.attach_asserted( &navigator, &Navigator::select);
+ * // do whatever you need to do in your main-loop.
+ * while( 1 ) {
+ * led4 = !led4;
+ * wait( 1 );
+ * }
+ * @endcode
+*/
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
+ Menu *activeMenu; // the current menu - can change when Menue-item is selected on selection with child menu
TextLCD_Base *lcd;
@@ -24,21 +51,21 @@
*/
void poll(); // no longer needed!
- /** Move up one line in menu
- * call this method when user moves up one line
- * can be triggered by RPG or Button (PinDetect)
+ /** Move up one line in menu.
+ * call this method when user moves up one line.
+ * can be triggered by RPG or Button (PinDetect) or otherwise.
*/
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)
+ /** Move down one line in menu.
+ * call this method when user moves down one line.
+ * can be triggered by RPG or Button (PinDetect) or otherwise.
*/
void moveDown();
- /** User presses Select Button
- * call this method when user wans to select an item
- * can be triggered by RPG or Button (PinDetect)
+ /** User presses Select Button.
+ * call this method when user wants to select an item.
+ * can be triggered by RPG or Button (PinDetect) or otherwise.
*/
void select();
@@ -49,6 +76,13 @@
/** print cursor on the beginning of line
*/
void printCursor();
+
+private:
+ int _display_rows; // number of rows the LCD can display
+ 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
+
+
};
#endif
\ No newline at end of file
