Skip to content

Execute root action #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MenuEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
*/


#include <arduino.h>
#include <Arduino.h>
#include "MenuEntry.h"
#include "MenuManager.h"

Expand Down
2 changes: 1 addition & 1 deletion MenuEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
*/


#include <arduino.h>
#include <Arduino.h>

#ifndef MenuEntry_h
#define MenuEntry_h 1
Expand Down
6 changes: 3 additions & 3 deletions MenuLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <arduino.h>
#include <Arduino.h>
#include <LiquidCrystal.h>
#include "MenuLCD.h"

Expand Down Expand Up @@ -49,11 +49,11 @@ bool MenuLCD::PrintMenu( char* pString[], int nLines, int nSelectedLine = 0 )
if( i == nSelectedLine )
{//this line should be surrounded by []
m_pLCD->setCursor(0, i);
m_pLCD->write( '[');
m_pLCD->write( '>');
m_pLCD->setCursor(1,i);
m_pLCD->print( pString[i] );
m_pLCD->setCursor(m_characters - 1, i);
m_pLCD->write( ']');
//m_pLCD->write( ']');
}
else
{
Expand Down
19 changes: 18 additions & 1 deletion MenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ MenuManager::MenuManager(MenuLCD* pMenuLCD)
{
}

// new Constructor which allows us to define in class if we want actions being executed
// on menus which have a child - or not.
MenuManager::MenuManager(MenuLCD* pMenuLCD, bool execRootAction ): m_pMenuLCD( pMenuLCD), m_fDoingIntInput( false ) {
m_execRootMenuAction = execRootAction ;
}



bool MenuManager::addMenuRoot( MenuEntry * p_menuItem)
{
m_pRootMenuEntry = p_menuItem;
Expand Down Expand Up @@ -178,7 +186,16 @@ void MenuManager::MenuDown()
}

void MenuManager::MenuSelect()
{
{

//
// EDIT: Changed library to always do a callback even if the
// menu has a child. This allows me to keep track of the menu we are in.
//
if ( m_execRootMenuAction == true) {
m_pCurrentMenuEntry->ExecuteCallback();
}

MenuEntry *child = m_pCurrentMenuEntry->getChild();
if( child != NULL )
{
Expand Down
8 changes: 6 additions & 2 deletions MenuManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ enum MENU_ACTION { MENU_ACTION_UP, MENU_ACTION_DOWN, MENU_ACTION_SELECT, MENU_AC
class MenuManager
{
public:
MenuManager(MenuLCD* pMenuLCD);
MenuManager(MenuLCD* pMenuLCD);
MenuManager(MenuLCD* pMenuLCD, bool rootAction);

bool addMenuRoot( MenuEntry * p_menuEntry);
MenuEntry * getMenuRoot();
void DrawMenu();
Expand All @@ -54,7 +56,9 @@ class MenuManager
unsigned int m_fDoingIntInput;
MenuIntHelper *m_pMenuIntHelper;
int m_iIntLine;
int *m_pInt;
int *m_pInt;
bool m_execRootMenuAction;

};


Expand Down
16 changes: 14 additions & 2 deletions readme → README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
Adruino_LCD_MENU README
# Adruino_LCD_MENU README

By David Andrews - May 6, 2012
Original library: By David Andrews - May 6, 2012

Modified by Tweep, February 2017

License: Modified BSD (See complete license at end)

Purpose: To shorten the time to get an Adriuno project running using a menuing system.


Changes :
- new constructor added which allows to enable / disable the execution of callback functions when the root
menu has been selected.

const bool doRootAction = false;
MenuLCD g_menuLCD( LCDRS, LCDE, LCDD4, LCDD5, LCDD6, LCDD7, 16, 2);
MenuManager g_menuManager( &g_menuLCD, doRootAction);


Getting Started: Open the Arduino_Menu_LCD.ino sketch in the Arduino IDE. Upload the sketch. In the serial window, send the following keys to control the menu:

u - move UP
Expand Down
File renamed without changes.