1#include <ItemRange.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
11// Declare the callbacks
12void callbackInt(const int value);
13void callbackFloat(const float value);
14
15// Initialize the main menu items
16// clang-format off
17MENU_SCREEN(mainScreen, mainItems,
18 ITEM_BASIC("Con"),
19 ITEM_RANGE("Dist", 100, 1, 100, 200, callbackInt, "%dm", 1, true),
20 ITEM_RANGE("Curr", -1.0f, 0.01f, -1.0f, 1.0f, callbackFloat, "%.2fmA", 2),
21 ITEM_BASIC("Blink SOS"),
22 ITEM_BASIC("Blink random"));
23// clang-format on
24
25// Construct the LcdMenu
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 // Initialize LcdMenu with the menu items
34 renderer.begin();
35 menu.setScreen(mainScreen);
36}
37
38void loop() {
39 keyboard.observe();
40}
41
42void callbackInt(const int value) {
43 // do something with the integer value
44 Serial.println(value);
45}
46
47void callbackFloat(const float value) {
48 // do something with the float value
49 Serial.println(value);
50}