MenuTimeout
1#include <LcdMenu.h>
2#include <MenuScreen.h>
3#include <display/LiquidCrystal_I2CAdapter.h>
4#include <input/KeyboardAdapter.h>
5#include <renderer/CharacterDisplayRenderer.h>
6
7#define LCD_ROWS 2
8#define LCD_COLS 16
9
10// clang-format off
11MENU_SCREEN(mainScreen, mainItems,
12 ITEM_BASIC("Start service"),
13 ITEM_BASIC("Connect to WiFi"),
14 ITEM_BASIC("Settings"),
15 ITEM_BASIC("Blink SOS"),
16 ITEM_BASIC("Blink random"));
17// clang-format on
18
19LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
20LiquidCrystal_I2CAdapter lcdAdapter(&lcd);
21CharacterDisplayRenderer renderer(&lcdAdapter, LCD_COLS, LCD_ROWS);
22LcdMenu menu(renderer);
23
24// Initialize the KeyboardAdapter
25KeyboardAdapter keyboard(&menu, &Serial);
26
27void setup() {
28 Serial.begin(9600);
29 renderer.begin();
30 menu.setScreen(mainScreen);
31}
32
33void loop() {
34 /**
35 * IMPORTANT: You must call this function for the timeout to work
36 * The default timeout is 10000ms
37 */
38 renderer.updateTimer();
39 keyboard.observe();
40}