1#include <ItemWidget.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#include <widget/WidgetRange.h>
8
9#define LCD_ROWS 2
10#define LCD_COLS 16
11
12// Declare the callbacks
13void callbackInt(int value);
14void callbackFloat(float value);
15
16// Initialize the main menu items
17// clang-format off
18MENU_SCREEN(mainScreen, mainItems,
19 ITEM_BASIC("Con"),
20 ITEM_WIDGET(
21 "Dist",
22 callbackInt,
23 WIDGET_RANGE(100, 1, 100, 200, "%dm", 1)),
24 ITEM_WIDGET(
25 "Curr",
26 callbackFloat,
27 WIDGET_RANGE(-1.0f, 0.01f, -1.0f, 1.0f, "%.2fmA", 2)),
28 ITEM_BASIC("Blink SOS"),
29 ITEM_BASIC("Blink random"));
30// clang-format on
31
32// Construct the LcdMenu
33LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
34CharacterDisplayRenderer renderer(new LiquidCrystal_I2CAdapter(&lcd), LCD_COLS, LCD_ROWS);
35LcdMenu menu(renderer);
36KeyboardAdapter keyboard(&menu, &Serial);
37
38void setup() {
39 Serial.begin(9600);
40 // Initialize LcdMenu with the menu items
41 renderer.begin();
42 menu.setScreen(mainScreen);
43}
44
45void loop() {
46 keyboard.observe();
47}
48
49void callbackInt(int value) {
50 // do something with the integer value
51 Serial.println(value);
52}
53
54void callbackFloat(float value) {
55 // do something with the float value
56 Serial.println(value);
57}