1#include <ItemInput.h>
2#include <ItemInputCharset.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
12// Create your charset
13const char* charset = "0123456789";
14
15// Declare the call back function
16void inputCallback(char* value);
17
18// clang-format off
19MENU_SCREEN(mainScreen, mainItems,
20 ITEM_INPUT_CHARSET("Con", "0123456", charset, inputCallback),
21 ITEM_BASIC("Connect to WiFi"),
22 ITEM_BASIC("Blink SOS"),
23 ITEM_BASIC("Blink random"));
24// clang-format on
25
26LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
27CharacterDisplayRenderer renderer(new LiquidCrystal_I2CAdapter(&lcd), LCD_COLS, LCD_ROWS);
28LcdMenu menu(renderer);
29KeyboardAdapter keyboard(&menu, &Serial);
30
31void setup() {
32 Serial.begin(9600);
33 renderer.begin();
34 menu.setScreen(mainScreen);
35}
36
37void loop() {
38 keyboard.observe();
39}
40/**
41 * Define callback
42 */
43void inputCallback(char* value) {
44 // Do stuff with value
45 Serial.print(F("# "));
46 Serial.println(value);
47}