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
Navigator.h
- Committer:
- charly
- Date:
- 2015-03-13
- Revision:
- 9:c9df0b33d176
- Parent:
- 8:fbaeab73fe1a
- Child:
- 10:2b6ddf53b05e
File content as of revision 9:c9df0b33d176:
#ifndef NAVIGATOR_H #define NAVIGATOR_H #include "mbed.h" #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 "MenuItem.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 { public: Navigator(Menu *, TextLCD_Base *); Menu *activeMenu; // the current menu - can change when Menue-item is selected on selection with child menu TextLCD_Base *lcd; /** no longer used! * */ 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) 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) or otherwise. */ void moveDown(); /** 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(); /** print the menu on LCD */ void printMenu(); /** 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