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