Set humidity and temperature with buttons
This commit is contained in:
43
drybox.ino
43
drybox.ino
@@ -3,13 +3,15 @@
|
||||
#include "Button.h"
|
||||
#include "Menu.h"
|
||||
|
||||
DisplayManager display;
|
||||
SensorManager sensor(7);
|
||||
#define FIRMWARE_VERSION "v0.1"
|
||||
|
||||
Button downButton(8);
|
||||
Button upButton(9);
|
||||
Button okButton(10);
|
||||
Button backButton(11);
|
||||
DisplayManager display;
|
||||
SensorManager sensor(10);
|
||||
|
||||
Button downButton(3);
|
||||
Button upButton(4);
|
||||
Button okButton(2);
|
||||
Button backButton(5);
|
||||
|
||||
Menu menu;
|
||||
|
||||
@@ -34,11 +36,11 @@ void loop() {
|
||||
sensor.update(now);
|
||||
|
||||
if (upButton.pressed()) {
|
||||
menu.prev();
|
||||
menu.next();
|
||||
}
|
||||
|
||||
if (downButton.pressed()) {
|
||||
menu.next();
|
||||
menu.prev();
|
||||
}
|
||||
|
||||
if (okButton.pressed()) {
|
||||
@@ -50,9 +52,26 @@ void loop() {
|
||||
}
|
||||
|
||||
if (display.ready(now)) {
|
||||
display.showText(
|
||||
String("> ") + menu.getCurrent(),
|
||||
String(" ") + menu.getNext()
|
||||
);
|
||||
if (menu.isEditing() && strcmp(menu.getCurrent(), "Temperature") == 0) {
|
||||
display.showText(
|
||||
"Set Temp",
|
||||
String(menu.getTargetTemperature()) + " C"
|
||||
);
|
||||
}
|
||||
|
||||
else if (menu.isEditing() && strcmp(menu.getCurrent(), "Humidity") == 0) {
|
||||
display.showText(
|
||||
"Set Humidity",
|
||||
String(menu.getTargetHumidity()) + " %"
|
||||
);
|
||||
}
|
||||
|
||||
else {
|
||||
display.showText(
|
||||
String("") + sensor.getTemp() + "C " + sensor.getHumidity() + "%",
|
||||
String("[") + menu.getCurrent() + String("] ")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user