ItemBack

 1#include <ItemBack.h>
 2#include <ItemSubMenu.h>
 3#include <LcdMenu.h>
 4#include <MenuScreen.h>
 5#include <display/LiquidCrystal_I2CAdapter.h>
 6#include <input/KeyboardAdapter.h>
 7#include <renderer/CharacterDisplayRenderer.h>
 8
 9#define LCD_ROWS 2
10#define LCD_COLS 16
11
12extern MenuScreen* settingsScreen;
13
14// Define the main menu
15// clang-format off
16MENU_SCREEN(mainScreen, mainItems,
17    ITEM_BASIC("Start service"),
18    ITEM_BASIC("Connect to WiFi"),
19    ITEM_SUBMENU("Settings", settingsScreen),
20    ITEM_BASIC("Blink SOS"),
21    ITEM_BASIC("Blink random"));
22
23// Create submenu and precise its parent
24MENU_SCREEN(settingsScreen, settingsItems,
25    ITEM_BASIC("Backlight"),
26    ITEM_BASIC("Contrast"),
27    ITEM_BACK());
28// clang-format on
29
30LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
31CharacterDisplayRenderer renderer(new LiquidCrystal_I2CAdapter(&lcd), LCD_COLS, LCD_ROWS);
32LcdMenu menu(renderer);
33
34// Initialize the KeyboardAdapter
35KeyboardAdapter keyboard(&menu, &Serial);
36
37void setup() {
38    Serial.begin(9600);
39    renderer.begin();
40    menu.setScreen(mainScreen);
41}
42
43void loop() {
44    keyboard.observe();
45}