From ce35f763ec7eebf37e680164f4836b21dd4bdbd7 Mon Sep 17 00:00:00 2001 From: Jan Vogel Date: Wed, 15 Feb 2017 14:20:10 -0800 Subject: [PATCH 1/7] Update MenuEntry.cpp Upper/lowercase issue with arduino.h fixed --- MenuEntry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MenuEntry.cpp b/MenuEntry.cpp index 1201270..1b6cc5f 100644 --- a/MenuEntry.cpp +++ b/MenuEntry.cpp @@ -19,7 +19,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI */ -#include +#include #include "MenuEntry.h" #include "MenuManager.h" From 0aa7d3fe7e151befa3c7d5b5e9cdeba5f8a11411 Mon Sep 17 00:00:00 2001 From: Jan Vogel Date: Wed, 15 Feb 2017 14:21:18 -0800 Subject: [PATCH 2/7] Update MenuLCD.cpp --- MenuLCD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MenuLCD.cpp b/MenuLCD.cpp index 93f8713..899f0ff 100644 --- a/MenuLCD.cpp +++ b/MenuLCD.cpp @@ -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 +#include #include #include "MenuLCD.h" From c1f063d1a0fb9dea28e0c77edf3033f84650b83b Mon Sep 17 00:00:00 2001 From: Jan Vogel Date: Wed, 15 Feb 2017 14:22:21 -0800 Subject: [PATCH 3/7] Update MenuEntry.h --- MenuEntry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MenuEntry.h b/MenuEntry.h index 7ce0d9c..9c8c556 100644 --- a/MenuEntry.h +++ b/MenuEntry.h @@ -19,7 +19,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI */ -#include +#include #ifndef MenuEntry_h #define MenuEntry_h 1 From c8e0cb151c912dbd3cf02562198315f56847f8a4 Mon Sep 17 00:00:00 2001 From: Tweep Date: Wed, 15 Feb 2017 14:30:51 -0800 Subject: [PATCH 4/7] * examples dir added --- .../Arduino_LCD_Menu/Arduino_LCD_Menu.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Arduino_LCD_Menu.ino => examples/Arduino_LCD_Menu/Arduino_LCD_Menu.ino (100%) diff --git a/Arduino_LCD_Menu.ino b/examples/Arduino_LCD_Menu/Arduino_LCD_Menu.ino similarity index 100% rename from Arduino_LCD_Menu.ino rename to examples/Arduino_LCD_Menu/Arduino_LCD_Menu.ino From 6eada37ba171f803af9a143a3b5944e3004e074f Mon Sep 17 00:00:00 2001 From: Jan Vogel Date: Wed, 15 Feb 2017 14:32:59 -0800 Subject: [PATCH 5/7] Cursor changed to > Cursor changed from [ menu ] to >menu --- MenuLCD.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MenuLCD.cpp b/MenuLCD.cpp index 899f0ff..b7d5af8 100644 --- a/MenuLCD.cpp +++ b/MenuLCD.cpp @@ -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 { From 7bb01181b888b6917a33c6e37da5ac1a1cb3a37e Mon Sep 17 00:00:00 2001 From: Tweep Date: Wed, 15 Feb 2017 18:26:21 -0800 Subject: [PATCH 6/7] addtl. notes --- readme => README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename readme => README.md (96%) diff --git a/readme b/README.md similarity index 96% rename from readme rename to README.md index 305a985..0937151 100644 --- a/readme +++ b/README.md @@ -1,6 +1,8 @@ -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) From c32dd22e112629fa4f57e4da229d73322fd096c0 Mon Sep 17 00:00:00 2001 From: Tweep Date: Thu, 16 Feb 2017 11:46:37 -0800 Subject: [PATCH 7/7] - Functionality added so the execution of callback functions for root menu-nodes (menu nodes which have a child ) can be configured and passed into the constructor. This is needed if you like to keep track of the menus / submenus the user is modifying. I'm using this for this kind of menu structure: LED strip 1 |--- configure brightness |----configure color LED strip 2 |--- configure brightness |----configure color When the user chooses to enter the root menu "LED strip 1" a callback function will be executed to set a variable to 'strip 1'. --- MenuManager.cpp | 19 ++++++++++++++++++- MenuManager.h | 8 ++++++-- README.md | 10 ++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/MenuManager.cpp b/MenuManager.cpp index 1f2afc2..ebc8e4b 100644 --- a/MenuManager.cpp +++ b/MenuManager.cpp @@ -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; @@ -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 ) { diff --git a/MenuManager.h b/MenuManager.h index 799635e..5ec41d3 100644 --- a/MenuManager.h +++ b/MenuManager.h @@ -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(); @@ -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; + }; diff --git a/README.md b/README.md index 0937151..d1902c2 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ 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