Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add example
example for a dynamic menu for example a file list wich can be read from a sd card
- Loading branch information
Showing
6 changed files
with
822 additions
and
1 deletion.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
LCDMenuLib/examples/LCDML_006_dynamic_menu/LCDML_006_dynamic_menu.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// ============================================================ | ||
// | ||
// Example: LCDML_006_dynamnic_menu | ||
// | ||
// ============================================================ | ||
// This example shows you, how to generate a dynamic menu list | ||
// | ||
// ============================================================ | ||
|
||
// include libs | ||
#include <LiquidCrystal.h> | ||
#include <LCDMenuLib.h> | ||
|
||
// lib config | ||
#define _LCDML_DISP_cfg_button_press_time 200 // button press time in ms | ||
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar | ||
#define _LCDML_DISP_cfg_cursor 0x7E // cursor Symbol | ||
|
||
// ********************************************************************* | ||
// LCDML TYPE SELECT | ||
// ********************************************************************* | ||
// settings for lcd | ||
#define _LCDML_DISP_cols 20 | ||
#define _LCDML_DISP_rows 4 | ||
|
||
// lcd object | ||
// liquid crystal needs (rs, e, dat4, dat5, dat6, dat7) | ||
LiquidCrystal lcd(4,5,6,7,8,9); | ||
|
||
const uint8_t scroll_bar[5][8] = { | ||
{B10001, B10001, B10001, B10001, B10001, B10001, B10001, B10001}, // scrollbar top | ||
{B11111, B11111, B10001, B10001, B10001, B10001, B10001, B10001}, // scroll state 1 | ||
{B10001, B10001, B11111, B11111, B10001, B10001, B10001, B10001}, // scroll state 2 | ||
{B10001, B10001, B10001, B10001, B11111, B11111, B10001, B10001}, // scroll state 3 | ||
{B10001, B10001, B10001, B10001, B10001, B10001, B11111, B11111} // scrollbar bottom | ||
}; | ||
|
||
// ********************************************************************* | ||
// LCDML MENU/DISP | ||
// ********************************************************************* | ||
// create menu | ||
// menu element count - last element id | ||
// this value must be the same as the last menu element | ||
#define _LCDML_DISP_cnt 0 | ||
|
||
// LCDML_root => layer 0 | ||
// LCDML_root_X => layer 1 | ||
// LCDML_root_X_X => layer 2 | ||
// LCDML_root_X_X_X => layer 3 | ||
// LCDML_root_... => layer ... | ||
|
||
// LCDMenuLib_add(id, group, prev_layer_element, new_element_num, lang_char_array, callback_function) | ||
LCDML_DISP_init(_LCDML_DISP_cnt); | ||
LCDML_DISP_add (0 , _LCDML_G1 , LCDML_root , 1 , "Dyn Filelist" , LCDML_FUNC_dyn_filelist); | ||
LCDML_DISP_createMenu(_LCDML_DISP_cnt); | ||
|
||
|
||
|
||
// ********************************************************************* | ||
// LCDML BACKEND (core of the menu, do not change here anything yet) | ||
// ********************************************************************* | ||
// define backend function | ||
#define _LCDML_BACK_cnt 1 // last backend function id | ||
|
||
LCDML_BACK_init(_LCDML_BACK_cnt); | ||
LCDML_BACK_new_timebased_dynamic (0 , ( 20UL ) , _LCDML_start , LCDML_BACKEND_control); | ||
LCDML_BACK_new_timebased_dynamic (1 , ( 100000000UL ) , _LCDML_stop , LCDML_BACKEND_menu); | ||
LCDML_BACK_create(); | ||
|
||
|
||
// ********************************************************************* | ||
// SETUP | ||
// ********************************************************************* | ||
void setup() | ||
{ | ||
// serial init; only be needed if serial control is used | ||
while(!Serial); // wait until serial ready | ||
Serial.begin(9600); // start serial | ||
Serial.println(F(_LCDML_VERSION)); // only for examples | ||
|
||
// LCD Begin | ||
lcd.begin(_LCDML_DISP_cols,_LCDML_DISP_rows); | ||
// set special chars for scrollbar | ||
lcd.createChar(0, (uint8_t*)scroll_bar[0]); | ||
lcd.createChar(1, (uint8_t*)scroll_bar[1]); | ||
lcd.createChar(2, (uint8_t*)scroll_bar[2]); | ||
lcd.createChar(3, (uint8_t*)scroll_bar[3]); | ||
lcd.createChar(4, (uint8_t*)scroll_bar[4]); | ||
|
||
// Enable all items with _LCDML_G1 | ||
LCDML_DISP_groupEnable(_LCDML_G1); // enable group 1 | ||
|
||
// LCDMenu Setup | ||
LCDML_setup(_LCDML_BACK_cnt); | ||
} | ||
|
||
// ********************************************************************* | ||
// LOOP | ||
// ********************************************************************* | ||
void loop() | ||
{ | ||
// this function must called here, do not delete it | ||
LCDML_run(_LCDML_priority); | ||
} | ||
|
||
|
||
|
||
|
||
// ********************************************************************* | ||
// check some errors - do not change here anything | ||
// ********************************************************************* | ||
# if(_LCDML_DISP_rows > _LCDML_DISP_cfg_max_rows) | ||
# error change value of _LCDML_DISP_cfg_max_rows in LCDMenuLib.h | ||
# endif | ||
# if(_LCDML_DISP_cols > _LCDML_DISP_cfg_max_string_length) | ||
# error change value of _LCDML_DISP_cfg_max_string_length in LCDMenuLib.h | ||
# endif |
Oops, something went wrong.