├── extras └── img │ ├── 20x4_1.jpg │ ├── 20x4_2.jpg │ ├── 20x4_3.jpg │ ├── 20x4_4.jpg │ ├── glcd_1.jpg │ ├── glcd_2.jpg │ ├── glcd_3.jpg │ ├── glcd_4.jpg │ ├── console_1.png │ ├── console_2.png │ └── console_3.png ├── library.properties ├── examples ├── 02_functionality │ ├── LCDML_023_multiLanguage_small │ │ ├── LCDML_display_dynFunction.ino │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_menu.ino │ │ ├── LCDML_display_menuFunction.ino │ │ └── LCDML_023_multiLanguage_small.ino │ ├── LCDML_020_filelist │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ ├── LCDML_display_menu.ino │ │ └── LCDML_020_filelist.ino │ ├── LCDML_022_multiLanguage │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino │ ├── LCDML_021_dynUpdatedContent │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino │ └── LCDML_024_condetions │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ ├── LCDML_display_menu.ino │ │ ├── LCDML_024_condetions.ino │ │ └── LCDML_display_menuFunction.ino ├── 00_beginners │ ├── LCDML_000_serialMonitor │ │ ├── LCDML_condition.ino │ │ ├── PlatformIO │ │ │ └── src │ │ │ │ ├── LCDML_condition.h │ │ │ │ ├── LCDML_display_dynFunction.h │ │ │ │ ├── LCDML_display_menu.h │ │ │ │ └── main.cpp │ │ ├── LCDML_display_dynFunction.ino │ │ ├── LCDML_display_menu.ino │ │ └── LCDML_000_serialMonitor.ino │ └── LCDML_001_liquidCrystal │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino ├── 01_backend │ ├── LCDML_010_simpleThread │ │ ├── LCDML_condition.ino │ │ ├── simple_threads.ino │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino │ └── LCDML_011_TaskScheduler │ │ ├── LCDML_condition.ino │ │ ├── TaskScheduler.ino │ │ ├── LCDML_display_dynFunction.ino │ │ ├── LCDML_display_menu.ino │ │ └── LCDML_011_TaskScheduler.ino └── 03_displaytypes │ ├── 02_glcd │ ├── LCDML_03022_u8glib │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino │ └── LCDML_03021_u8g2lib │ │ ├── LCDML_condition.ino │ │ ├── PlaformIO │ │ └── src │ │ │ ├── LCDML_condition.h │ │ │ ├── LCDML_display_dynFunction.h │ │ │ └── LCDML_display_menu.h │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino │ ├── 01_lcd │ ├── LCDML_03012_liquidcrystal_20x4 │ │ ├── LCDML_condition.ino │ │ ├── LCDML_display_dynFunction.ino │ │ └── LCDML_display_menu.ino │ └── LCDML_03011_i2c_display_20x4 │ │ ├── LCDML_display_menu.ino │ │ └── LCDML_03011_i2c_display_20x4.ino │ └── 03_gfx │ ├── LCDML_03031_adafruit_gfx_ssd1306 │ ├── LCDML_condition.ino │ ├── LCDML_display_dynFunction.ino │ └── LCDML_display_menu.ino │ └── LCDML_03032_adafruit_gfx_st7735 │ ├── LCDML_condition.ino │ ├── LCDML_display_dynFunction.ino │ └── LCDML_display_menu.ino ├── LICENSE ├── src ├── LCDMenuLib2_typedef.h ├── LCDMenuLib2_menu.h └── LCDMenuLib2_menu.cpp └── README.md /extras/img/20x4_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/20x4_1.jpg -------------------------------------------------------------------------------- /extras/img/20x4_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/20x4_2.jpg -------------------------------------------------------------------------------- /extras/img/20x4_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/20x4_3.jpg -------------------------------------------------------------------------------- /extras/img/20x4_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/20x4_4.jpg -------------------------------------------------------------------------------- /extras/img/glcd_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/glcd_1.jpg -------------------------------------------------------------------------------- /extras/img/glcd_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/glcd_2.jpg -------------------------------------------------------------------------------- /extras/img/glcd_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/glcd_3.jpg -------------------------------------------------------------------------------- /extras/img/glcd_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/glcd_4.jpg -------------------------------------------------------------------------------- /extras/img/console_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/console_1.png -------------------------------------------------------------------------------- /extras/img/console_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/console_2.png -------------------------------------------------------------------------------- /extras/img/console_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jomelo/LCDMenuLib2/HEAD/extras/img/console_3.png -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=LCDMenuLib2 2 | version=2.2.8 3 | author=Nils Feldkämper 4 | maintainer=Community https://github.com/Jomelo/LCDMenuLib2 5 | sentence=Easy creation of a multi layer tree menu with screensaver and other stuff. 6 | paragraph=Examples for the basic function and different output types [console (serial monitor), lcd displays, glcd displays, gfx displays] 7 | category=Display 8 | url=https://github.com/Jomelo/LCDMenuLib2 9 | architectures=* 10 | includes=LCDMenuLib2.h -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_023_multiLanguage_small/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | // not needed in this example 10 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_010_simpleThread/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_011_TaskScheduler/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_020_filelist/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_022_multiLanguage/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_023_multiLanguage_small/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/PlatformIO/src/LCDML_condition.h: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide() // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_001_liquidCrystal/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03022_u8glib/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03021_u8g2lib/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/03_displaytypes/01_lcd/LCDML_03012_liquidcrystal_20x4/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/03_displaytypes/03_gfx/LCDML_03031_adafruit_gfx_ssd1306/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/03_displaytypes/03_gfx/LCDML_03032_adafruit_gfx_st7735/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_011_TaskScheduler/TaskScheduler.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // ********************************************************** 5 | void Task_Serial_Blink_Example() { 6 | // ********************************************************** 7 | 8 | 9 | Serial.println("."); 10 | } 11 | 12 | // ********************************************************** 13 | void Task_input_check() { 14 | // ********************************************************** 15 | 16 | // check LCDML inputs 17 | LCDML.loop_control(); 18 | } 19 | 20 | // ********************************************************** 21 | void Task_LCDMenuLib() { 22 | // ********************************************************** 23 | 24 | 25 | LCDML.loop_menu(); 26 | } 27 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03021_u8g2lib/PlaformIO/src/LCDML_condition.h: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | #include 9 | 10 | // ********************************************************************* 11 | boolean COND_hide() // hide a menu element 12 | // ********************************************************************* 13 | { 14 | return false; // hidden 15 | } 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2025] [Nils Feldkämper] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_024_condetions/LCDML_condition.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Conditions to show or hide a menu element on the display * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | // ********************************************************************* 9 | boolean COND_hide(void) // hide a menu element 10 | // ********************************************************************* 11 | { 12 | return false; // hidden 13 | } 14 | 15 | // ********************************************************************* 16 | boolean COND_a(void) 17 | // ********************************************************************* 18 | { 19 | return g_condetion_a; 20 | } 21 | 22 | // ********************************************************************* 23 | boolean COND_not_a(void) 24 | // ********************************************************************* 25 | { 26 | // invert condetion a "!" 27 | return !g_condetion_a; 28 | } 29 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_010_simpleThread/simple_threads.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | // ===================================================================== 4 | void simpleThread_setup(Thread_Serial_Blink_Example) 5 | // ===================================================================== 6 | { 7 | // for example set pinmode for some inputs 8 | Serial.println(); 9 | } 10 | 11 | boolean simpleThread_loop(Thread_Serial_Blink_Example) 12 | { 13 | // generate a serial-output in the console every secound 14 | Serial.print("."); 15 | 16 | 17 | return false; 18 | } 19 | 20 | 21 | void simpleThread_stable(Thread_Serial_Blink_Example) 22 | { 23 | // stable state 24 | } 25 | 26 | 27 | 28 | 29 | // ===================================================================== 30 | void simpleThread_setup(Thread_input_check) 31 | // ===================================================================== 32 | { 33 | // for example set pinmode for some inputs 34 | } 35 | 36 | boolean simpleThread_loop(Thread_input_check) 37 | { 38 | // check inputs 39 | 40 | // check LCDML inputs 41 | LCDML.loop_control(); 42 | 43 | // go to the next function because the wait time is set to 0 44 | // when this return value is "false" all threads with a higher priority will not be called 45 | return true; 46 | } 47 | 48 | 49 | void simpleThread_stable(Thread_input_check) 50 | { 51 | // stable state 52 | } 53 | 54 | 55 | 56 | // ===================================================================== 57 | void simpleThread_setup(Thread_LCDMenuLib) 58 | // ===================================================================== 59 | { 60 | } 61 | boolean simpleThread_loop(Thread_LCDMenuLib) 62 | { 63 | 64 | LCDML.loop_menu(); 65 | 66 | return false; 67 | } 68 | 69 | void simpleThread_stable(Thread_LCDMenuLib) 70 | { 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/LCDMenuLib2_typedef.h: -------------------------------------------------------------------------------- 1 | /* ****************************************************************************** 2 | * LCDMenuLib2 (LCDML) 3 | * ****************************************************************************** 4 | * 5 | * MIT License 6 | * 7 | * Copyright (c) [2025] [Nils Feldkämper] 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in all 17 | * copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * ****************************************************************************** 28 | * 29 | * BUG / ISSUES REPORTING 30 | * https://github.com/Jomelo/LCDMenuLib2/issues 31 | * 32 | * ARDUINO FORUM 33 | * http://forum.arduino.cc/index.php?topic=73816.0 34 | * 35 | * ****************************************************************************** 36 | */ 37 | 38 | #ifndef _LCDML_typedef_h 39 | #define _LCDML_typedef_h 40 | 41 | typedef void (* LCDML_FuncPtr) (); 42 | typedef void (* LCDML_FuncPtr_pu8) (uint8_t); // with parameter u8 43 | typedef bool (* LCDML_FuncPtr_rb) (); // with return value bool 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_010_simpleThread/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | Serial.print("dynValue:"); 66 | Serial.print(g_dynParam); 67 | } 68 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_011_TaskScheduler/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | Serial.print("dynValue:"); 66 | Serial.print(g_dynParam); 67 | } 68 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | Serial.print("dynValue:"); 66 | Serial.print(g_dynParam); 67 | } 68 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_020_filelist/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | Serial.print("dynValue:"); 66 | Serial.print(g_dynParam); 67 | } 68 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_022_multiLanguage/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | Serial.print("dynValue:"); 66 | Serial.print(g_dynParam); 67 | } 68 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/PlatformIO/src/LCDML_display_dynFunction.h: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | Serial.print("dynValue:"); 66 | Serial.print(g_dynParam); 67 | } 68 | -------------------------------------------------------------------------------- /examples/03_displaytypes/01_lcd/LCDML_03012_liquidcrystal_20x4/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | char buf[20]; 66 | sprintf (buf, "dynValue: %d", g_dynParam); 67 | 68 | // use the line from function parameters 69 | lcd.setCursor(1, line); 70 | lcd.print(buf); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_001_liquidCrystal/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | char buf[20]; 66 | sprintf (buf, "dynValue: %d", g_dynParam); 67 | 68 | // use the line from function parameters 69 | lcd.setCursor(1, (line + _LCDML_DSIP_use_header)); 70 | lcd.print(buf); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /examples/03_displaytypes/03_gfx/LCDML_03031_adafruit_gfx_ssd1306/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | 40 | LCDML.BT_resetEnter(); 41 | } 42 | 43 | // This check have only an effect when MENU_disScroll is set 44 | if(LCDML.BT_checkUp()) 45 | { 46 | g_dynParam++; 47 | LCDML.BT_resetUp(); 48 | } 49 | 50 | // This check have only an effect when MENU_disScroll is set 51 | if(LCDML.BT_checkDown()) 52 | { 53 | g_dynParam--; 54 | LCDML.BT_resetDown(); 55 | } 56 | 57 | 58 | if(LCDML.BT_checkLeft()) 59 | { 60 | g_dynParam++; 61 | LCDML.BT_resetLeft(); 62 | } 63 | 64 | if(LCDML.BT_checkRight()) 65 | { 66 | g_dynParam--; 67 | LCDML.BT_resetRight(); 68 | } 69 | } 70 | } 71 | 72 | char buf[20]; 73 | sprintf (buf, " dynValue: %d", g_dynParam); 74 | 75 | display.setCursor(0, _LCDML_ADAFRUIT_FONT_H * (line)); 76 | display.println(buf); 77 | } 78 | -------------------------------------------------------------------------------- /examples/03_displaytypes/03_gfx/LCDML_03032_adafruit_gfx_st7735/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | 40 | LCDML.BT_resetEnter(); 41 | } 42 | 43 | // This check have only an effect when MENU_disScroll is set 44 | if(LCDML.BT_checkUp()) 45 | { 46 | g_dynParam++; 47 | LCDML.BT_resetUp(); 48 | } 49 | 50 | // This check have only an effect when MENU_disScroll is set 51 | if(LCDML.BT_checkDown()) 52 | { 53 | g_dynParam--; 54 | LCDML.BT_resetDown(); 55 | } 56 | 57 | 58 | if(LCDML.BT_checkLeft()) 59 | { 60 | g_dynParam++; 61 | LCDML.BT_resetLeft(); 62 | } 63 | 64 | if(LCDML.BT_checkRight()) 65 | { 66 | g_dynParam--; 67 | LCDML.BT_resetRight(); 68 | } 69 | } 70 | } 71 | 72 | char buf[20]; 73 | sprintf (buf, "dynValue: %d", g_dynParam); 74 | 75 | display.setCursor(1, _LCDML_ADAFRUIT_FONT_H * (line)); 76 | display.println(buf); 77 | } 78 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03021_u8g2lib/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | 40 | LCDML.BT_resetEnter(); 41 | } 42 | 43 | // This check have only an effect when MENU_disScroll is set 44 | if(LCDML.BT_checkUp()) 45 | { 46 | g_dynParam++; 47 | LCDML.BT_resetUp(); 48 | } 49 | 50 | // This check have only an effect when MENU_disScroll is set 51 | if(LCDML.BT_checkDown()) 52 | { 53 | g_dynParam--; 54 | LCDML.BT_resetDown(); 55 | } 56 | 57 | 58 | if(LCDML.BT_checkLeft()) 59 | { 60 | g_dynParam++; 61 | LCDML.BT_resetLeft(); 62 | } 63 | 64 | if(LCDML.BT_checkRight()) 65 | { 66 | g_dynParam--; 67 | LCDML.BT_resetRight(); 68 | } 69 | } 70 | } 71 | 72 | char buf[20]; 73 | sprintf (buf, "dynValue: %d", g_dynParam); 74 | 75 | // setup function 76 | u8g2.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_font_w + _LCDML_DISP_cur_space_behind, (_LCDML_DISP_font_h * (1+line)), buf); // the value can be changed with left or right 77 | 78 | } 79 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03022_u8glib/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | 40 | LCDML.BT_resetEnter(); 41 | } 42 | 43 | // This check have only an effect when MENU_disScroll is set 44 | if(LCDML.BT_checkUp()) 45 | { 46 | g_dynParam++; 47 | LCDML.BT_resetUp(); 48 | } 49 | 50 | // This check have only an effect when MENU_disScroll is set 51 | if(LCDML.BT_checkDown()) 52 | { 53 | g_dynParam--; 54 | LCDML.BT_resetDown(); 55 | } 56 | 57 | 58 | if(LCDML.BT_checkLeft()) 59 | { 60 | g_dynParam++; 61 | LCDML.BT_resetLeft(); 62 | } 63 | 64 | if(LCDML.BT_checkRight()) 65 | { 66 | g_dynParam--; 67 | LCDML.BT_resetRight(); 68 | } 69 | } 70 | } 71 | 72 | char buf[20]; 73 | sprintf (buf, "dynValue: %d", g_dynParam); 74 | 75 | // setup function 76 | u8g.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_font_w + _LCDML_DISP_cur_space_behind, (_LCDML_DISP_font_h * (1+line)), buf); // the value can be changed with left or right 77 | 78 | } 79 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03021_u8g2lib/PlaformIO/src/LCDML_display_dynFunction.h: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | 40 | LCDML.BT_resetEnter(); 41 | } 42 | 43 | // This check have only an effect when MENU_disScroll is set 44 | if(LCDML.BT_checkUp()) 45 | { 46 | g_dynParam++; 47 | LCDML.BT_resetUp(); 48 | } 49 | 50 | // This check have only an effect when MENU_disScroll is set 51 | if(LCDML.BT_checkDown()) 52 | { 53 | g_dynParam--; 54 | LCDML.BT_resetDown(); 55 | } 56 | 57 | 58 | if(LCDML.BT_checkLeft()) 59 | { 60 | g_dynParam++; 61 | LCDML.BT_resetLeft(); 62 | } 63 | 64 | if(LCDML.BT_checkRight()) 65 | { 66 | g_dynParam--; 67 | LCDML.BT_resetRight(); 68 | } 69 | } 70 | } 71 | 72 | char buf[20]; 73 | sprintf (buf, "dynValue: %d", g_dynParam); 74 | 75 | // setup function 76 | u8g2.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_font_w + _LCDML_DISP_cur_space_behind, (_LCDML_DISP_font_h * (1+line)), buf); // the value can be changed with left or right 77 | 78 | } -------------------------------------------------------------------------------- /examples/01_backend/LCDML_010_simpleThread/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = _LCDML_DISP_rows + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // loop to display lines 49 | do 50 | { 51 | // check if a menu element has a condition and if the condition be true 52 | if (tmp->checkCondition()) 53 | { 54 | // display cursor 55 | if (n == LCDML.MENU_getCursorPos()) 56 | { 57 | Serial.print(F("(x) ")); 58 | } 59 | else 60 | { 61 | Serial.print(F("( ) ")); 62 | } 63 | 64 | // check the type off a menu element 65 | if(tmp->checkType_menu() == true) 66 | { 67 | // display normal content 68 | LCDML_getContent(content_text, tmp->getID()); 69 | Serial.print(content_text); 70 | } 71 | else 72 | { 73 | if(tmp->checkType_dynParam()) { 74 | tmp->callback(n); 75 | } 76 | } 77 | 78 | Serial.println(); 79 | 80 | // increment some values 81 | i++; 82 | n++; 83 | } 84 | // try to go to the next sibling and check the number of displayed rows 85 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/01_backend/LCDML_011_TaskScheduler/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = _LCDML_DISP_rows + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // loop to display lines 49 | do 50 | { 51 | // check if a menu element has a condition and if the condition be true 52 | if (tmp->checkCondition()) 53 | { 54 | // display cursor 55 | if (n == LCDML.MENU_getCursorPos()) 56 | { 57 | Serial.print(F("(x) ")); 58 | } 59 | else 60 | { 61 | Serial.print(F("( ) ")); 62 | } 63 | 64 | // check the type off a menu element 65 | if(tmp->checkType_menu() == true) 66 | { 67 | // display normal content 68 | LCDML_getContent(content_text, tmp->getID()); 69 | Serial.print(content_text); 70 | } 71 | else 72 | { 73 | if(tmp->checkType_dynParam()) { 74 | tmp->callback(n); 75 | } 76 | } 77 | 78 | Serial.println(); 79 | 80 | // increment some values 81 | i++; 82 | n++; 83 | } 84 | // try to go to the next sibling and check the number of displayed rows 85 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_020_filelist/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = _LCDML_DISP_rows + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // loop to display lines 49 | do 50 | { 51 | // check if a menu element has a condition and if the condition be true 52 | if (tmp->checkCondition()) 53 | { 54 | // display cursor 55 | if (n == LCDML.MENU_getCursorPos()) 56 | { 57 | Serial.print(F("(x) ")); 58 | } 59 | else 60 | { 61 | Serial.print(F("( ) ")); 62 | } 63 | 64 | // check the type off a menu element 65 | if(tmp->checkType_menu() == true) 66 | { 67 | // display normal content 68 | LCDML_getContent(content_text, tmp->getID()); 69 | Serial.print(content_text); 70 | } 71 | else 72 | { 73 | if(tmp->checkType_dynParam()) { 74 | tmp->callback(n); 75 | } 76 | } 77 | 78 | Serial.println(); 79 | 80 | // increment some values 81 | i++; 82 | n++; 83 | } 84 | // try to go to the next sibling and check the number of displayed rows 85 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_024_condetions/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_change_condetion(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | 42 | if(LCDML.BT_checkLeft() || LCDML.BT_checkRight()) 43 | { 44 | g_condetion_a = !g_condetion_a; 45 | 46 | // this functions are new in this version 47 | 48 | // The handling of condetions is changed in this version because a condetion must not called with every element call 49 | // The condetions would only be update when this function is called. 50 | LCDML.MENU_allCondetionRefresh(); 51 | 52 | // this function is usefull when content above this menu element needs an update. 53 | // for example one dyn function change the content of another dyn function above this line. 54 | LCDML.MENU_setDynFunctionContentUpdate(); 55 | 56 | // after the condetion changes it is usefull to go back to the root menu 57 | //LCDML.MENU_goRoot(); 58 | // or set the cursor to the right defined position 59 | LCDML.OTHER_setCursorToID(8); // to this function 60 | } 61 | } 62 | } 63 | 64 | if(g_condetion_a == true) 65 | { 66 | Serial.println("change to condetion: < B >"); 67 | } 68 | else 69 | { 70 | Serial.println("change to condetion: < A >"); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = (_LCDML_DISP_rows - _LCDML_DSIP_use_header) + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // Display a header with the parent element name 49 | if(_LCDML_DSIP_use_header > 0) 50 | { 51 | // only one line 52 | if(LCDML.MENU_getLayer() == 0) 53 | { 54 | // this text is displayed when no header is available 55 | Serial.println(F("Root Menu")); 56 | } 57 | else 58 | { 59 | // Display parent name 60 | LCDML_getContent(content_text, LCDML.MENU_getParentID()); 61 | Serial.print(content_text); 62 | Serial.println(); 63 | } 64 | } 65 | 66 | // loop to display lines 67 | do 68 | { 69 | // check if a menu element has a condition and if the condition be true 70 | if (tmp->checkCondition()) 71 | { 72 | // display cursor 73 | if (n == LCDML.MENU_getCursorPos()) 74 | { 75 | Serial.print(F("(x) ")); 76 | } 77 | else 78 | { 79 | Serial.print(F("( ) ")); 80 | } 81 | 82 | // check the type off a menu element 83 | if(tmp->checkType_menu() == true) 84 | { 85 | // display normal content 86 | LCDML_getContent(content_text, tmp->getID()); 87 | Serial.print(content_text); 88 | } 89 | else 90 | { 91 | if(tmp->checkType_dynParam()) { 92 | tmp->callback(n); 93 | } 94 | } 95 | 96 | Serial.println(); 97 | 98 | // increment some values 99 | i++; 100 | n++; 101 | } 102 | // try to go to the next sibling and check the number of displayed rows 103 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_024_condetions/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = (_LCDML_DISP_rows - _LCDML_DSIP_use_header) + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // Display a header with the parent element name 49 | if(_LCDML_DSIP_use_header > 0) 50 | { 51 | // only one line 52 | if(LCDML.MENU_getLayer() == 0) 53 | { 54 | // this text is displayed when no header is available 55 | Serial.println(F("Root Menu")); 56 | } 57 | else 58 | { 59 | // Display parent name 60 | LCDML_getContent(content_text, LCDML.MENU_getParentID()); 61 | Serial.print(content_text); 62 | Serial.println(); 63 | } 64 | } 65 | 66 | // loop to display lines 67 | do 68 | { 69 | // check if a menu element has a condition and if the condition be true 70 | if (tmp->checkCondition()) 71 | { 72 | // display cursor 73 | if (n == LCDML.MENU_getCursorPos()) 74 | { 75 | Serial.print(F("(x) ")); 76 | } 77 | else 78 | { 79 | Serial.print(F("( ) ")); 80 | } 81 | 82 | // check the type off a menu element 83 | if(tmp->checkType_menu() == true) 84 | { 85 | // display normal content 86 | LCDML_getContent(content_text, tmp->getID()); 87 | Serial.print(content_text); 88 | } 89 | else 90 | { 91 | if(tmp->checkType_dynParam()) { 92 | tmp->callback(n); 93 | } 94 | } 95 | 96 | Serial.println(); 97 | 98 | // increment some values 99 | i++; 100 | n++; 101 | } 102 | // try to go to the next sibling and check the number of displayed rows 103 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/PlatformIO/src/LCDML_display_menu.h: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = (_LCDML_DISP_rows - _LCDML_DSIP_use_header) + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // Display a header with the parent element name 49 | if(_LCDML_DSIP_use_header > 0) 50 | { 51 | // only one line 52 | if(LCDML.MENU_getLayer() == 0) 53 | { 54 | // this text is displayed when no header is available 55 | Serial.println(F("Root Menu")); 56 | } 57 | else 58 | { 59 | // Display parent name 60 | LCDML_getContent(content_text, LCDML.MENU_getParentID()); 61 | Serial.print(content_text); 62 | Serial.println(); 63 | } 64 | } 65 | 66 | // loop to display lines 67 | do 68 | { 69 | // check if a menu element has a condition and if the condition be true 70 | if (tmp->checkCondition()) 71 | { 72 | // display cursor 73 | if (n == LCDML.MENU_getCursorPos()) 74 | { 75 | Serial.print(F("(x) ")); 76 | } 77 | else 78 | { 79 | Serial.print(F("( ) ")); 80 | } 81 | 82 | // check the type off a menu element 83 | if(tmp->checkType_menu() == true) 84 | { 85 | // display normal content 86 | LCDML_getContent(content_text, tmp->getID()); 87 | Serial.print(content_text); 88 | } 89 | else 90 | { 91 | if(tmp->checkType_dynParam()) { 92 | tmp->callback(n); 93 | } 94 | } 95 | 96 | Serial.println(); 97 | 98 | // increment some values 99 | i++; 100 | n++; 101 | } 102 | // try to go to the next sibling and check the number of displayed rows 103 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_022_multiLanguage/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = _LCDML_DISP_rows + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // loop to display lines 49 | do 50 | { 51 | // check if a menu element has a condition and if the condition be true 52 | if (tmp->checkCondition()) 53 | { 54 | // display cursor 55 | if (n == LCDML.MENU_getCursorPos()) 56 | { 57 | Serial.print(F("(x) ")); 58 | } 59 | else 60 | { 61 | Serial.print(F("( ) ")); 62 | } 63 | 64 | // check the type off a menu element 65 | if(tmp->checkType_menu() == true) 66 | { 67 | // display normal content 68 | switch(g_lcdml_lang_select) 69 | { 70 | case LANG_DE: // custom language long name 71 | // get the custom language content with the short name of the language 72 | LCDML_getCustomContent(DE, content_text, tmp->getID()); 73 | break; 74 | 75 | /* 76 | // this is only an example for other languages 77 | case LANG_EN: // custom language long name 78 | // get the custom language content with the short name of the language 79 | LCDML_getCustomContent(EN, content_text, tmp->getID()); 80 | break; 81 | */ 82 | 83 | 84 | default: // default language 85 | LCDML_getContent(content_text, tmp->getID()); 86 | break; 87 | } 88 | 89 | Serial.print(content_text); 90 | } 91 | else 92 | { 93 | if(tmp->checkType_dynParam()) { 94 | tmp->callback(n); 95 | } 96 | } 97 | 98 | Serial.println(); 99 | 100 | // increment some values 101 | i++; 102 | n++; 103 | } 104 | // try to go to the next sibling and check the number of displayed rows 105 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_023_multiLanguage_small/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | for(uint8_t i=0;i<15;i++) { 12 | Serial.println(); 13 | } 14 | } 15 | 16 | /* ******************************************************************** */ 17 | void lcdml_menu_display() 18 | /* ******************************************************************** */ 19 | { 20 | // init vars 21 | //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 22 | 23 | // update content 24 | // *************** 25 | if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) { 26 | // clear menu 27 | // *************** 28 | LCDML.DISP_clear(); 29 | 30 | Serial.println(F("===========================================")); 31 | Serial.println(F("================ Menu ====================")); 32 | Serial.println(F("===========================================")); 33 | 34 | // declaration of some variables 35 | // *************** 36 | // content variable 37 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 38 | // menu element object 39 | LCDMenuLib2_menu *tmp; 40 | // some limit values 41 | uint8_t i = LCDML.MENU_getScroll(); 42 | uint8_t maxi = _LCDML_DISP_rows + i; 43 | uint8_t n = 0; 44 | 45 | // check if this element has children 46 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 47 | { 48 | // loop to display lines 49 | do 50 | { 51 | // check if a menu element has a condition and if the condition be true 52 | if (tmp->checkCondition()) 53 | { 54 | // display cursor 55 | if (n == LCDML.MENU_getCursorPos()) 56 | { 57 | Serial.print(F("(x) ")); 58 | } 59 | else 60 | { 61 | Serial.print(F("( ) ")); 62 | } 63 | 64 | // check the type off a menu element 65 | if(tmp->checkType_menu() == true) 66 | { 67 | // display normal content 68 | switch(g_lcdml_lang_select) 69 | { 70 | case LANG_DE: // custom language long name 71 | // get the custom language content with the short name of the language 72 | LCDML_getCustomContent(DE, content_text, tmp->getID()); 73 | break; 74 | 75 | /* 76 | // this is only an example for other languages 77 | case LANG_EN: // custom language long name 78 | // get the custom language content with the short name of the language 79 | LCDML_getCustomContent(EN, content_text, tmp->getID()); 80 | break; 81 | */ 82 | 83 | 84 | default: // default language 85 | LCDML_getContent(content_text, tmp->getID()); 86 | break; 87 | } 88 | 89 | Serial.print(content_text); 90 | } 91 | else 92 | { 93 | if(tmp->checkType_dynParam()) { 94 | tmp->callback(n); 95 | } 96 | } 97 | 98 | Serial.println(); 99 | 100 | // increment some values 101 | i++; 102 | n++; 103 | } 104 | // try to go to the next sibling and check the number of displayed rows 105 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_dynFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Dynamic content * 4 | * * 5 | * ===================================================================== * 6 | */ 7 | 8 | 9 | uint8_t g_dynParam = 100; // when this value comes from an EEPROM, load it in setup 10 | // at the moment here is no setup function (To-Do) 11 | void mDyn_para(uint8_t line) 12 | // ********************************************************************* 13 | { 14 | // check if this function is active (cursor stands on this line) 15 | if (line == LCDML.MENU_getCursorPos()) 16 | { 17 | // make only an action when the cursor stands on this menu item 18 | //check Button 19 | if(LCDML.BT_checkAny()) 20 | { 21 | if(LCDML.BT_checkEnter()) 22 | { 23 | // this function checks returns the scroll disable status (0 = menu scrolling enabled, 1 = menu scrolling disabled) 24 | if(LCDML.MENU_getScrollDisableStatus() == 0) 25 | { 26 | // disable the menu scroll function to catch the cursor on this point 27 | // now it is possible to work with BT_checkUp and BT_checkDown in this function 28 | // this function can only be called in a menu, not in a menu function 29 | LCDML.MENU_disScroll(); 30 | } 31 | else 32 | { 33 | // enable the normal menu scroll function 34 | LCDML.MENU_enScroll(); 35 | } 36 | 37 | // do something 38 | // ... 39 | } 40 | 41 | // This check have only an effect when MENU_disScroll is set 42 | if(LCDML.BT_checkUp()) 43 | { 44 | g_dynParam++; 45 | } 46 | 47 | // This check have only an effect when MENU_disScroll is set 48 | if(LCDML.BT_checkDown()) 49 | { 50 | g_dynParam--; 51 | } 52 | 53 | 54 | if(LCDML.BT_checkLeft()) 55 | { 56 | g_dynParam++; 57 | } 58 | if(LCDML.BT_checkRight()) 59 | { 60 | g_dynParam--; 61 | } 62 | } 63 | } 64 | 65 | 66 | // clear the line manuel because clear the complete content is disabled when a external refreshed function is active 67 | lcd.setCursor(1, line); 68 | for(uint8_t i=0;i<_LCDML_DISP_cols-3;i++) // -3 because: 69 | // -1 for counter from 0 to x 70 | // -1 for cursor position 71 | // -1 for scrollbar on the end 72 | { 73 | lcd.print(F(" ")); 74 | } 75 | 76 | 77 | char buf[20]; 78 | sprintf (buf, "dynValue: %d", g_dynParam); 79 | // use the line from function parameters 80 | lcd.setCursor(1, line); 81 | lcd.print(buf); 82 | } 83 | 84 | 85 | 86 | 87 | // ********************************************************************* 88 | void mDyn_time(uint8_t line) 89 | // ********************************************************************* 90 | { 91 | // clear the line manuel because clear the complete content is disabled when a external refreshed function is active 92 | lcd.setCursor(1, line); 93 | for(uint8_t i=0;i<_LCDML_DISP_cols-3;i++) // -3 because: 94 | // -1 for counter from 0 to x 95 | // -1 for cursor position 96 | // -1 for scrollbar on the end 97 | { 98 | lcd.print(F(" ")); 99 | } 100 | 101 | 102 | char buf[20]; 103 | // http://www.c-howto.de/tutorial/benutzerinteraktion/bildschirmausgaben/ 104 | sprintf (buf, "Time %02d:%02d:%02d", dyn_hour, dyn_min, dyn_sec); 105 | 106 | // use the line from function parameters 107 | lcd.setCursor(1, line); 108 | lcd.print(buf); 109 | 110 | // reset initscreen timer when this function is displayed 111 | //LCDML.SCREEN_resetTimer(); 112 | 113 | // check if this function is active (cursor stands on this line) 114 | if (line == LCDML.MENU_getCursorPos()) 115 | { 116 | // ... 117 | } 118 | } -------------------------------------------------------------------------------- /examples/03_displaytypes/01_lcd/LCDML_03011_i2c_display_20x4/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | lcd.clear(); 12 | lcd.setCursor(0, 0); 13 | } 14 | 15 | /* ******************************************************************** */ 16 | void lcdml_menu_display() 17 | /* ******************************************************************** */ 18 | { 19 | // update content 20 | // *************** 21 | if (LCDML.DISP_checkMenuUpdate()) { 22 | // clear menu 23 | // *************** 24 | LCDML.DISP_clear(); 25 | 26 | // declaration of some variables 27 | // *************** 28 | // content variable 29 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 30 | // menu element object 31 | LCDMenuLib2_menu *tmp; 32 | // some limit values 33 | uint8_t i = LCDML.MENU_getScroll(); 34 | uint8_t maxi = _LCDML_DISP_rows + i; 35 | uint8_t n = 0; 36 | 37 | // check if this element has children 38 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 39 | { 40 | // loop to display lines 41 | do 42 | { 43 | // check if a menu element has a condition and if the condition be true 44 | if (tmp->checkCondition()) 45 | { 46 | // check the type off a menu element 47 | if(tmp->checkType_menu() == true) 48 | { 49 | // display normal content 50 | LCDML_getContent(content_text, tmp->getID()); 51 | lcd.setCursor(1, n); 52 | lcd.print(content_text); 53 | } 54 | else 55 | { 56 | if(tmp->checkType_dynParam()) { 57 | tmp->callback(n); 58 | } 59 | } 60 | // increment some values 61 | i++; 62 | n++; 63 | } 64 | // try to go to the next sibling and check the number of displayed rows 65 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 66 | } 67 | } 68 | 69 | if(LCDML.DISP_checkMenuCursorUpdate()) 70 | { 71 | // init vars 72 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 73 | uint8_t scrollbar_min = 0; 74 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 75 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 76 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 77 | 78 | 79 | // display rows 80 | for (uint8_t n = 0; n < n_max; n++) 81 | { 82 | //set cursor 83 | lcd.setCursor(0, n); 84 | 85 | //set cursor char 86 | if (n == LCDML.MENU_getCursorPos()) { 87 | lcd.write(_LCDML_DISP_cfg_cursor); 88 | } else { 89 | lcd.write(' '); 90 | } 91 | 92 | // delete or reset scrollbar 93 | if (_LCDML_DISP_cfg_scrollbar == 1) { 94 | if (scrollbar_max > n_max) { 95 | lcd.setCursor((_LCDML_DISP_cols - 1), n); 96 | lcd.write((uint8_t)0); 97 | } 98 | else { 99 | lcd.setCursor((_LCDML_DISP_cols - 1), n); 100 | lcd.print(' '); 101 | } 102 | } 103 | } 104 | 105 | // display scrollbar 106 | if (_LCDML_DISP_cfg_scrollbar == 1) { 107 | if (scrollbar_max > n_max) { 108 | //set scroll position 109 | if (scrollbar_cur_pos == scrollbar_min) { 110 | // min pos 111 | lcd.setCursor((_LCDML_DISP_cols - 1), 0); 112 | lcd.write((uint8_t)1); 113 | } else if (scrollbar_cur_pos == (scrollbar_max - 1)) { 114 | // max pos 115 | lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1)); 116 | lcd.write((uint8_t)4); 117 | } else { 118 | // between 119 | lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max); 120 | lcd.write((uint8_t)(scroll_pos % n_max) + 1); 121 | } 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /examples/03_displaytypes/01_lcd/LCDML_03012_liquidcrystal_20x4/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | lcd.clear(); 12 | lcd.setCursor(0, 0); 13 | } 14 | 15 | /* ******************************************************************** */ 16 | void lcdml_menu_display() 17 | /* ******************************************************************** */ 18 | { 19 | // update content 20 | // *************** 21 | if (LCDML.DISP_checkMenuUpdate()) { 22 | // clear menu 23 | // *************** 24 | LCDML.DISP_clear(); 25 | 26 | // declaration of some variables 27 | // *************** 28 | // content variable 29 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 30 | // menu element object 31 | LCDMenuLib2_menu *tmp; 32 | // some limit values 33 | uint8_t i = LCDML.MENU_getScroll(); 34 | uint8_t maxi = _LCDML_DISP_rows + i; 35 | uint8_t n = 0; 36 | 37 | // check if this element has children 38 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 39 | { 40 | // loop to display lines 41 | do 42 | { 43 | // check if a menu element has a condition and if the condition be true 44 | if (tmp->checkCondition()) 45 | { 46 | // check the type off a menu element 47 | if(tmp->checkType_menu() == true) 48 | { 49 | // display normal content 50 | LCDML_getContent(content_text, tmp->getID()); 51 | lcd.setCursor(1, n); 52 | lcd.print(content_text); 53 | } 54 | else 55 | { 56 | if(tmp->checkType_dynParam()) { 57 | tmp->callback(n); 58 | } 59 | } 60 | // increment some values 61 | i++; 62 | n++; 63 | } 64 | // try to go to the next sibling and check the number of displayed rows 65 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 66 | } 67 | } 68 | 69 | if(LCDML.DISP_checkMenuCursorUpdate()) 70 | { 71 | // init vars 72 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 73 | uint8_t scrollbar_min = 0; 74 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 75 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 76 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 77 | 78 | 79 | // display rows 80 | for (uint8_t n = 0; n < n_max; n++) 81 | { 82 | //set cursor 83 | lcd.setCursor(0, n); 84 | 85 | //set cursor char 86 | if (n == LCDML.MENU_getCursorPos()) { 87 | lcd.write(_LCDML_DISP_cfg_cursor); 88 | } else { 89 | lcd.write(' '); 90 | } 91 | 92 | // delete or reset scrollbar 93 | if (_LCDML_DISP_cfg_scrollbar == 1) { 94 | if (scrollbar_max > n_max) { 95 | lcd.setCursor((_LCDML_DISP_cols - 1), n); 96 | lcd.write((uint8_t)0); 97 | } 98 | else { 99 | lcd.setCursor((_LCDML_DISP_cols - 1), n); 100 | lcd.print(' '); 101 | } 102 | } 103 | } 104 | 105 | // display scrollbar 106 | if (_LCDML_DISP_cfg_scrollbar == 1) { 107 | if (scrollbar_max > n_max) { 108 | //set scroll position 109 | if (scrollbar_cur_pos == scrollbar_min) { 110 | // min pos 111 | lcd.setCursor((_LCDML_DISP_cols - 1), 0); 112 | lcd.write((uint8_t)1); 113 | } else if (scrollbar_cur_pos == (scrollbar_max - 1)) { 114 | // max pos 115 | lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1)); 116 | lcd.write((uint8_t)4); 117 | } else { 118 | // between 119 | lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max); 120 | lcd.write((uint8_t)(scroll_pos % n_max) + 1); 121 | } 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino LCDMenuLib2 (LCDML) 2 | A versatile menu library for Arduino, supporting various LCD types (row displays, graphic displays, console output). 3 | 4 | [![GitHub Issues](https://img.shields.io/github/issues/Jomelo/LCDMenuLib2)](https://github.com/Jomelo/LCDMenuLib2/issues) 5 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) 6 | 7 | ## Table of Contents 8 | 1. [Features](#features) 9 | 2. [Installation](#installation) 10 | 3. [Code reference](#lcdml-code-reference) 11 | 4. [Forum Link](#forum-link) 12 | 3. [Images](#images) 13 | 4. [License](#license) 14 | 15 | ## Features 16 | - **Supports up to 254 menu elements** per layer. 17 | - **Tree-based structure** (parent, child, sibling). 18 | - Requires a minimum of **3 buttons** (up, down, enter). 19 | - Supports **6 predefined buttons** (up, down, left, right, back/quit, enter). 20 | - Handles **64 custom events**, such as button clicks or other triggers. This events could be combined with a special handling to open a defined menu function when the status is changed. 21 | - **Screensaver support** after a configurable timeout. 22 | - Displays a **scrollbar** when menu elements exceed display rows. 23 | - Allows **dynamic parameter changes** directly from the menu. 24 | - Separation of structural and functional level 25 | - Setting of **special conditions** to diplay elements 26 | - Can be used for **statemashines** with jumping function between menu elements 27 | - Provides **examples** for various LCD libraries and functionalities. 28 | 29 | ## Installation 30 | ### Arduino IDE -> Library Installation 31 | 1. Search into the Arduino Library for "LCDMenuLib2". 32 | 2. Follow the installation instruction. 33 | ### Arduino IDE -> Installation by ZIP file 34 | 1. Download the library from the [GitHub repository](https://github.com/Jomelo/LCDMenuLib2). 35 | 2. Open the Arduino IDE. 36 | 3. Go to `Sketch > Include Library > Add .ZIP Library`. 37 | 4. Select the downloaded `.zip` file and click `Open`. 38 | 39 | ### PlatformIO 40 | 1. Add the following to your `platformio.ini` file: 41 | ```ini 42 | lib_deps = 43 | Jomelo/LCDMenuLib2 44 | 45 | ## LCDML Code Reference 46 | - https://github.com/Jomelo/LCDMenuLib2/wiki/Code-Reference 47 | 48 | ## Forum-Link 49 | Description (German): 50 | http://forum.arduino.cc/index.php?topic=73816.0 51 | 52 | ## Images 53 | ### 20x4 LCD 54 | 55 | ![20x4 display](extras/img/20x4_1.jpg?raw=true "20x4 display") 56 | ![20x4 display](extras/img/20x4_2.jpg?raw=true "20x4 display") 57 | ![20x4 display](extras/img/20x4_3.jpg?raw=true "20x4 display") 58 | ![20x4 display](extras/img/20x4_4.jpg?raw=true "20x4 display") 59 | 60 | ### glcd with u8glib 61 | 62 | ![Graphic display](extras/img/glcd_1.jpg?raw=true "Graphic display") 63 | ![Graphic display](extras/img/glcd_2.jpg?raw=true "Graphic display") 64 | ![Graphic display](extras/img/glcd_3.jpg?raw=true "Graphic display") 65 | ![Graphic display](extras/img/glcd_4.jpg?raw=true "Graphic display") 66 | 67 | ### serial monitor for testing or programming without a connected display 68 | 69 | ![Serial Monitor](extras/img/console_1.png?raw=true "Serial Monitor") 70 | ![Serial Monitor](extras/img/console_2.png?raw=true "Serial Monitor") 71 | ![Serial Monitor](extras/img/console_3.png?raw=true "Serial Monitor") 72 | 73 | ## License 74 | MIT License 75 | 76 | Copyright (c) [2025] [Nils Feldkämper] 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to deal 80 | in the Software without restriction, including without limitation the rights 81 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 82 | copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in all 86 | copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 93 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 94 | SOFTWARE. -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | if (LCDML.MENU_checkDynRContent() == false) 12 | { 13 | // clear only the display when the external content refresh is not displayed 14 | lcd.clear(); 15 | } 16 | } 17 | 18 | /* ******************************************************************** */ 19 | void lcdml_menu_display() 20 | /* ******************************************************************** */ 21 | { 22 | // update content 23 | // *************** 24 | if (LCDML.DISP_checkMenuUpdate()) { 25 | // declaration of some variables 26 | // *************** 27 | // content variable 28 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 29 | // menu element object 30 | LCDMenuLib2_menu *tmp; 31 | // some limit values 32 | uint8_t i = LCDML.MENU_getScroll(); 33 | uint8_t maxi = _LCDML_DISP_rows + i; 34 | uint8_t n = 0; 35 | 36 | // clear menu 37 | // *************** 38 | LCDML.DISP_clear(); 39 | 40 | // check if this element has children 41 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 42 | { 43 | // loop to display lines 44 | do 45 | { 46 | // check if a menu element has a condition and if the condition be true 47 | if (tmp->checkCondition()) 48 | { 49 | // check the type off a menu element 50 | if(tmp->checkType_menu() == true) 51 | { 52 | // display normal content 53 | LCDML_getContent(content_text, tmp->getID()); 54 | lcd.setCursor(1, n); 55 | lcd.print(content_text); 56 | } 57 | else 58 | { 59 | if(tmp->checkType_dynParam()) 60 | { 61 | tmp->callback(n); 62 | } 63 | } 64 | // increment some values 65 | i++; 66 | n++; 67 | } 68 | // try to go to the next sibling and check the number of displayed rows 69 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 70 | } 71 | 72 | 73 | } 74 | 75 | if(LCDML.DISP_checkMenuCursorUpdate()) 76 | { 77 | // init vars 78 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 79 | uint8_t scrollbar_min = 0; 80 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 81 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 82 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 83 | 84 | 85 | // display rows 86 | for (uint8_t n = 0; n < n_max; n++) 87 | { 88 | //set cursor 89 | lcd.setCursor(0, n); 90 | 91 | //set cursor char 92 | if (n == LCDML.MENU_getCursorPos()) { 93 | lcd.write(_LCDML_DISP_cfg_cursor); 94 | if(LCDML.MENU_checkDynRContent() == true) 95 | { 96 | LCDML.MENU_getDisplayedObj()->callback(n); 97 | } 98 | } else { 99 | lcd.write(' '); 100 | } 101 | 102 | // delete or reset scrollbar 103 | if (_LCDML_DISP_cfg_scrollbar == 1) { 104 | if (scrollbar_max > n_max) { 105 | lcd.setCursor((_LCDML_DISP_cols - 1), n); 106 | lcd.write((uint8_t)0); 107 | } 108 | else { 109 | lcd.setCursor((_LCDML_DISP_cols - 1), n); 110 | lcd.print(' '); 111 | } 112 | } 113 | } 114 | 115 | // display scrollbar 116 | if (_LCDML_DISP_cfg_scrollbar == 1) { 117 | if (scrollbar_max > n_max) { 118 | //set scroll position 119 | if (scrollbar_cur_pos == scrollbar_min) { 120 | // min pos 121 | lcd.setCursor((_LCDML_DISP_cols - 1), 0); 122 | lcd.write((uint8_t)1); 123 | } else if (scrollbar_cur_pos == (scrollbar_max - 1)) { 124 | // max pos 125 | lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1)); 126 | lcd.write((uint8_t)4); 127 | } else { 128 | // between 129 | lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max); 130 | lcd.write((uint8_t)(scroll_pos % n_max) + 1); 131 | } 132 | } 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03021_u8g2lib/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | 8 | /* ******************************************************************** */ 9 | void lcdml_menu_clear() 10 | /* ******************************************************************** */ 11 | { 12 | } 13 | 14 | /* ******************************************************************** */ 15 | void lcdml_menu_display() 16 | /* ******************************************************************** */ 17 | { 18 | // for first test set font here 19 | u8g2.setFont(_LCDML_DISP_font); 20 | 21 | // declaration of some variables 22 | // *************** 23 | // content variable 24 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 25 | // menu element object 26 | LCDMenuLib2_menu *tmp; 27 | // some limit values 28 | uint8_t i = LCDML.MENU_getScroll(); 29 | uint8_t maxi = _LCDML_DISP_rows + i; 30 | uint8_t n = 0; 31 | 32 | // init vars 33 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 34 | 35 | uint8_t scrollbar_min = 0; 36 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 37 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 38 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 39 | 40 | // generate content 41 | u8g2.firstPage(); 42 | do { 43 | 44 | 45 | n = 0; 46 | i = LCDML.MENU_getScroll(); 47 | // update content 48 | // *************** 49 | 50 | // clear menu 51 | // *************** 52 | 53 | // check if this element has children 54 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 55 | { 56 | // loop to display lines 57 | do 58 | { 59 | // check if a menu element has a condition and if the condition be true 60 | if (tmp->checkCondition()) 61 | { 62 | // check the type off a menu element 63 | if(tmp->checkType_menu() == true) 64 | { 65 | // display normal content 66 | LCDML_getContent(content_text, tmp->getID()); 67 | u8g2.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_font_w + _LCDML_DISP_cur_space_behind, _LCDML_DISP_box_y0 + _LCDML_DISP_font_h * (n + 1), content_text); 68 | } 69 | else 70 | { 71 | if(tmp->checkType_dynParam()) { 72 | tmp->callback(n); 73 | } 74 | } 75 | // increment some values 76 | i++; 77 | n++; 78 | } 79 | // try to go to the next sibling and check the number of displayed rows 80 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 81 | } 82 | 83 | // set cursor 84 | u8g2.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_cur_space_before, _LCDML_DISP_box_y0 + _LCDML_DISP_font_h * (LCDML.MENU_getCursorPos() + 1), _LCDML_DISP_cursor_char); 85 | 86 | if(_LCDML_DISP_draw_frame == 1) { 87 | u8g2.drawFrame(_LCDML_DISP_box_x0, _LCDML_DISP_box_y0, (_LCDML_DISP_box_x1-_LCDML_DISP_box_x0), (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)); 88 | } 89 | 90 | // display scrollbar when more content as rows available and with > 2 91 | if (scrollbar_max > n_max && _LCDML_DISP_scrollbar_w > 2) 92 | { 93 | // set frame for scrollbar 94 | u8g2.drawFrame(_LCDML_DISP_box_x1 - _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y0, _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y1-_LCDML_DISP_box_y0); 95 | 96 | // calculate scrollbar length 97 | uint8_t scrollbar_block_length = scrollbar_max - n_max; 98 | scrollbar_block_length = (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0) / (scrollbar_block_length + _LCDML_DISP_rows); 99 | 100 | //set scrollbar 101 | if (scrollbar_cur_pos == 0) { // top position (min) 102 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + 1 , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 103 | } 104 | else if (scrollbar_cur_pos == (scrollbar_max-1)) { // bottom position (max) 105 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y1 - scrollbar_block_length , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 106 | } 107 | else { // between top and bottom 108 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + (scrollbar_block_length * scrollbar_cur_pos + 1),(_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 109 | } 110 | } 111 | } while ( u8g2.nextPage() ); 112 | } 113 | -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03021_u8g2lib/PlaformIO/src/LCDML_display_menu.h: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | 8 | /* ******************************************************************** */ 9 | void lcdml_menu_clear() 10 | /* ******************************************************************** */ 11 | { 12 | } 13 | 14 | /* ******************************************************************** */ 15 | void lcdml_menu_display() 16 | /* ******************************************************************** */ 17 | { 18 | // for first test set font here 19 | u8g2.setFont(_LCDML_DISP_font); 20 | 21 | // declaration of some variables 22 | // *************** 23 | // content variable 24 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 25 | // menu element object 26 | LCDMenuLib2_menu *tmp; 27 | // some limit values 28 | uint8_t i = LCDML.MENU_getScroll(); 29 | uint8_t maxi = _LCDML_DISP_rows + i; 30 | uint8_t n = 0; 31 | 32 | // init vars 33 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 34 | 35 | //uint8_t scrollbar_min = 0; 36 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 37 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 38 | //uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 39 | 40 | // generate content 41 | u8g2.firstPage(); 42 | do { 43 | 44 | 45 | n = 0; 46 | i = LCDML.MENU_getScroll(); 47 | // update content 48 | // *************** 49 | 50 | // clear menu 51 | // *************** 52 | 53 | // check if this element has children 54 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 55 | { 56 | // loop to display lines 57 | do 58 | { 59 | // check if a menu element has a condition and if the condition be true 60 | if (tmp->checkCondition()) 61 | { 62 | // check the type off a menu element 63 | if(tmp->checkType_menu() == true) 64 | { 65 | // display normal content 66 | LCDML_getContent(content_text, tmp->getID()); 67 | u8g2.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_font_w + _LCDML_DISP_cur_space_behind, _LCDML_DISP_box_y0 + _LCDML_DISP_font_h * (n + 1), content_text); 68 | } 69 | else 70 | { 71 | if(tmp->checkType_dynParam()) { 72 | tmp->callback(n); 73 | } 74 | } 75 | // increment some values 76 | i++; 77 | n++; 78 | } 79 | // try to go to the next sibling and check the number of displayed rows 80 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 81 | } 82 | 83 | // set cursor 84 | u8g2.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_cur_space_before, _LCDML_DISP_box_y0 + _LCDML_DISP_font_h * (LCDML.MENU_getCursorPos() + 1), _LCDML_DISP_cursor_char); 85 | 86 | if(_LCDML_DISP_draw_frame == 1) { 87 | u8g2.drawFrame(_LCDML_DISP_box_x0, _LCDML_DISP_box_y0, (_LCDML_DISP_box_x1-_LCDML_DISP_box_x0), (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)); 88 | } 89 | 90 | // display scrollbar when more content as rows available and with > 2 91 | if (scrollbar_max > n_max && _LCDML_DISP_scrollbar_w > 2) 92 | { 93 | // set frame for scrollbar 94 | u8g2.drawFrame(_LCDML_DISP_box_x1 - _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y0, _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y1-_LCDML_DISP_box_y0); 95 | 96 | // calculate scrollbar length 97 | uint8_t scrollbar_block_length = scrollbar_max - n_max; 98 | scrollbar_block_length = (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0) / (scrollbar_block_length + _LCDML_DISP_rows); 99 | 100 | //set scrollbar 101 | if (scrollbar_cur_pos == 0) { // top position (min) 102 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + 1 , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 103 | } 104 | else if (scrollbar_cur_pos == (scrollbar_max-1)) { // bottom position (max) 105 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y1 - scrollbar_block_length , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 106 | } 107 | else { // between top and bottom 108 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + (scrollbar_block_length * scrollbar_cur_pos + 1),(_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 109 | } 110 | } 111 | } while ( u8g2.nextPage() ); 112 | } -------------------------------------------------------------------------------- /examples/03_displaytypes/03_gfx/LCDML_03032_adafruit_gfx_st7735/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | 8 | /* ******************************************************************** */ 9 | void lcdml_menu_clear() 10 | /* ******************************************************************** */ 11 | { 12 | } 13 | 14 | /* ******************************************************************** */ 15 | void lcdml_menu_display() 16 | /* ******************************************************************** */ 17 | { 18 | // clear lcd 19 | display.fillScreen(_LCDML_ADAFRUIT_BACKGROUND_COLOR); 20 | // set text color / Textfarbe setzen 21 | display.setTextColor(_LCDML_ADAFRUIT_TEXT_COLOR); 22 | // set text size / Textgroesse setzen 23 | display.setTextSize(_LCDML_ADAFRUIT_FONT_SIZE); 24 | 25 | 26 | // declaration of some variables 27 | // *************** 28 | // content variable 29 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 30 | // menu element object 31 | LCDMenuLib2_menu *tmp; 32 | // some limit values 33 | uint8_t i = LCDML.MENU_getScroll(); 34 | uint8_t maxi = _LCDML_DISP_rows + i; 35 | uint8_t n = 0; 36 | 37 | // init vars 38 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 39 | 40 | uint8_t scrollbar_min = 0; 41 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 42 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 43 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 44 | 45 | 46 | n = 0; 47 | i = LCDML.MENU_getScroll(); 48 | // update content 49 | // *************** 50 | 51 | // clear menu 52 | // *************** 53 | 54 | // check if this element has children 55 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 56 | { 57 | // loop to display lines 58 | do 59 | { 60 | // check if a menu element has a condition and if the condition be true 61 | if (tmp->checkCondition()) 62 | { 63 | // check the type off a menu element 64 | if(tmp->checkType_menu() == true) 65 | { 66 | // display normal content 67 | LCDML_getContent(content_text, tmp->getID()); 68 | display.setCursor(1, _LCDML_ADAFRUIT_FONT_H * (n)); 69 | display.println(content_text); 70 | } 71 | else 72 | { 73 | if(tmp->checkType_dynParam()) { 74 | tmp->callback(n); 75 | } 76 | } 77 | // increment some values 78 | i++; 79 | n++; 80 | } 81 | // try to go to the next sibling and check the number of displayed rows 82 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 83 | } 84 | 85 | // set cursor 86 | display.setCursor(0, _LCDML_ADAFRUIT_FONT_H * (LCDML.MENU_getCursorPos())); 87 | display.println("X"); 88 | 89 | // ***** todo ***** 90 | #ifdef _SCROLLBAR_TODO_ 91 | if(_LCDML_DISP_draw_frame == 1) { 92 | u8g2.drawFrame(_LCDML_DISP_box_x0, _LCDML_DISP_box_y0, (_LCDML_DISP_box_x1-_LCDML_DISP_box_x0), (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)); 93 | } 94 | 95 | 96 | // display scrollbar when more content as rows available and with > 2 97 | 98 | if (scrollbar_max > n_max && _LCDML_DISP_scrollbar_w > 2) 99 | { 100 | // set frame for scrollbar 101 | //u8g2.drawFrame(_LCDML_DISP_box_x1 - _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y0, _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y1-_LCDML_DISP_box_y0); 102 | display.drawRect(_LCDML_ADAFRUIT_lcd_w - _LCDML_ADAFRUIT_scrollbar_w, 0,_LCDML_ADAFRUIT_scrollbar_w,_LCDML_ADAFRUIT_lcd_h, _LCDML_ADAFRUIT_TEXT_COLOR); 103 | 104 | // calculate scrollbar length 105 | uint8_t scrollbar_block_length = scrollbar_max - n_max; 106 | scrollbar_block_length = (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0) / (scrollbar_block_length + _LCDML_DISP_rows); 107 | 108 | //set scrollbar 109 | if (scrollbar_cur_pos == 0) { // top position (min) 110 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + 1 , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 111 | } 112 | else if (scrollbar_cur_pos == (scrollbar_max-1)) { // bottom position (max) 113 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y1 - scrollbar_block_length , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 114 | } 115 | else { // between top and bottom 116 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + (scrollbar_block_length * scrollbar_cur_pos + 1),(_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 117 | } 118 | } 119 | #endif 120 | 121 | } 122 | -------------------------------------------------------------------------------- /examples/03_displaytypes/03_gfx/LCDML_03031_adafruit_gfx_ssd1306/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | 8 | /* ******************************************************************** */ 9 | void lcdml_menu_clear() 10 | /* ******************************************************************** */ 11 | { 12 | } 13 | 14 | /* ******************************************************************** */ 15 | void lcdml_menu_display() 16 | /* ******************************************************************** */ 17 | { 18 | // clear lcd 19 | display.clearDisplay(); 20 | // set text color / Textfarbe setzen 21 | display.setTextColor(_LCDML_ADAFRUIT_TEXT_COLOR); 22 | // set text size / Textgroesse setzen 23 | display.setTextSize(_LCDML_ADAFRUIT_FONT_SIZE); 24 | 25 | 26 | // declaration of some variables 27 | // *************** 28 | // content variable 29 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 30 | // menu element object 31 | LCDMenuLib2_menu *tmp; 32 | // some limit values 33 | uint8_t i = LCDML.MENU_getScroll(); 34 | uint8_t maxi = _LCDML_DISP_rows + i; 35 | uint8_t n = 0; 36 | 37 | // init vars 38 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 39 | 40 | uint8_t scrollbar_min = 0; 41 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 42 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 43 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 44 | 45 | 46 | n = 0; 47 | i = LCDML.MENU_getScroll(); 48 | // update content 49 | // *************** 50 | 51 | // clear menu 52 | // *************** 53 | 54 | // check if this element has children 55 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 56 | { 57 | // loop to display lines 58 | do 59 | { 60 | // check if a menu element has a condition and if the condition be true 61 | if (tmp->checkCondition()) 62 | { 63 | // check the type off a menu element 64 | if(tmp->checkType_menu() == true) 65 | { 66 | // display normal content 67 | LCDML_getContent(content_text, tmp->getID()); 68 | display.setCursor(0, _LCDML_ADAFRUIT_FONT_H * (n)); 69 | display.print(" "); 70 | display.println(content_text); 71 | } 72 | else 73 | { 74 | if(tmp->checkType_dynParam()) { 75 | tmp->callback(n); 76 | } 77 | } 78 | // increment some values 79 | i++; 80 | n++; 81 | } 82 | // try to go to the next sibling and check the number of displayed rows 83 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 84 | } 85 | 86 | // set cursor 87 | display.setCursor(0, _LCDML_ADAFRUIT_FONT_H * (LCDML.MENU_getCursorPos())); 88 | display.println(" >"); 89 | 90 | // ***** todo ***** 91 | #ifdef _SCROLLBAR_TODO_ 92 | if(_LCDML_DISP_draw_frame == 1) { 93 | u8g2.drawFrame(_LCDML_DISP_box_x0, _LCDML_DISP_box_y0, (_LCDML_DISP_box_x1-_LCDML_DISP_box_x0), (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)); 94 | } 95 | 96 | 97 | // display scrollbar when more content as rows available and with > 2 98 | 99 | if (scrollbar_max > n_max && _LCDML_DISP_scrollbar_w > 2) 100 | { 101 | // set frame for scrollbar 102 | //u8g2.drawFrame(_LCDML_DISP_box_x1 - _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y0, _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y1-_LCDML_DISP_box_y0); 103 | display.drawRect(_LCDML_ADAFRUIT_lcd_w - _LCDML_ADAFRUIT_scrollbar_w, 0,_LCDML_ADAFRUIT_scrollbar_w,_LCDML_ADAFRUIT_lcd_h, _LCDML_ADAFRUIT_TEXT_COLOR); 104 | 105 | // calculate scrollbar length 106 | uint8_t scrollbar_block_length = scrollbar_max - n_max; 107 | scrollbar_block_length = (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0) / (scrollbar_block_length + _LCDML_DISP_rows); 108 | 109 | //set scrollbar 110 | if (scrollbar_cur_pos == 0) { // top position (min) 111 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + 1 , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 112 | } 113 | else if (scrollbar_cur_pos == (scrollbar_max-1)) { // bottom position (max) 114 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y1 - scrollbar_block_length , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 115 | } 116 | else { // between top and bottom 117 | u8g2.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + (scrollbar_block_length * scrollbar_cur_pos + 1),(_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 118 | } 119 | } 120 | #endif 121 | 122 | display.display(); 123 | 124 | } 125 | -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_001_liquidCrystal/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | /* ******************************************************************** */ 8 | void lcdml_menu_clear() 9 | /* ******************************************************************** */ 10 | { 11 | lcd.clear(); 12 | lcd.setCursor(0, 0); 13 | } 14 | 15 | /* ******************************************************************** */ 16 | void lcdml_menu_display() 17 | /* ******************************************************************** */ 18 | { 19 | // update content 20 | // *************** 21 | if (LCDML.DISP_checkMenuUpdate()) { 22 | // clear menu 23 | // *************** 24 | LCDML.DISP_clear(); 25 | 26 | // declaration of some variables 27 | // *************** 28 | // content variable 29 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 30 | // menu element object 31 | LCDMenuLib2_menu *tmp; 32 | // some limit values 33 | uint8_t i = LCDML.MENU_getScroll(); 34 | uint8_t maxi = (_LCDML_DISP_rows - _LCDML_DSIP_use_header) + i; 35 | uint8_t n = 0; 36 | 37 | // Display a header with the parent element name 38 | if(_LCDML_DSIP_use_header > 0) 39 | { 40 | // only one line 41 | if(LCDML.MENU_getLayer() == 0) 42 | { 43 | // this text is displayed when no header is available 44 | lcd.setCursor(0,0); 45 | lcd.print(F("Root Menu")); 46 | } 47 | else 48 | { 49 | // Display parent name 50 | LCDML_getContent(content_text, LCDML.MENU_getParentID()); 51 | lcd.setCursor(0,0); 52 | lcd.print(content_text); 53 | } 54 | } 55 | 56 | // check if this element has children 57 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 58 | { 59 | // loop to display lines 60 | do 61 | { 62 | // check if a menu element has a condition and if the condition be true 63 | if (tmp->checkCondition()) 64 | { 65 | // check the type off a menu element 66 | if(tmp->checkType_menu() == true) 67 | { 68 | // display normal content 69 | LCDML_getContent(content_text, tmp->getID()); 70 | lcd.setCursor(1, (n+_LCDML_DSIP_use_header)); 71 | lcd.print(content_text); 72 | } 73 | else 74 | { 75 | if(tmp->checkType_dynParam()) { 76 | tmp->callback(n); 77 | } 78 | } 79 | // increment some values 80 | i++; 81 | n++; 82 | } 83 | // try to go to the next sibling and check the number of displayed rows 84 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 85 | } 86 | } 87 | 88 | if(LCDML.DISP_checkMenuCursorUpdate()) 89 | { 90 | // init vars 91 | uint8_t n_max = (LCDML.MENU_getChilds() >= (_LCDML_DISP_rows - _LCDML_DSIP_use_header)) ? (_LCDML_DISP_rows - _LCDML_DSIP_use_header) : (LCDML.MENU_getChilds()); 92 | uint8_t scrollbar_min = 0; 93 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 94 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 95 | uint8_t scroll_pos = ((1.*n_max * (_LCDML_DISP_rows - _LCDML_DSIP_use_header)) / (scrollbar_max - 1) * scrollbar_cur_pos); 96 | 97 | 98 | // display rows 99 | for (uint8_t n = 0; n < n_max; n++) 100 | { 101 | //set cursor 102 | lcd.setCursor(0, (n+_LCDML_DSIP_use_header)); 103 | 104 | //set cursor char 105 | if (n == LCDML.MENU_getCursorPos()) { 106 | lcd.write(_LCDML_DISP_cfg_cursor); 107 | } else { 108 | lcd.write(' '); 109 | } 110 | 111 | // delete or reset scrollbar 112 | if (_LCDML_DISP_cfg_scrollbar == 1) { 113 | if (scrollbar_max > n_max) { 114 | lcd.setCursor((_LCDML_DISP_cols - 1), (n+_LCDML_DSIP_use_header)); 115 | lcd.write((uint8_t)0); 116 | } 117 | else { 118 | lcd.setCursor((_LCDML_DISP_cols - 1), (n+_LCDML_DSIP_use_header)); 119 | lcd.print(' '); 120 | } 121 | } 122 | } 123 | 124 | // display scrollbar 125 | if (_LCDML_DISP_cfg_scrollbar == 1) { 126 | if (scrollbar_max > n_max) { 127 | //set scroll position 128 | if (scrollbar_cur_pos == scrollbar_min) { 129 | // min pos 130 | lcd.setCursor((_LCDML_DISP_cols - 1), (0+_LCDML_DSIP_use_header)); 131 | lcd.write((uint8_t)1); 132 | } else if (scrollbar_cur_pos == (scrollbar_max - 1)) { 133 | // max pos 134 | lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1 + _LCDML_DSIP_use_header)); 135 | lcd.write((uint8_t)4); 136 | } else { 137 | // between 138 | lcd.setCursor((_LCDML_DISP_cols - 1), (scroll_pos / n_max + _LCDML_DSIP_use_header)); 139 | lcd.write((uint8_t)(scroll_pos % n_max) + 1); 140 | } 141 | } 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /examples/03_displaytypes/02_glcd/LCDML_03022_u8glib/LCDML_display_menu.ino: -------------------------------------------------------------------------------- 1 | // ===================================================================== 2 | // 3 | // Output function 4 | // 5 | // ===================================================================== 6 | 7 | 8 | /* ******************************************************************** */ 9 | void lcdml_menu_clear() 10 | /* ******************************************************************** */ 11 | { 12 | } 13 | 14 | /* ******************************************************************** */ 15 | void lcdml_menu_display() 16 | /* ******************************************************************** */ 17 | { 18 | // for first test set font here 19 | u8g.setFont(_LCDML_DISP_font); 20 | //u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. 21 | 22 | // declaration of some variables 23 | // *************** 24 | // content variable 25 | char content_text[_LCDML_DISP_cols]; // save the content text of every menu element 26 | // menu element object 27 | LCDMenuLib2_menu *tmp; 28 | // some limit values 29 | uint8_t i = LCDML.MENU_getScroll(); 30 | uint8_t maxi = _LCDML_DISP_rows + i; 31 | uint8_t n = 0; 32 | 33 | // init vars 34 | uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds()); 35 | 36 | uint8_t scrollbar_min = 0; 37 | uint8_t scrollbar_max = LCDML.MENU_getChilds(); 38 | uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs(); 39 | uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos); 40 | 41 | 42 | // for first test set font here 43 | u8g.setFont(_LCDML_DISP_font); 44 | u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. 45 | 46 | 47 | // generate content 48 | u8g.firstPage(); 49 | do { 50 | 51 | 52 | n = 0; 53 | i = LCDML.MENU_getScroll(); 54 | // update content 55 | // *************** 56 | 57 | // clear menu 58 | // *************** 59 | 60 | // check if this element has children 61 | if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) 62 | { 63 | // loop to display lines 64 | do 65 | { 66 | // check if a menu element has a condition and if the condition be true 67 | if (tmp->checkCondition()) 68 | { 69 | // check the type off a menu element 70 | if(tmp->checkType_menu() == true) 71 | { 72 | // display normal content 73 | LCDML_getContent(content_text, tmp->getID()); 74 | u8g.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_font_w + _LCDML_DISP_cur_space_behind, _LCDML_DISP_box_y0 + _LCDML_DISP_font_h * (n + 1), content_text); 75 | } 76 | else 77 | { 78 | if(tmp->checkType_dynParam()) { 79 | tmp->callback(n); 80 | } 81 | } 82 | // increment some values 83 | i++; 84 | n++; 85 | } 86 | // try to go to the next sibling and check the number of displayed rows 87 | } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); 88 | } 89 | 90 | // set cursor 91 | u8g.drawStr( _LCDML_DISP_box_x0+_LCDML_DISP_cur_space_before, _LCDML_DISP_box_y0 + _LCDML_DISP_font_h * (LCDML.MENU_getCursorPos() + 1), _LCDML_DISP_cursor_char); 92 | 93 | if(_LCDML_DISP_draw_frame == 1) { 94 | u8g.drawFrame(_LCDML_DISP_box_x0, _LCDML_DISP_box_y0, (_LCDML_DISP_box_x1-_LCDML_DISP_box_x0), (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)); 95 | } 96 | 97 | // display scrollbar when more content as rows available and with > 2 98 | if (scrollbar_max > n_max && _LCDML_DISP_scrollbar_w > 2) 99 | { 100 | // set frame for scrollbar 101 | u8g.drawFrame(_LCDML_DISP_box_x1 - _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y0, _LCDML_DISP_scrollbar_w, _LCDML_DISP_box_y1-_LCDML_DISP_box_y0); 102 | 103 | // calculate scrollbar length 104 | uint8_t scrollbar_block_length = scrollbar_max - n_max; 105 | scrollbar_block_length = (_LCDML_DISP_box_y1-_LCDML_DISP_box_y0) / (scrollbar_block_length + _LCDML_DISP_rows); 106 | 107 | //set scrollbar 108 | if (scrollbar_cur_pos == 0) { // top position (min) 109 | u8g.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + 1 , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 110 | } 111 | else if (scrollbar_cur_pos == (scrollbar_max-1)) { // bottom position (max) 112 | u8g.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y1 - scrollbar_block_length , (_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 113 | } 114 | else { // between top and bottom 115 | u8g.drawBox(_LCDML_DISP_box_x1 - (_LCDML_DISP_scrollbar_w-1), _LCDML_DISP_box_y0 + (scrollbar_block_length * scrollbar_cur_pos + 1),(_LCDML_DISP_scrollbar_w-2) , scrollbar_block_length); 116 | } 117 | } 118 | } while ( u8g.nextPage() ); 119 | } 120 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_023_multiLanguage_small/LCDML_display_menuFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Menu Callback Function * 4 | * * 5 | * ===================================================================== * 6 | * 7 | * EXAMPLE CODE: 8 | 9 | // ********************************************************************* 10 | void your_function_name(uint8_t param) 11 | // ********************************************************************* 12 | { 13 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 14 | { 15 | // remmove compiler warnings when the param variable is not used: 16 | //LCDML_UNUSED(param); 17 | // setup 18 | // is called only if it is started 19 | 20 | // starts a trigger event for the loop function every 100 milliseconds 21 | LCDML.FUNC_setLoopInterval(100); 22 | 23 | // uncomment this line when the menu should go back to the last called position 24 | // this could be a cursor position or the an active menu function 25 | // GBA means => go back advanced 26 | //LCDML.FUNC_setGBA() 27 | 28 | // 29 | } 30 | 31 | if(LCDML.FUNC_loop()) // ****** LOOP ********* 32 | { 33 | // loop 34 | // is called when it is triggered 35 | // - with LCDML_DISP_triggerMenu( milliseconds ) 36 | // - with every button or event status change 37 | 38 | // uncomment this line when the screensaver should not be called when this function is running 39 | // reset screensaver timer 40 | //LCDML.SCREEN_resetTimer(); 41 | 42 | // check if any button is pressed (enter, up, down, left, right) 43 | if(LCDML.BT_checkAny()) { 44 | LCDML.FUNC_goBackToMenu(); 45 | } 46 | } 47 | 48 | if(LCDML.FUNC_close()) // ****** STABLE END ********* 49 | { 50 | // loop end 51 | // you can here reset some global vars or delete it 52 | // this function is always called when the functions ends. 53 | // this means when you are calling a jumpTo ore a goRoot function 54 | // that this part is called before a function is closed 55 | } 56 | } 57 | 58 | 59 | * ===================================================================== * 60 | */ 61 | 62 | 63 | // ********************************************************************* 64 | void mFunc_information(uint8_t param) 65 | // ********************************************************************* 66 | { 67 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 68 | { 69 | // remmove compiler warnings when the param variable is not used: 70 | LCDML_UNUSED(param); 71 | 72 | // setup function 73 | Serial.println(F("===========================================")); 74 | Serial.println(F("================ FUNC ====================")); 75 | Serial.println(F("===========================================")); 76 | 77 | switch(g_lcdml_lang_select) 78 | { 79 | case LANG_DE: // custom language long name 80 | Serial.println(F("Zum schlie\342en der")); 81 | Serial.println(F("Funktion, bitte druck")); 82 | Serial.println(F("irgendeine Taste oder")); 83 | Serial.println(F("den Zur\365ck Knopf")); 84 | break; 85 | 86 | default: 87 | Serial.println(F("To close this")); 88 | Serial.println(F("function press")); 89 | Serial.println(F("any button or use")); 90 | Serial.println(F("back button")); 91 | break; 92 | } 93 | 94 | 95 | } 96 | 97 | if(LCDML.FUNC_loop()) // ****** LOOP ********* 98 | { 99 | // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set 100 | // the quit button works in every DISP function without any checks; it starts the loop_end function 101 | if(LCDML.BT_checkAny()) { // check if any button is pressed (enter, up, down, left, right) 102 | // LCDML_goToMenu stops a running menu function and goes to the menu 103 | LCDML.FUNC_goBackToMenu(); 104 | } 105 | } 106 | 107 | if(LCDML.FUNC_close()) // ****** STABLE END ********* 108 | { 109 | // you can here reset some global vars or do nothing 110 | } 111 | } 112 | 113 | 114 | // ********************************************************************* 115 | void mFunc_switch_language(uint8_t param) 116 | // ********************************************************************* 117 | { 118 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 119 | { 120 | // remmove compiler warnings when the param variable is not used: 121 | LCDML_UNUSED(param); 122 | 123 | if(g_lcdml_lang_select == LANG_DE) 124 | { 125 | g_lcdml_lang_select = LANG_DEFAULT; 126 | } 127 | else 128 | { 129 | g_lcdml_lang_select = LANG_DE; 130 | } 131 | 132 | switch(g_lcdml_lang_select) 133 | { 134 | case LANG_DE: // custom language long name 135 | Serial.println(F("Sprache geändert")); 136 | break; 137 | 138 | default: 139 | Serial.println(F("wait 20 seconds or press back button")); 140 | break; 141 | } 142 | 143 | // go back 144 | LCDML.FUNC_goBackToMenu(); 145 | } 146 | 147 | 148 | if(LCDML.FUNC_loop()) // ****** LOOP ********* 149 | { 150 | // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set 151 | // the quit button works in every DISP function without any checks; it starts the loop_end function 152 | 153 | // not needed here 154 | } 155 | 156 | if(LCDML.FUNC_close()) // ****** STABLE END ********* 157 | { 158 | // you can here reset some global vars or do nothing 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_023_multiLanguage_small/LCDML_023_multiLanguage_small.ino: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: LCDML_multilanguage 3 | // ============================================================ 4 | // Description: 5 | // This example includes the complete functionality over some 6 | // tabs. All Tabs which are started with "LCDML_display_.." 7 | // generates an output on the display / console / .... 8 | // This example is for the author to test the complete functionality 9 | // 10 | // !!!! 11 | // Here are some diffcult parts, when something is not working in your code 12 | // look in this example and please read the comments 13 | // !!!! 14 | // ============================================================ 15 | // ********************************************************************* 16 | // special settings 17 | // ********************************************************************* 18 | // enable this line when you want to work only with ram 19 | //#define _LCDML_cfg_use_ram 20 | 21 | // enable this line when you are using an 32 bit processor 22 | //#define _LCDML_cfg_use_32bit_cpu 23 | 24 | // ********************************************************************* 25 | // includes 26 | // ********************************************************************* 27 | #include 28 | 29 | // ********************************************************************* 30 | // LCDML display settings 31 | // ********************************************************************* 32 | // settings for LCD 33 | #define _LCDML_DISP_cols 30 34 | #define _LCDML_DISP_rows 4 35 | 36 | // ********************************************************************* 37 | // Prototypes 38 | // ********************************************************************* 39 | void lcdml_menu_display(); 40 | void lcdml_menu_clear(); 41 | void lcdml_menu_control(); 42 | 43 | // ********************************************************************* 44 | // Objects 45 | // ********************************************************************* 46 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 47 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 48 | 49 | // ********************************************************************* 50 | // LCDML MENU/DISP 51 | // ********************************************************************* 52 | // LCDML_0 => layer 0 53 | // LCDML_0_X => layer 1 54 | // LCDML_0_X_X => layer 2 55 | // LCDML_0_X_X_X => layer 3 56 | // LCDML_0_... => layer ... 57 | 58 | // ********************************************************************* 59 | // LCDML MENU/DISP 60 | // ********************************************************************* 61 | // LCDML_0 => layer 0 62 | // LCDML_0_X => layer 1 63 | // LCDML_0_X_X => layer 2 64 | // LCDML_0_X_X_X => layer 3 65 | // LCDML_0_... => layer ... 66 | 67 | // For beginners 68 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 69 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 70 | // create a new language with a short name 71 | // parameter (id from the element above, short language name, string) 72 | LCDML_langDef (0, DE, "Information"); 73 | 74 | LCDML_add (1 , LCDML_0 , 2 , "Change Language" , mFunc_switch_language); // this menu function can be found on "LCDML_display_menuFunction" tab 75 | LCDML_langDef (1, DE, "Sprache umstellen"); 76 | 77 | LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function 78 | LCDML_langDef (2, DE, "Programm"); 79 | 80 | 81 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 82 | 83 | // menu element count - last element id 84 | // this value must be the same as the last menu element 85 | #define _LCDML_DISP_cnt 2 86 | 87 | // create menu 88 | LCDML_createMenu(_LCDML_DISP_cnt); 89 | 90 | // CREATE language types 91 | // the language definition here should not be the same like in the definition above 92 | // please write here "LANG_" before the short name 93 | // EN -> LANG_EN 94 | // DE -> LANG_DE 95 | // ... 96 | enum lang_types 97 | { 98 | LANG_DEFAULT = 0, // this value is every 0 99 | LANG_DE = 1 // the last element have no "," at the end 100 | // custom elements can be added 101 | }; 102 | 103 | // set the default language with the long name 104 | lang_types g_lcdml_lang_select = LANG_DEFAULT; 105 | //lang_types g_lcdml_lang_select = LANG_DE; 106 | 107 | // in the source code you can change the language with this line: 108 | // g_lcdml_lang_select = DEFAULT_LANG; 109 | // g_lcdml_lang_select = LANG_DE; 110 | // ... 111 | 112 | // create custom language with short name, not with the long name 113 | LCDML_createCustomLang(_LCDML_DISP_cnt, DE); 114 | 115 | // next step when you add a new language: 116 | // go into the LCDML_display_menu tab and change or add a switch case condition 117 | 118 | // next step: 119 | // change the menu function 120 | 121 | 122 | 123 | // ********************************************************************* 124 | // SETUP 125 | // ********************************************************************* 126 | void setup() 127 | { 128 | // serial init; only be needed if serial control is used 129 | Serial.begin(9600); // start serial 130 | Serial.println(F(_LCDML_VERSION)); // only for examples 131 | 132 | // LCDMenuLib Setup 133 | LCDML_setup(_LCDML_DISP_cnt); 134 | 135 | // Some settings which can be used 136 | 137 | // Enable Menu Rollover 138 | //LCDML.MENU_enRollover(); 139 | 140 | // Some needful methods 141 | 142 | // You can jump to a menu function from anywhere with 143 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 144 | } 145 | 146 | // ********************************************************************* 147 | // LOOP 148 | // ********************************************************************* 149 | void loop() 150 | { 151 | LCDML.loop(); 152 | } 153 | -------------------------------------------------------------------------------- /src/LCDMenuLib2_menu.h: -------------------------------------------------------------------------------- 1 | /* ****************************************************************************** 2 | * LCDMenuLib2 (LCDML) 3 | * ****************************************************************************** 4 | * 5 | * MIT License 6 | * 7 | * Copyright (c) [2025] [Nils Feldkämper] 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in all 17 | * copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * ****************************************************************************** 28 | * 29 | * BUG / ISSUES REPORTING 30 | * https://github.com/Jomelo/LCDMenuLib2/issues 31 | * 32 | * ARDUINO FORUM 33 | * http://forum.arduino.cc/index.php?topic=73816.0 34 | * 35 | * ****************************************************************************** 36 | */ 37 | 38 | #ifndef LCDMenuLib2_menu_h 39 | # define LCDMenuLib2_menu_h 40 | 41 | # include "Arduino.h" 42 | # include "LCDMenuLib2_typedef.h" 43 | 44 | // REG_control 45 | #define _LCDML_REG_MENU_CONTROL_condetion 7 46 | #define _LCDML_REG_MENU_CONTROL_free_6 6 47 | #define _LCDML_REG_MENU_CONTROL_free_5 5 48 | #define _LCDML_REG_MENU_CONTROL_free_4 4 49 | #define _LCDML_REG_MENU_CONTROL_type_dynParam_enable_custom_refresh 3 50 | #define _LCDML_REG_MENU_CONTROL_type_dynParam_enable_sub 2 51 | #define _LCDML_REG_MENU_CONTROL_type_dynParam 1 52 | #define _LCDML_REG_MENU_CONTROL_type_default 0 53 | 54 | // types for advanced menu function (this types are used by the menu element initialisation) 55 | #define _LCDML_TYPE_dynParam_enableCustomRefresh 10 //0b1010// setBit 1 & setBit 3 56 | #define _LCDML_TYPE_dynParam_enableSubMenus 6 //0b0110// setBit 1 & setBit 2 57 | #define _LCDML_TYPE_dynParam 2 //0b0010// setBit 1 58 | #define _LCDML_TYPE_default 1 //0b0000// setBit 0 59 | 60 | inline void LCDML_cb_default_function(uint8_t) { }; 61 | inline bool LCDML_cb_default_condetion(void) { return true; }; 62 | 63 | class LCDMenuLib2_menu 64 | { 65 | private: 66 | LCDMenuLib2_menu * parent; // Parent menu, NULL if this is the top 67 | LCDMenuLib2_menu * child; // First child menu, NULL if no children 68 | LCDMenuLib2_menu * sibling; // Next sibling menu, NULL if this is the last sibling 69 | 70 | LCDML_FuncPtr_pu8 cb_function; // Menu Function callback 71 | LCDML_FuncPtr_rb cb_condition; // Menu Condition callback 72 | 73 | void setParent(LCDMenuLib2_menu &p); // Sets the menu's parent to p 74 | void addSibling(LCDMenuLib2_menu &s,LCDMenuLib2_menu &p);// Adds a sibling s with parent p. If the menu already has a sibling, ask that sibling to add it 75 | 76 | uint8_t id; // Name of this menu 77 | uint8_t param; // parameter which can be set for this menu element 78 | uint8_t REG_control; // control register 79 | 80 | public: 81 | // Constructs the menu with a name and a NULL use function (be careful calling it) 82 | LCDMenuLib2_menu(uint8_t p_id, uint8_t p_param, uint8_t p_configuration, LCDML_FuncPtr_pu8 p_callback_function, LCDML_FuncPtr_rb p_callback_condition); 83 | 84 | LCDML_FuncPtr_pu8 getCbFunction(); 85 | 86 | void addChild(LCDMenuLib2_menu &c); // Adds the child c to the menu. 87 | // If the menu already has a child, ask the child to add it as a sibling 88 | LCDMenuLib2_menu * getChild(uint8_t which); // Returns a pointer to the which'th child of this menu 89 | LCDMenuLib2_menu * getSibling(uint8_t howfar); // Returns a pointer to the sibling how far siblings away from this menu 90 | LCDMenuLib2_menu * getParent(); // Returns this menu's parent menu. If no parent, returns itself 91 | 92 | uint8_t getID(void); // return the id of a menu element 93 | 94 | bool checkCondition(void); // check menu display condition 95 | void updateCondetion(void); // refrech the condetion callback 96 | 97 | uint8_t getParam(void); // return a parameter which is set on the initialization 98 | 99 | bool checkType_menu(void); // check menu type - normal menu function 100 | bool checkType_dynParam(void); // check menu type - dynamic menu function 101 | bool checkType_dynParam_enabledSubMenu(void); // check menu type - dynamic menu function with sub menus 102 | bool checkType_dynParam_enabledCustomRefresh(void); // check menu type - dynamic menu function with external custom refresh 103 | 104 | void callback(uint8_t p); // call menu callback 105 | }; 106 | #endif 107 | -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_024_condetions/LCDML_024_condetions.ino: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: LCDML_condetions 3 | // ============================================================ 4 | // Description: 5 | // ToDo 6 | // ============================================================ 7 | // ********************************************************************* 8 | // special settings 9 | // ********************************************************************* 10 | // enable this line when you want to work only with ram 11 | //#define _LCDML_cfg_use_ram 12 | 13 | // enable this line when you are using an 32 bit processor 14 | //#define _LCDML_cfg_use_32bit_cpu 15 | 16 | // ********************************************************************* 17 | // includes 18 | // ********************************************************************* 19 | #include 20 | 21 | // ********************************************************************* 22 | // LCDML display settings 23 | // ********************************************************************* 24 | // settings for LCD 25 | #define _LCDML_DISP_cols 20 26 | #define _LCDML_DISP_rows 4 27 | 28 | // enable this line (set to 1) to show a header above the first menu element 29 | // this function can be changed in LCDML_display_menu tab 30 | #define _LCDML_DSIP_use_header 0 31 | 32 | // ********************************************************************* 33 | // Prototypes 34 | // ********************************************************************* 35 | void lcdml_menu_display(); 36 | void lcdml_menu_clear(); 37 | void lcdml_menu_control(); 38 | 39 | // ********************************************************************* 40 | // Condetions 41 | // ********************************************************************* 42 | // global variable for condetion 43 | boolean g_condetion_a = true; 44 | // ********************************************************************* 45 | // Objects 46 | // ********************************************************************* 47 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 48 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows-_LCDML_DSIP_use_header, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 49 | 50 | // ********************************************************************* 51 | // LCDML MENU/DISP 52 | // ********************************************************************* 53 | // LCDML_0 => layer 0 54 | // LCDML_0_X => layer 1 55 | // LCDML_0_X_X => layer 2 56 | // LCDML_0_X_X_X => layer 3 57 | // LCDML_0_... => layer ... 58 | 59 | // For beginners 60 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 61 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 62 | LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 63 | LCDML_addAdvanced (2 , LCDML_0 , 3 , COND_a, "Condetion A" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function 64 | LCDML_add (3 , LCDML_0_3 , 1 , "Program 1" , NULL); // NULL = no menu function 65 | LCDML_add (4 , LCDML_0_3 , 2 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 66 | LCDML_addAdvanced (5 , LCDML_0 , 4 , COND_not_a, "Condetion B" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function 67 | LCDML_add (6 , LCDML_0_4 , 1 , "Program 2" , NULL); // this menu function can be found on "LCDML_display_menuFunction" tab 68 | LCDML_add (7 , LCDML_0_4 , 2 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 69 | 70 | // Example for dynamic content 71 | // 1. set the string to "" 72 | // 2. use type _LCDML_TYPE_dynParam instead of _LCDML_TYPE_default 73 | // this function type can not be used in combination with different parameters 74 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 75 | LCDML_addAdvanced (8 , LCDML_0 , 5 , NULL, "" , mDyn_change_condetion, 0, _LCDML_TYPE_dynParam); // NULL = no menu function 76 | 77 | // Example for conditions (for example for a screensaver) 78 | // 1. define a condition as a function of a boolean type -> return false = not displayed, return true = displayed 79 | // 2. set the function name as callback (remove the braces '()' it gives bad errors) 80 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 81 | LCDML_addAdvanced (9 , LCDML_0 , 6 , COND_hide, "screensaver" , mFunc_screensaver, 0, _LCDML_TYPE_default); // this menu function can be found on "LCDML_display_menuFunction" tab 82 | 83 | 84 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 85 | 86 | // menu element count - last element id 87 | // this value must be the same as the last menu element 88 | #define _LCDML_DISP_cnt 9 89 | 90 | // create menu 91 | LCDML_createMenu(_LCDML_DISP_cnt); 92 | 93 | // ********************************************************************* 94 | // SETUP 95 | // ********************************************************************* 96 | void setup() 97 | { 98 | // serial init; only be needed if serial control is used 99 | Serial.begin(9600); // start serial 100 | Serial.println(F(_LCDML_VERSION)); // only for examples 101 | 102 | // LCDMenuLib Setup 103 | LCDML_setup(_LCDML_DISP_cnt); 104 | 105 | // Some settings which can be used 106 | 107 | // Enable Menu Rollover 108 | //LCDML.MENU_enRollover(); 109 | 110 | // Enable Screensaver (screensaver menu function, time to activate in ms) 111 | //LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds 112 | //LCDML.SCREEN_disable(); 113 | 114 | // Some needful methods 115 | 116 | // You can jump to a menu function from anywhere with 117 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 118 | 119 | // In the following line the new event handling system ins configured 120 | // you can use 0 - 3 special events when calling the LCDML.CE_set(id) function 121 | // when you need more events you can change in LCDMenuLib.h the number until 0-63 122 | //LCDML.CE_setOnChangeCbFunction(0, mFunc_exampleEventHandling); 123 | //LCDML.CE_setOnChangeCbFunction(1, your_special_menu_function); 124 | //... 125 | 126 | } 127 | 128 | // ********************************************************************* 129 | // LOOP 130 | // ********************************************************************* 131 | void loop() 132 | { 133 | LCDML.loop(); 134 | } -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_024_condetions/LCDML_display_menuFunction.ino: -------------------------------------------------------------------------------- 1 | /* ===================================================================== * 2 | * * 3 | * Menu Callback Function * 4 | * * 5 | * ===================================================================== * 6 | * 7 | * EXAMPLE CODE: 8 | 9 | // ********************************************************************* 10 | void your_function_name(uint8_t param) 11 | // ********************************************************************* 12 | { 13 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 14 | { 15 | // remmove compiler warnings when the param variable is not used: 16 | //LCDML_UNUSED(param); 17 | // setup 18 | // is called only if it is started 19 | 20 | // starts a trigger event for the loop function every 100 milliseconds 21 | LCDML.FUNC_setLoopInterval(100); 22 | 23 | // uncomment this line when the menu should go back to the last called position 24 | // this could be a cursor position or the an active menu function 25 | // GBA means => go back advanced 26 | //LCDML.FUNC_setGBA() 27 | 28 | // 29 | } 30 | 31 | if(LCDML.FUNC_loop()) // ****** LOOP ********* 32 | { 33 | // loop 34 | // is called when it is triggered 35 | // - with LCDML_DISP_triggerMenu( milliseconds ) 36 | // - with every button or event status change 37 | 38 | // uncomment this line when the screensaver should not be called when this function is running 39 | // reset screensaver timer 40 | //LCDML.SCREEN_resetTimer(); 41 | 42 | // check if any button is pressed (enter, up, down, left, right) 43 | if(LCDML.BT_checkAny()) { 44 | LCDML.FUNC_goBackToMenu(); 45 | } 46 | } 47 | 48 | if(LCDML.FUNC_close()) // ****** STABLE END ********* 49 | { 50 | // loop end 51 | // you can here reset some global vars or delete it 52 | // this function is always called when the functions ends. 53 | // this means when you are calling a jumpTo ore a goRoot function 54 | // that this part is called before a function is closed 55 | } 56 | } 57 | 58 | 59 | * ===================================================================== * 60 | */ 61 | 62 | 63 | // ********************************************************************* 64 | void mFunc_information(uint8_t param) 65 | // ********************************************************************* 66 | { 67 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 68 | { 69 | // remmove compiler warnings when the param variable is not used: 70 | LCDML_UNUSED(param); 71 | 72 | // setup function 73 | Serial.println(F("===========================================")); 74 | Serial.println(F("================ FUNC ====================")); 75 | Serial.println(F("===========================================")); 76 | 77 | Serial.println(F("To close this")); 78 | Serial.println(F("function press")); 79 | Serial.println(F("any button or use")); 80 | Serial.println(F("back button")); 81 | } 82 | 83 | if(LCDML.FUNC_loop()) // ****** LOOP ********* 84 | { 85 | // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set 86 | // the quit button works in every DISP function without any checks; it starts the loop_end function 87 | if(LCDML.BT_checkAny()) { // check if any button is pressed (enter, up, down, left, right) 88 | // LCDML_goToMenu stops a running menu function and goes to the menu 89 | LCDML.FUNC_goBackToMenu(); 90 | } 91 | } 92 | 93 | if(LCDML.FUNC_close()) // ****** STABLE END ********* 94 | { 95 | // you can here reset some global vars or do nothing 96 | } 97 | } 98 | 99 | 100 | // ********************************************************************* 101 | uint8_t g_func_timer_info = 0; // time counter (global variable) 102 | unsigned long g_timer_1 = 0; // timer variable (global variable) 103 | void mFunc_timer_info(uint8_t param) 104 | // ********************************************************************* 105 | { 106 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 107 | { 108 | // remmove compiler warnings when the param variable is not used: 109 | LCDML_UNUSED(param); 110 | 111 | Serial.println(F("===========================================")); 112 | Serial.println(F("================ FUNC ====================")); 113 | Serial.println(F("===========================================")); 114 | Serial.println(F("wait 20 seconds or press back button")); 115 | g_func_timer_info = 20; // reset and set timer 116 | LCDML.FUNC_setLoopInterval(100); // starts a trigger event for the loop function every 100 milliseconds 117 | 118 | LCDML.TIMER_msReset(g_timer_1); 119 | } 120 | 121 | 122 | if(LCDML.FUNC_loop()) // ****** LOOP ********* 123 | { 124 | // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set 125 | // the quit button works in every DISP function without any checks; it starts the loop_end function 126 | 127 | // reset screensaver timer 128 | LCDML.SCREEN_resetTimer(); 129 | 130 | // this function is called every 100 milliseconds 131 | 132 | // this method checks every 1000 milliseconds if it is called 133 | if(LCDML.TIMER_ms(g_timer_1, 1000)) { 134 | g_func_timer_info--; // increment the value every second 135 | Serial.println(g_func_timer_info); // print the time counter value 136 | } 137 | 138 | // this function can only be ended when quit button is pressed or the time is over 139 | // check if the function ends normally 140 | if (g_func_timer_info <= 0) 141 | { 142 | // leave this function 143 | LCDML.FUNC_goBackToMenu(); 144 | } 145 | } 146 | 147 | if(LCDML.FUNC_close()) // ****** STABLE END ********* 148 | { 149 | // you can here reset some global vars or do nothing 150 | } 151 | } 152 | 153 | // ********************************************************************* 154 | void mFunc_back(uint8_t param) 155 | // ********************************************************************* 156 | { 157 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 158 | { 159 | // remmove compiler warnings when the param variable is not used: 160 | LCDML_UNUSED(param); 161 | 162 | // end function and go an layer back 163 | LCDML.FUNC_goBackToMenu(1); // leave this function 164 | } 165 | } 166 | 167 | 168 | // ********************************************************************* 169 | void mFunc_screensaver(uint8_t param) 170 | // ********************************************************************* 171 | { 172 | if(LCDML.FUNC_setup()) // ****** SETUP ********* 173 | { 174 | // remmove compiler warnings when the param variable is not used: 175 | LCDML_UNUSED(param); 176 | 177 | Serial.println(F("start screensaver")); 178 | Serial.println(F("press any key to quit")); 179 | LCDML.FUNC_setLoopInterval(100); // starts a trigger event for the loop function every 100 milliseconds 180 | } 181 | 182 | if(LCDML.FUNC_loop()) 183 | { 184 | if (LCDML.BT_checkAny()) // check if any button is pressed (enter, up, down, left, right) 185 | { 186 | LCDML.FUNC_goBackToMenu(); 187 | } 188 | } 189 | 190 | if(LCDML.FUNC_close()) 191 | { 192 | LCDML.MENU_goRoot(); 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /src/LCDMenuLib2_menu.cpp: -------------------------------------------------------------------------------- 1 | /* ****************************************************************************** 2 | * LCDMenuLib2 (LCDML) 3 | * ****************************************************************************** 4 | * 5 | * MIT License 6 | * 7 | * Copyright (c) [2025] [Nils Feldkämper] 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in all 17 | * copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * ****************************************************************************** 28 | * 29 | * BUG / ISSUES REPORTING 30 | * https://github.com/Jomelo/LCDMenuLib2/issues 31 | * 32 | * ARDUINO FORUM 33 | * http://forum.arduino.cc/index.php?topic=73816.0 34 | * 35 | * ****************************************************************************** 36 | */ 37 | 38 | #include "LCDMenuLib2_menu.h" 39 | #include "LCDMenuLib2_typedef.h" 40 | 41 | 42 | /* ******************************************************************** */ 43 | LCDMenuLib2_menu::LCDMenuLib2_menu(uint8_t p_id, uint8_t p_param, uint8_t p_configuration, LCDML_FuncPtr_pu8 p_callback_function, LCDML_FuncPtr_rb p_callback_condition) 44 | /* ******************************************************************** */ 45 | { 46 | parent = NULL; 47 | sibling = NULL; 48 | child = NULL; 49 | id = p_id; // element name 50 | param = p_param; // element configuration 51 | 52 | REG_control = p_configuration; 53 | 54 | if(p_callback_function == NULL) 55 | { 56 | cb_function = LCDML_cb_default_function; 57 | } 58 | else 59 | { 60 | cb_function = p_callback_function; 61 | } 62 | 63 | if(p_callback_condition == NULL) 64 | { 65 | cb_condition = LCDML_cb_default_condetion; 66 | } 67 | else 68 | { 69 | cb_condition = p_callback_condition; 70 | } 71 | 72 | // update some things 73 | updateCondetion(); 74 | } 75 | 76 | /* ******************************************************************** */ 77 | void LCDMenuLib2_menu::setParent(LCDMenuLib2_menu &p) 78 | /* ******************************************************************** */ 79 | { 80 | parent = &p; 81 | } 82 | 83 | /* ******************************************************************** */ 84 | void LCDMenuLib2_menu::addSibling(LCDMenuLib2_menu &s,LCDMenuLib2_menu &p) 85 | /* ******************************************************************** */ 86 | { 87 | if (sibling) 88 | { // add sibling if sibling exists 89 | sibling->addSibling(s,p); 90 | } 91 | else 92 | { // add sibling and parent 93 | sibling =& s; 94 | sibling->setParent(p); 95 | } 96 | } 97 | 98 | /* ******************************************************************** */ 99 | void LCDMenuLib2_menu::addChild(LCDMenuLib2_menu &c) 100 | /* ******************************************************************** */ 101 | { 102 | if (child) 103 | { // add sibling if child exists 104 | child->addSibling(c,*this); 105 | } 106 | else 107 | { // add child and parent 108 | child=&c; 109 | child->setParent(*this); 110 | } 111 | } 112 | 113 | /* ******************************************************************** */ 114 | LCDMenuLib2_menu * LCDMenuLib2_menu::getChild(uint8_t which) 115 | /* ******************************************************************** */ 116 | { 117 | if (child) 118 | { // return child if exists 119 | return child->getSibling(which); 120 | } 121 | else 122 | { // this menu item has no children 123 | return NULL; 124 | } 125 | } 126 | 127 | /* ******************************************************************** */ 128 | LCDMenuLib2_menu * LCDMenuLib2_menu::getSibling(uint8_t howfar) 129 | /* ******************************************************************** */ 130 | { 131 | if (howfar == 0) 132 | { // this sibling 133 | return this; 134 | } 135 | else if (sibling) 136 | { // get next sibling 137 | return sibling->getSibling(howfar - 1); 138 | } 139 | else 140 | { // asking for a nonexistent sibling 141 | return NULL; 142 | } 143 | } 144 | 145 | /* ******************************************************************** */ 146 | LCDMenuLib2_menu * LCDMenuLib2_menu::getParent() 147 | /* ******************************************************************** */ 148 | { 149 | if (parent) 150 | { // get parent if exists 151 | return parent; 152 | } 153 | else 154 | { // root menu 155 | return this; 156 | } 157 | } 158 | 159 | /* ******************************************************************** */ 160 | uint8_t LCDMenuLib2_menu::getID() 161 | /* ******************************************************************** */ 162 | { 163 | return id; 164 | } 165 | 166 | /* ******************************************************************** */ 167 | bool LCDMenuLib2_menu::checkCondition() 168 | /* ******************************************************************** */ 169 | { 170 | return bitRead(REG_control, _LCDML_REG_MENU_CONTROL_condetion); 171 | } 172 | 173 | /* ******************************************************************** */ 174 | void LCDMenuLib2_menu::updateCondetion() 175 | /* ******************************************************************** */ 176 | { 177 | if(cb_condition() == true) 178 | { 179 | bitSet(REG_control, _LCDML_REG_MENU_CONTROL_condetion); 180 | } 181 | else 182 | { 183 | bitClear(REG_control, _LCDML_REG_MENU_CONTROL_condetion); 184 | } 185 | } 186 | 187 | /* ******************************************************************** */ 188 | LCDML_FuncPtr_pu8 LCDMenuLib2_menu::getCbFunction() 189 | /* ******************************************************************** */ 190 | { 191 | return cb_function; 192 | } 193 | 194 | /* ******************************************************************** */ 195 | uint8_t LCDMenuLib2_menu::getParam() 196 | /* ******************************************************************** */ 197 | { 198 | return param; 199 | } 200 | 201 | /* ******************************************************************** */ 202 | void LCDMenuLib2_menu::callback(uint8_t p) 203 | /* ******************************************************************** */ 204 | { 205 | cb_function(p); 206 | } 207 | 208 | /* ******************************************************************** */ 209 | bool LCDMenuLib2_menu::checkType_menu() 210 | /* ******************************************************************** */ 211 | { 212 | return bitRead(REG_control, _LCDML_REG_MENU_CONTROL_type_default); 213 | } 214 | 215 | /* ******************************************************************** */ 216 | bool LCDMenuLib2_menu::checkType_dynParam() 217 | /* ******************************************************************** */ 218 | { 219 | return bitRead(REG_control, _LCDML_REG_MENU_CONTROL_type_dynParam); 220 | } 221 | 222 | /* ******************************************************************** */ 223 | bool LCDMenuLib2_menu::checkType_dynParam_enabledSubMenu() 224 | /* ******************************************************************** */ 225 | { 226 | return bitRead(REG_control, _LCDML_REG_MENU_CONTROL_type_dynParam); 227 | } 228 | 229 | /* ******************************************************************** */ 230 | bool LCDMenuLib2_menu::checkType_dynParam_enabledCustomRefresh() 231 | /* ******************************************************************** */ 232 | { 233 | return bitRead(REG_control, _LCDML_REG_MENU_CONTROL_type_dynParam_enable_custom_refresh); 234 | } 235 | 236 | -------------------------------------------------------------------------------- /examples/03_displaytypes/01_lcd/LCDML_03011_i2c_display_20x4/LCDML_03011_i2c_display_20x4.ino: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: DisplayType - I2C LiquidCrystal 3 | // ============================================================ 4 | // Description: 5 | // This example includes the complete functionality over some 6 | // tabs. All Tabs which are started with "LCDML_display_.." 7 | // generates an output on the display / console / .... 8 | // This example is for the author to test the complete functionality 9 | // ============================================================ 10 | // ********************************************************************* 11 | // special settings 12 | // ********************************************************************* 13 | // enable this line when you want to work only with ram 14 | //#define _LCDML_cfg_use_ram 15 | 16 | // enable this line when you are using an 32 bit processor 17 | //#define _LCDML_cfg_use_32bit_cpu 18 | 19 | // ********************************************************************* 20 | // includes 21 | // ********************************************************************* 22 | #include 23 | #include 24 | #include 25 | 26 | // ********************************************************************* 27 | // LCDML display settings 28 | // ********************************************************************* 29 | // settings for LCD 30 | #define _LCDML_DISP_cols 20 31 | #define _LCDML_DISP_rows 4 32 | 33 | #define _LCDML_DISP_cfg_cursor 0x7E // cursor Symbol 34 | #define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar 35 | 36 | // LCD object 37 | // for i2c there are many different steps for initialization, some are listed here 38 | // when the rows and cols are not set here, they have to be set in the setup 39 | //LiquidCrystal_I2C lcd(0x27); // Set the LCD I2C address 40 | //LiquidCrystal_I2C lcd(0x27, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address 41 | LiquidCrystal_I2C lcd(0x27,_LCDML_DISP_cols,_LCDML_DISP_rows); 42 | //LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address 43 | 44 | const uint8_t scroll_bar[5][8] = { 45 | {B10001, B10001, B10001, B10001, B10001, B10001, B10001, B10001}, // scrollbar top 46 | {B11111, B11111, B10001, B10001, B10001, B10001, B10001, B10001}, // scroll state 1 47 | {B10001, B10001, B11111, B11111, B10001, B10001, B10001, B10001}, // scroll state 2 48 | {B10001, B10001, B10001, B10001, B11111, B11111, B10001, B10001}, // scroll state 3 49 | {B10001, B10001, B10001, B10001, B10001, B10001, B11111, B11111} // scrollbar bottom 50 | }; 51 | 52 | // ********************************************************************* 53 | // Prototypes 54 | // ********************************************************************* 55 | void lcdml_menu_display(); 56 | void lcdml_menu_clear(); 57 | void lcdml_menu_control(); 58 | 59 | // ********************************************************************* 60 | // Global variables 61 | // ********************************************************************* 62 | 63 | 64 | // ********************************************************************* 65 | // Objects 66 | // ********************************************************************* 67 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 68 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 69 | 70 | // ********************************************************************* 71 | // LCDML MENU/DISP 72 | // ********************************************************************* 73 | // LCDML_0 => layer 0 74 | // LCDML_0_X => layer 1 75 | // LCDML_0_X_X => layer 2 76 | // LCDML_0_X_X_X => layer 3 77 | // LCDML_0_... => layer ... 78 | 79 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 80 | 81 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 82 | LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 83 | LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function 84 | LCDML_add (3 , LCDML_0_3 , 1 , "Program 1" , NULL); // NULL = no menu function 85 | LCDML_add (4 , LCDML_0_3_1 , 1 , "P1 dummy" , NULL); // NULL = no menu function 86 | LCDML_add (5 , LCDML_0_3_1 , 2 , "P1 Settings" , NULL); // NULL = no menu function 87 | LCDML_add (6 , LCDML_0_3_1_2 , 1 , "Warm" , NULL); // NULL = no menu function 88 | LCDML_add (7 , LCDML_0_3_1_2 , 2 , "Cold" , NULL); // NULL = no menu function 89 | LCDML_add (8 , LCDML_0_3_1_2 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 90 | LCDML_add (9 , LCDML_0_3_1 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 91 | LCDML_add (10 , LCDML_0_3 , 2 , "Program 2" , mFunc_p2); // this menu function can be found on "LCDML_display_menuFunction" tab 92 | LCDML_add (11 , LCDML_0_3 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 93 | LCDML_add (12 , LCDML_0 , 4 , "Special" , NULL); // NULL = no menu function 94 | LCDML_add (13 , LCDML_0_4 , 1 , "Go to Root" , mFunc_goToRootMenu); // this menu function can be found on "LCDML_display_menuFunction" tab 95 | LCDML_add (14 , LCDML_0_4 , 2 , "Jump to Time info", mFunc_jumpTo_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 96 | LCDML_add (15 , LCDML_0_4 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 97 | LCDML_add (16 , LCDML_0 , 5 , "Dummy B" , NULL); // NULL = no menu function 98 | LCDML_add (17 , LCDML_0 , 6 , "Screensaver" , mFunc_screensaver); // this menu function can be found on "LCDML_display_menuFunction" tab 99 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 100 | 101 | // menu element count - last element id 102 | // this value must be the same as the last menu element 103 | #define _LCDML_DISP_cnt 17 104 | 105 | // create menu 106 | LCDML_createMenu(_LCDML_DISP_cnt); 107 | 108 | // ********************************************************************* 109 | // SETUP 110 | // ********************************************************************* 111 | void setup() 112 | { 113 | // serial init; only be needed if serial control is used 114 | Serial.begin(9600); // start serial 115 | Serial.println(F(_LCDML_VERSION)); // only for examples 116 | 117 | // LCD Begin 118 | lcd.init(); 119 | lcd.backlight(); 120 | //lcd.begin(_LCDML_DISP_cols,_LCDML_DISP_rows); // some display types needs here the initialization 121 | 122 | 123 | // set special chars for scrollbar 124 | lcd.createChar(0, (uint8_t*)scroll_bar[0]); 125 | lcd.createChar(1, (uint8_t*)scroll_bar[1]); 126 | lcd.createChar(2, (uint8_t*)scroll_bar[2]); 127 | lcd.createChar(3, (uint8_t*)scroll_bar[3]); 128 | lcd.createChar(4, (uint8_t*)scroll_bar[4]); 129 | 130 | // LCDMenuLib Setup 131 | LCDML_setup(_LCDML_DISP_cnt); 132 | 133 | // Some settings which can be used 134 | 135 | // Enable Menu Rollover 136 | LCDML.MENU_enRollover(); 137 | 138 | // Enable Screensaver (screensaver menu function, time to activate in ms) 139 | LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds 140 | //LCDML.SCREEN_disable(); 141 | 142 | // Some needful methods 143 | 144 | // You can jump to a menu function from anywhere with 145 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 146 | } 147 | 148 | // ********************************************************************* 149 | // LOOP 150 | // ********************************************************************* 151 | void loop() 152 | { 153 | LCDML.loop(); 154 | } -------------------------------------------------------------------------------- /examples/02_functionality/LCDML_020_filelist/LCDML_020_filelist.ino: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: LCDML_dynamic_file_list 3 | // ============================================================ 4 | // Description: 5 | // This example includes the complete functionality over some 6 | // tabs. All Tabs which are started with "LCDML_display_.." 7 | // generates an output on the display / console / .... 8 | // This example is for the author to test the complete functionality 9 | // 10 | // This example shows how a dynamic file list can be added 11 | // Program->Program 1-> Filelist 12 | // ============================================================ 13 | // ********************************************************************* 14 | // special settings 15 | // ********************************************************************* 16 | // enable this line when you want to work only with ram 17 | //#define _LCDML_cfg_use_ram 18 | 19 | // enable this line when you are using an 32 bit processor 20 | //#define _LCDML_cfg_use_32bit_cpu 21 | 22 | // ********************************************************************* 23 | // includes 24 | // ********************************************************************* 25 | #include 26 | 27 | // ********************************************************************* 28 | // LCDML display settings 29 | // ********************************************************************* 30 | // settings for LCD 31 | #define _LCDML_DISP_cols 20 32 | #define _LCDML_DISP_rows 4 33 | 34 | // ********************************************************************* 35 | // Prototypes 36 | // ********************************************************************* 37 | void lcdml_menu_display(); 38 | void lcdml_menu_clear(); 39 | void lcdml_menu_control(); 40 | 41 | // ********************************************************************* 42 | // Objects 43 | // ********************************************************************* 44 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 45 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 46 | 47 | // ********************************************************************* 48 | // LCDML MENU/DISP 49 | // ********************************************************************* 50 | // LCDML_0 => layer 0 51 | // LCDML_0_X => layer 1 52 | // LCDML_0_X_X => layer 2 53 | // LCDML_0_X_X_X => layer 3 54 | // LCDML_0_... => layer ... 55 | 56 | // For beginners 57 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 58 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 59 | LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 60 | LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function 61 | LCDML_add (3 , LCDML_0_3 , 1 , "Program 1" , NULL); // NULL = no menu function 62 | LCDML_add (4 , LCDML_0_3_1 , 1 , "Filelist" , mFunc_filelist); // Add an filelist which can be scrolled 63 | LCDML_add (5 , LCDML_0_3_1 , 2 , "P1 Settings" , NULL); // NULL = no menu function 64 | LCDML_add (6 , LCDML_0_3_1_2 , 1 , "Warm" , NULL); // NULL = no menu function 65 | LCDML_add (7 , LCDML_0_3_1_2 , 2 , "Cold" , NULL); // NULL = no menu function 66 | LCDML_add (8 , LCDML_0_3_1_2 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 67 | LCDML_add (9 , LCDML_0_3_1 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 68 | LCDML_add (10 , LCDML_0_3 , 2 , "Program 2" , mFunc_p2); // this menu function can be found on "LCDML_display_menuFunction" tab 69 | LCDML_add (11 , LCDML_0_3 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 70 | LCDML_add (12 , LCDML_0 , 4 , "Special" , NULL); // NULL = no menu function 71 | LCDML_add (13 , LCDML_0_4 , 1 , "Go to Root" , mFunc_goToRootMenu); // this menu function can be found on "LCDML_display_menuFunction" tab 72 | LCDML_add (14 , LCDML_0_4 , 2 , "Jump to Time info", mFunc_jumpTo_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 73 | LCDML_add (15 , LCDML_0_4 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 74 | 75 | // Advanced menu (for profit) part with more settings 76 | // Example for one function and different parameters 77 | // It is recommend to use parameters for switching settings like, (small drink, medium drink, big drink) or (200ml, 400ml, 600ml, 800ml) ... 78 | // the parameter change can also be released with dynParams on the next example 79 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 80 | LCDML_addAdvanced (16 , LCDML_0 , 5 , NULL, "Parameter" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function 81 | LCDML_addAdvanced (17 , LCDML_0_5 , 1 , NULL, "Parameter 1" , mFunc_para, 10, _LCDML_TYPE_default); // NULL = no menu function 82 | LCDML_addAdvanced (18 , LCDML_0_5 , 2 , NULL, "Parameter 2" , mFunc_para, 20, _LCDML_TYPE_default); // NULL = no menu function 83 | LCDML_addAdvanced (19 , LCDML_0_5 , 3 , NULL, "Parameter 3" , mFunc_para, 30, _LCDML_TYPE_default); // NULL = no menu function 84 | LCDML_add (20 , LCDML_0_5 , 4 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 85 | 86 | 87 | // Example for dynamic content 88 | // 1. set the string to "" 89 | // 2. use type _LCDML_TYPE_dynParam instead of _LCDML_TYPE_default 90 | // this function type can not be used in combination with different parameters 91 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 92 | LCDML_addAdvanced (21 , LCDML_0 , 6 , NULL, "" , mDyn_para, 0, _LCDML_TYPE_dynParam); // NULL = no menu function 93 | 94 | // Example for conditions (for example for a screensaver) 95 | // 1. define a condition as a function of a boolean type -> return false = not displayed, return true = displayed 96 | // 2. set the function name as callback (remove the braces '()' it gives bad errors) 97 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 98 | LCDML_addAdvanced (22 , LCDML_0 , 7 , COND_hide, "screensaver" , mFunc_screensaver, 0, _LCDML_TYPE_default); // this menu function can be found on "LCDML_display_menuFunction" tab 99 | 100 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 101 | 102 | // menu element count - last element id 103 | // this value must be the same as the last menu element 104 | #define _LCDML_DISP_cnt 22 105 | 106 | // create menu 107 | LCDML_createMenu(_LCDML_DISP_cnt); 108 | 109 | // ********************************************************************* 110 | // SETUP 111 | // ********************************************************************* 112 | void setup() 113 | { 114 | // serial init; only be needed if serial control is used 115 | Serial.begin(9600); // start serial 116 | Serial.println(F(_LCDML_VERSION)); // only for examples 117 | 118 | // LCDMenuLib Setup 119 | LCDML_setup(_LCDML_DISP_cnt); 120 | 121 | // Some settings which can be used 122 | 123 | // Enable Menu Rollover 124 | //LCDML.MENU_enRollover(); 125 | 126 | // Enable Screensaver (screensaver menu function, time to activate in ms) 127 | LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds 128 | //LCDML.SCREEN_disable(); 129 | 130 | // Some needful methods 131 | 132 | // You can jump to a menu function from anywhere with 133 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 134 | } 135 | 136 | // ********************************************************************* 137 | // LOOP 138 | // ********************************************************************* 139 | void loop() 140 | { 141 | LCDML.loop(); 142 | } -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/LCDML_000_serialMonitor.ino: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: LCDML_serialmonitor 3 | // ============================================================ 4 | // Description: 5 | // This example includes the complete functionality over some 6 | // tabs. All Tabs which are started with "LCDML_display_.." 7 | // generates an output on the display / console / .... 8 | // This example is for the author to test the complete functionality 9 | // ============================================================ 10 | // ********************************************************************* 11 | // special settings 12 | // ********************************************************************* 13 | // enable this line when you want to work only with ram 14 | //#define _LCDML_cfg_use_ram 15 | 16 | // enable this line when you are using an 32 bit processor 17 | //#define _LCDML_cfg_use_32bit_cpu 18 | 19 | // ********************************************************************* 20 | // includes 21 | // ********************************************************************* 22 | #include 23 | 24 | // ********************************************************************* 25 | // LCDML display settings 26 | // ********************************************************************* 27 | // settings for LCD 28 | #define _LCDML_DISP_cols 20 29 | #define _LCDML_DISP_rows 4 30 | 31 | // enable this line (set to 1) to show a header above the first menu element 32 | // this function can be changed in LCDML_display_menu tab 33 | #define _LCDML_DSIP_use_header 0 34 | 35 | // ********************************************************************* 36 | // Prototypes 37 | // ********************************************************************* 38 | void lcdml_menu_display(); 39 | void lcdml_menu_clear(); 40 | void lcdml_menu_control(); 41 | 42 | // ********************************************************************* 43 | // Objects 44 | // ********************************************************************* 45 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 46 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows-_LCDML_DSIP_use_header, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 47 | 48 | // ********************************************************************* 49 | // LCDML MENU/DISP 50 | // ********************************************************************* 51 | // LCDML_0 => layer 0 52 | // LCDML_0_X => layer 1 53 | // LCDML_0_X_X => layer 2 54 | // LCDML_0_X_X_X => layer 3 55 | // LCDML_0_... => layer ... 56 | 57 | // For beginners 58 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 59 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 60 | LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 61 | LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function 62 | LCDML_add (3 , LCDML_0_3 , 1 , "Program 1" , NULL); // NULL = no menu function 63 | LCDML_add (4 , LCDML_0_3_1 , 1 , "P1 dummy" , NULL); // NULL = no menu function 64 | LCDML_add (5 , LCDML_0_3_1 , 2 , "P1 Settings" , NULL); // NULL = no menu function 65 | LCDML_add (6 , LCDML_0_3_1_2 , 1 , "Warm" , NULL); // NULL = no menu function 66 | LCDML_add (7 , LCDML_0_3_1_2 , 2 , "Cold" , NULL); // NULL = no menu function 67 | LCDML_add (8 , LCDML_0_3_1_2 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 68 | LCDML_add (9 , LCDML_0_3_1 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 69 | LCDML_add (10 , LCDML_0_3 , 2 , "Program 2" , mFunc_p2); // this menu function can be found on "LCDML_display_menuFunction" tab 70 | LCDML_add (11 , LCDML_0_3 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 71 | LCDML_add (12 , LCDML_0 , 4 , "Special" , NULL); // NULL = no menu function 72 | LCDML_add (13 , LCDML_0_4 , 1 , "Go to Root" , mFunc_goToRootMenu); // this menu function can be found on "LCDML_display_menuFunction" tab 73 | LCDML_add (14 , LCDML_0_4 , 2 , "Jump to Time info", mFunc_jumpTo_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 74 | LCDML_add (15 , LCDML_0_4 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 75 | 76 | // Advanced menu (for profit) part with more settings 77 | // Example for one function and different parameters 78 | // It is recommend to use parameters for switching settings like, (small drink, medium drink, big drink) or (200ml, 400ml, 600ml, 800ml) ... 79 | // the parameter change can also be released with dynParams on the next example 80 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 81 | LCDML_addAdvanced (16 , LCDML_0 , 5 , NULL, "Parameter" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function 82 | LCDML_addAdvanced (17 , LCDML_0_5 , 1 , NULL, "Parameter 1" , mFunc_para, 10, _LCDML_TYPE_default); // NULL = no menu function 83 | LCDML_addAdvanced (18 , LCDML_0_5 , 2 , NULL, "Parameter 2" , mFunc_para, 20, _LCDML_TYPE_default); // NULL = no menu function 84 | LCDML_addAdvanced (19 , LCDML_0_5 , 3 , NULL, "Parameter 3" , mFunc_para, 30, _LCDML_TYPE_default); // NULL = no menu function 85 | LCDML_add (20 , LCDML_0_5 , 4 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 86 | 87 | 88 | // Example for dynamic content 89 | // 1. set the string to "" 90 | // 2. use type _LCDML_TYPE_dynParam instead of _LCDML_TYPE_default 91 | // this function type can not be used in combination with different parameters 92 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 93 | LCDML_addAdvanced (21 , LCDML_0 , 6 , NULL, "" , mDyn_para, 0, _LCDML_TYPE_dynParam); // NULL = no menu function 94 | 95 | // Example for conditions (for example for a screensaver) 96 | // 1. define a condition as a function of a boolean type -> return false = not displayed, return true = displayed 97 | // 2. set the function name as callback (remove the braces '()' it gives bad errors) 98 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 99 | LCDML_addAdvanced (22 , LCDML_0 , 7 , COND_hide, "screensaver" , mFunc_screensaver, 0, _LCDML_TYPE_default); // this menu function can be found on "LCDML_display_menuFunction" tab 100 | 101 | // Example function for event handling (only serial output in this example) 102 | LCDML_add (23 , LCDML_0 , 8 , "Event Handling" , mFunc_exampleEventHandling); // this menu function can be found on "LCDML_display_menuFunction" tab 103 | 104 | 105 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 106 | 107 | // menu element count - last element id 108 | // this value must be the same as the last menu element 109 | #define _LCDML_DISP_cnt 23 110 | 111 | // create menu 112 | LCDML_createMenu(_LCDML_DISP_cnt); 113 | 114 | // ********************************************************************* 115 | // SETUP 116 | // ********************************************************************* 117 | void setup() 118 | { 119 | // serial init; only be needed if serial control is used 120 | Serial.begin(9600); // start serial 121 | Serial.println(F(_LCDML_VERSION)); // only for examples 122 | 123 | // LCDMenuLib Setup 124 | LCDML_setup(_LCDML_DISP_cnt); 125 | 126 | // Some settings which can be used 127 | 128 | // Enable Menu Rollover 129 | //LCDML.MENU_enRollover(); 130 | 131 | // Enable Screensaver (screensaver menu function, time to activate in ms) 132 | LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds 133 | //LCDML.SCREEN_disable(); 134 | 135 | // Some needful methods 136 | 137 | // You can jump to a menu function from anywhere with 138 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 139 | 140 | // In the following line the new event handling system ins configured 141 | // you can use 0 - 3 special events when calling the LCDML.CE_set(id) function 142 | // when you need more events you can change in LCDMenuLib.h the number until 0-63 143 | LCDML.CE_setOnChangeCbFunction(0, mFunc_exampleEventHandling); 144 | //LCDML.CE_setOnChangeCbFunction(1, your_special_menu_function); 145 | //... 146 | 147 | } 148 | 149 | // ********************************************************************* 150 | // LOOP 151 | // ********************************************************************* 152 | void loop() 153 | { 154 | LCDML.loop(); 155 | } -------------------------------------------------------------------------------- /examples/00_beginners/LCDML_000_serialMonitor/PlatformIO/src/main.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: LCDML_serialmonitor 3 | // ============================================================ 4 | // Description: 5 | // This example includes the complete functionality over some 6 | // tabs. All Tabs which are started with "LCDML_display_.." 7 | // generates an output on the display / console / .... 8 | // This example is for the author to test the complete functionality 9 | // ============================================================ 10 | // ********************************************************************* 11 | // special settings for non arduino basic controllers 12 | // ********************************************************************* 13 | // enable this line when you are not usigng a standard arduino 14 | // for example when your chip is an ESP or a STM or SAM or something else 15 | 16 | //#define _LCDML_cfg_use_ram 17 | 18 | // ********************************************************************* 19 | // includes 20 | // ********************************************************************* 21 | #include 22 | 23 | // ********************************************************************* 24 | // LCDML display settings 25 | // ********************************************************************* 26 | // settings for LCD 27 | #define _LCDML_DISP_cols 20 28 | #define _LCDML_DISP_rows 4 29 | 30 | // enable this line (set to 1) to show a header above the first menu element 31 | // this function can be changed in LCDML_display_menu tab 32 | #define _LCDML_DSIP_use_header 0 33 | 34 | // ********************************************************************* 35 | // Prototypes 36 | // ********************************************************************* 37 | void lcdml_menu_display(); 38 | void lcdml_menu_clear(); 39 | void lcdml_menu_control(); 40 | 41 | // ********************************************************************* 42 | // Objects 43 | // ********************************************************************* 44 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 45 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows-_LCDML_DSIP_use_header, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 46 | 47 | // ********************************************************************* 48 | // LCDML MENU/DISP 49 | // ********************************************************************* 50 | // LCDML_0 => layer 0 51 | // LCDML_0_X => layer 1 52 | // LCDML_0_X_X => layer 2 53 | // LCDML_0_X_X_X => layer 3 54 | // LCDML_0_... => layer ... 55 | 56 | // For beginners 57 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 58 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 59 | LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 60 | LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function 61 | LCDML_add (3 , LCDML_0_3 , 1 , "Program 1" , NULL); // NULL = no menu function 62 | LCDML_add (4 , LCDML_0_3_1 , 1 , "P1 dummy" , NULL); // NULL = no menu function 63 | LCDML_add (5 , LCDML_0_3_1 , 2 , "P1 Settings" , NULL); // NULL = no menu function 64 | LCDML_add (6 , LCDML_0_3_1_2 , 1 , "Warm" , NULL); // NULL = no menu function 65 | LCDML_add (7 , LCDML_0_3_1_2 , 2 , "Cold" , NULL); // NULL = no menu function 66 | LCDML_add (8 , LCDML_0_3_1_2 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 67 | LCDML_add (9 , LCDML_0_3_1 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 68 | LCDML_add (10 , LCDML_0_3 , 2 , "Program 2" , mFunc_p2); // this menu function can be found on "LCDML_display_menuFunction" tab 69 | LCDML_add (11 , LCDML_0_3 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 70 | LCDML_add (12 , LCDML_0 , 4 , "Special" , NULL); // NULL = no menu function 71 | LCDML_add (13 , LCDML_0_4 , 1 , "Go to Root" , mFunc_goToRootMenu); // this menu function can be found on "LCDML_display_menuFunction" tab 72 | LCDML_add (14 , LCDML_0_4 , 2 , "Jump to Time info", mFunc_jumpTo_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 73 | LCDML_add (15 , LCDML_0_4 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 74 | 75 | // Advanced menu (for profit) part with more settings 76 | // Example for one function and different parameters 77 | // It is recommend to use parameters for switching settings like, (small drink, medium drink, big drink) or (200ml, 400ml, 600ml, 800ml) ... 78 | // the parameter change can also be released with dynParams on the next example 79 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 80 | LCDML_addAdvanced (16 , LCDML_0 , 5 , NULL, "Parameter" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function 81 | LCDML_addAdvanced (17 , LCDML_0_5 , 1 , NULL, "Parameter 1" , mFunc_para, 10, _LCDML_TYPE_default); // NULL = no menu function 82 | LCDML_addAdvanced (18 , LCDML_0_5 , 2 , NULL, "Parameter 2" , mFunc_para, 20, _LCDML_TYPE_default); // NULL = no menu function 83 | LCDML_addAdvanced (19 , LCDML_0_5 , 3 , NULL, "Parameter 3" , mFunc_para, 30, _LCDML_TYPE_default); // NULL = no menu function 84 | LCDML_add (20 , LCDML_0_5 , 4 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 85 | 86 | 87 | // Example for dynamic content 88 | // 1. set the string to "" 89 | // 2. use type _LCDML_TYPE_dynParam instead of _LCDML_TYPE_default 90 | // this function type can not be used in combination with different parameters 91 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 92 | LCDML_addAdvanced (21 , LCDML_0 , 6 , NULL, "" , mDyn_para, 0, _LCDML_TYPE_dynParam); // NULL = no menu function 93 | 94 | // Example for conditions (for example for a screensaver) 95 | // 1. define a condition as a function of a boolean type -> return false = not displayed, return true = displayed 96 | // 2. set the function name as callback (remove the braces '()' it gives bad errors) 97 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 98 | LCDML_addAdvanced (22 , LCDML_0 , 7 , COND_hide, "screensaver" , mFunc_screensaver, 0, _LCDML_TYPE_default); // this menu function can be found on "LCDML_display_menuFunction" tab 99 | 100 | // Example function for event handling (only serial output in this example) 101 | LCDML_add (23 , LCDML_0 , 8 , "Event Handling" , mFunc_exampleEventHandling); // this menu function can be found on "LCDML_display_menuFunction" tab 102 | 103 | 104 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 105 | 106 | // menu element count - last element id 107 | // this value must be the same as the last menu element 108 | #define _LCDML_DISP_cnt 23 109 | 110 | // create menu 111 | LCDML_createMenu(_LCDML_DISP_cnt); 112 | 113 | // ********************************************************************* 114 | // SETUP 115 | // ********************************************************************* 116 | void setup() 117 | { 118 | // serial init; only be needed if serial control is used 119 | Serial.begin(9600); // start serial 120 | Serial.println(F(_LCDML_VERSION)); // only for examples 121 | 122 | // LCDMenuLib Setup 123 | LCDML_setup(_LCDML_DISP_cnt); 124 | 125 | // Some settings which can be used 126 | 127 | // Enable Menu Rollover 128 | //LCDML.MENU_enRollover(); 129 | 130 | // Enable Screensaver (screensaver menu function, time to activate in ms) 131 | LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds 132 | //LCDML.SCREEN_disable(); 133 | 134 | // Some needful methods 135 | 136 | // You can jump to a menu function from anywhere with 137 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 138 | 139 | // In the following line the new event handling system ins configured 140 | // you can use 0 - 3 special events when calling the LCDML.CE_set(id) function 141 | // when you need more events you can change in LCDMenuLib.h the number until 0-63 142 | LCDML.CE_setOnChangeCbFunction(0, mFunc_exampleEventHandling); 143 | //LCDML.CE_setOnChangeCbFunction(1, your_special_menu_function); 144 | //... 145 | 146 | } 147 | 148 | // ********************************************************************* 149 | // LOOP 150 | // ********************************************************************* 151 | void loop() 152 | { 153 | LCDML.loop(); 154 | } -------------------------------------------------------------------------------- /examples/01_backend/LCDML_011_TaskScheduler/LCDML_011_TaskScheduler.ino: -------------------------------------------------------------------------------- 1 | // ============================================================ 2 | // Example: LCDML_simpleThread example 3 | // ============================================================ 4 | // Description: 5 | // This example includes the complete functionality over some 6 | // tabs. All Tabs which are started with "LCDML_display_.." 7 | // generates an output on the display / console / .... 8 | // This example is for the author to test the complete functionality 9 | // 10 | // Add the TaskScheduler Libarary 11 | // 12 | // Download simple thread: 13 | // https://github.com/arkhipenko/TaskScheduler 14 | // 15 | // 16 | // ============================================================ 17 | // ********************************************************************* 18 | // special settings 19 | // ********************************************************************* 20 | // enable this line when you want to work only with ram 21 | //#define _LCDML_cfg_use_ram 22 | 23 | // enable this line when you are using an 32 bit processor 24 | //#define _LCDML_cfg_use_32bit_cpu 25 | 26 | // ********************************************************************* 27 | // includes 28 | // ********************************************************************* 29 | #include 30 | #include 31 | 32 | // ********************************************************************* 33 | // LCDML display settings 34 | // ********************************************************************* 35 | // settings for LCD 36 | #define _LCDML_DISP_cols 20 37 | #define _LCDML_DISP_rows 4 38 | 39 | // ********************************************************************* 40 | // Prototypes 41 | // ********************************************************************* 42 | void lcdml_menu_display(); 43 | void lcdml_menu_clear(); 44 | void lcdml_menu_control(); 45 | 46 | // ********************************************************************* 47 | // Objects 48 | // ********************************************************************* 49 | LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) 50 | LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); 51 | 52 | // ********************************************************************* 53 | // LCDML MENU/DISP 54 | // ********************************************************************* 55 | // LCDML_0 => layer 0 56 | // LCDML_0_X => layer 1 57 | // LCDML_0_X_X => layer 2 58 | // LCDML_0_X_X_X => layer 3 59 | // LCDML_0_... => layer ... 60 | 61 | // For beginners 62 | // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function) 63 | LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab 64 | LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 65 | LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function 66 | LCDML_add (3 , LCDML_0_3 , 1 , "Blink Thread" , NULL); // NULL = no menu function 67 | LCDML_add (4 , LCDML_0_3_1 , 1 , "Start Thread" , mFunc_thread_start); // Thread control (start) 68 | LCDML_add (5 , LCDML_0_3_1 , 2 , "Stop Thread" , mFunc_thread_stop); // Thread control (stop) 69 | LCDML_add (6 , LCDML_0_3_1_2 , 1 , "Warm" , NULL); // NULL = no menu function 70 | LCDML_add (7 , LCDML_0_3_1_2 , 2 , "Cold" , NULL); // NULL = no menu function 71 | LCDML_add (8 , LCDML_0_3_1_2 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 72 | LCDML_add (9 , LCDML_0_3_1 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 73 | LCDML_add (10 , LCDML_0_3 , 2 , "Program 2" , mFunc_p2); // this menu function can be found on "LCDML_display_menuFunction" tab 74 | LCDML_add (11 , LCDML_0_3 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 75 | LCDML_add (12 , LCDML_0 , 4 , "Special" , NULL); // NULL = no menu function 76 | LCDML_add (13 , LCDML_0_4 , 1 , "Go to Root" , mFunc_goToRootMenu); // this menu function can be found on "LCDML_display_menuFunction" tab 77 | LCDML_add (14 , LCDML_0_4 , 2 , "Jump to Time info", mFunc_jumpTo_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab 78 | LCDML_add (15 , LCDML_0_4 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 79 | 80 | // Advanced menu (for profit) part with more settings 81 | // Example for one function and different parameters 82 | // It is recommend to use parameters for switching settings like, (small drink, medium drink, big drink) or (200ml, 400ml, 600ml, 800ml) ... 83 | // the parameter change can also be released with dynParams on the next example 84 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 85 | LCDML_addAdvanced (16 , LCDML_0 , 5 , NULL, "Parameter" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function 86 | LCDML_addAdvanced (17 , LCDML_0_5 , 1 , NULL, "Parameter 1" , mFunc_para, 10, _LCDML_TYPE_default); // NULL = no menu function 87 | LCDML_addAdvanced (18 , LCDML_0_5 , 2 , NULL, "Parameter 2" , mFunc_para, 20, _LCDML_TYPE_default); // NULL = no menu function 88 | LCDML_addAdvanced (19 , LCDML_0_5 , 3 , NULL, "Parameter 3" , mFunc_para, 30, _LCDML_TYPE_default); // NULL = no menu function 89 | LCDML_add (20 , LCDML_0_5 , 4 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab 90 | 91 | 92 | // Example for dynamic content 93 | // 1. set the string to "" 94 | // 2. use type _LCDML_TYPE_dynParam instead of _LCDML_TYPE_default 95 | // this function type can not be used in combination with different parameters 96 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 97 | LCDML_addAdvanced (21 , LCDML_0 , 6 , NULL, "" , mDyn_para, 0, _LCDML_TYPE_dynParam); // NULL = no menu function 98 | 99 | // Example for conditions (for example for a screensaver) 100 | // 1. define a condition as a function of a boolean type -> return false = not displayed, return true = displayed 101 | // 2. set the function name as callback (remove the braces '()' it gives bad errors) 102 | // LCDMenuLib_addAdvanced(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type ) 103 | LCDML_addAdvanced (22 , LCDML_0 , 7 , COND_hide, "screensaver" , mFunc_screensaver, 0, _LCDML_TYPE_default); // this menu function can be found on "LCDML_display_menuFunction" tab 104 | 105 | // ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element. 106 | 107 | // menu element count - last element id 108 | // this value must be the same as the last menu element 109 | #define _LCDML_DISP_cnt 22 110 | 111 | // create menu 112 | LCDML_createMenu(_LCDML_DISP_cnt); 113 | 114 | 115 | // ********************************************************************* 116 | // Task Scheduler 117 | // ********************************************************************* 118 | 119 | // objects 120 | Scheduler r, hpr; 121 | 122 | // Callback methods prototypes 123 | void Task_input_check(); 124 | void Task_Serial_Blink_Example(); 125 | void Task_LCDMenuLib(); 126 | 127 | // Tasks 128 | Task t1(10, TASK_FOREVER, &Task_input_check, &r); //adding task to the chain on creation 129 | Task t2(1000, TASK_FOREVER, &Task_Serial_Blink_Example, &r); 130 | Task t3(100, TASK_FOREVER, &Task_LCDMenuLib, &r); 131 | 132 | 133 | 134 | 135 | 136 | // ********************************************************************* 137 | // SETUP 138 | // ********************************************************************* 139 | void setup() 140 | { 141 | // serial init; only be needed if serial control is used 142 | Serial.begin(9600); // start serial 143 | Serial.println(F(_LCDML_VERSION)); // only for examples 144 | 145 | // Enable input and LCDML Task 146 | t1.enable(); 147 | t3.enable(); 148 | 149 | // LCDMenuLib Setup 150 | LCDML_setup(_LCDML_DISP_cnt); 151 | 152 | // Some settings which can be used 153 | 154 | // Enable Menu Rollover 155 | //LCDML.MENU_enRollover(); 156 | 157 | // Enable Screensaver (screensaver menu function, time to activate in ms) 158 | LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds 159 | //LCDML.SCREEN_disable(); 160 | 161 | // Some needful methods 162 | 163 | // You can jump to a menu function from anywhere with 164 | //LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name 165 | } 166 | 167 | // ********************************************************************* 168 | // LOOP 169 | // ********************************************************************* 170 | void loop() 171 | { 172 | r.execute(); 173 | } --------------------------------------------------------------------------------