-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the Arduino-1602-2004-LCD-menu wiki!
#include <Time.h>
//time library used for handling with datetime variables type
#include <TimeLib.h>
//time library used for handling with datetime variables type
#include <Wire.h>
//I2C communication library
#include <LiquidCrystal_I2C.h>
//LCD display library
#include "CMenu_I2C.h"
//Read the Menu library
const String On_label = "ON ";
//set on/off labels string for menu dialog
const String Off_label = "OFF";
//set on/off labels string for menu dialog
const String New_val = "Enter:";
//set input label string for menu dialog
const char t00[] PROGMEM = "Menu item 1";
const char t01[] PROGMEM = "Menu item 2";
const char t02[] PROGMEM = "Submenu item 1";
const char t03[] PROGMEM = "Event text";
const char* const tt[] PROGMEM = {t00, t01, t02, t03};
LiquidCrystal_I2C lcd(0x3f, 16, 2);
// Create instance of LiquidCrystal_I2C class. I2C address of the LCD display is 0x3f
Menu MyMenu;
void setup() {
lcd.init();
lcd.backlight();
MyMenu.begin(LCD_object, PROGMEM_text_table, refresh_time_[ms], sleep_time [s], off_time[min.] (255=off), LCD_columns, LCD_rows, date_format [1:DD.MM.YY, 0:MM.DD.YY], max_events [0..50])
MyMenu.begin(lcd, tt, 500, 30, 5, 16, 2, 1, 0);
Example: refresh_time = 500ms, sleep_time = 30 sec. (function Menu_Off is called), off_time = 5 min. (display is switched off), LCD have 16 columns, LCD have 2 rows, date_format is "DD.MM.YY", event table has 0 rows = not used
MyMenu.key_input(input_type[0:binary, 1:analog], analog_pin, pin_up, pin_down, pin_left, pin_right)
MyMenu.key_input(1, 1, 40, 160, 10, 250);
//analog keypad on A1 pin; up, down, left, right represents value on analog input pin when you press corresponding key on keypad [0-1024]
MyMenu.key_input(0, 0, 3, 4, 5, 2);
//digital keypad pins 3 up, 4 down, 5 left, 2 right
MyMenu.key_input(0, 0, 2, 3, 4, 4);
//rotary encoder pins 2 CLK, 3 DT, 4 SW
MyMenu.add_menu_item(parent_id, action_type, text_table_index, variable_pointer (optional), var_type (optional))
// For root menu: parent_id = -1
byte item1_id = MyMenu.add_menu_item(-1,0,0);
//creates menu item with text "Menu item 1" in the root menu level
byte item2_id = MyMenu.add_menu_item(-1,0,1);
//creates menu item with text "Menu item 2" in the root menu level
MyMenu.add_menu_item(item1_id,0,2);
//creates submenu of "Menu item 1" with text "Submenu item 1"
}
// setup section end
void Print2LCD() {
// function is called periodically when the menu is inactive (after 30 sec. since last key input - parameter of MyMenu.begin method)
lcd.clear();
lcd.setCursor(0,0);
lcd.print("LCD Text in sleep-mode");
}
void Menu_Off() {
// function is called when you exit menu (using back button or by inactivity).
}
void loop() {
MyMenu.draw();
}
MyMenu.add_event(unsigned long _event_time, byte _event_text_id, float event_var);
MyMenu.add_event(1557297120, 3, 532);
//creates event with time stamp 8. May 2019 6:32:00, description "Event text" and value 532
// time stamp is in standard unix time format (number of seconds since 1.1.1970 00:00:00)