-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathSimpleInput.ino
56 lines (46 loc) · 1.21 KB
/
SimpleInput.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Simple Input
https://lcdmenu.forntoh.dev/examples/simple-input
*/
#include <ItemInput.h>
#include <LcdMenu.h>
#include <interface/LiquidCrystalI2CAdapter.h>
#include <utils/commandProccesors.h>
#define LCD_ROWS 2
#define LCD_COLS 16
// Configure keyboard keys (ASCII)
#define UP 56 // NUMPAD 8
#define DOWN 50 // NUMPAD 2
#define LEFT 52 // NUMPAD 4
#define RIGHT 54 // NUMPAD 6
#define ENTER 53 // NUMPAD 5
#define BACK 55 // NUMPAD 7
#define BACKSPACE 8 // BACKSPACE
#define CLEAR 46 // NUMPAD .
// Declare the call back function
void inputCallback(char* value);
MAIN_MENU(
ITEM_INPUT("Con", inputCallback),
ITEM_BASIC("Connect to WiFi"),
ITEM_BASIC("Blink SOS"),
ITEM_BASIC("Blink random")
);
LiquidCrystalI2CAdapter lcdAdapter(0x27, LCD_COLS, LCD_ROWS);
LcdMenu menu(lcdAdapter);
void setup() {
Serial.begin(9600);
menu.initialize(mainMenu);
}
void loop() {
if (!Serial.available()) return;
char command = Serial.read();
processMenuCommand(menu, command, UP, DOWN, LEFT, RIGHT, ENTER, BACK, CLEAR,
BACKSPACE);
}
/**
* Define callback
*/
void inputCallback(char* value) {
Serial.print(F("# "));
Serial.println(value);
}