58 lines
897 B
C++
58 lines
897 B
C++
#include "DisplayManager.h"
|
|
#include "SensorManager.h"
|
|
#include "Button.h"
|
|
#include "Menu.h"
|
|
|
|
DisplayManager display;
|
|
SensorManager sensor(7);
|
|
|
|
Button downButton(8);
|
|
Button upButton(9);
|
|
Button okButton(10);
|
|
Button backButton(11);
|
|
|
|
Menu menu;
|
|
|
|
void setup() {
|
|
display.begin();
|
|
sensor.begin();
|
|
|
|
upButton.begin();
|
|
downButton.begin();
|
|
okButton.begin();
|
|
backButton.begin();
|
|
}
|
|
|
|
void loop() {
|
|
unsigned long now = millis();
|
|
|
|
upButton.update(now);
|
|
downButton.update(now);
|
|
okButton.update(now);
|
|
backButton.update(now);
|
|
|
|
sensor.update(now);
|
|
|
|
if (upButton.pressed()) {
|
|
menu.prev();
|
|
}
|
|
|
|
if (downButton.pressed()) {
|
|
menu.next();
|
|
}
|
|
|
|
if (okButton.pressed()) {
|
|
menu.enter();
|
|
}
|
|
|
|
if(backButton.pressed()) {
|
|
menu.back();
|
|
}
|
|
|
|
if (display.ready(now)) {
|
|
display.showText(
|
|
String("> ") + menu.getCurrent(),
|
|
String(" ") + menu.getNext()
|
|
);
|
|
}
|
|
} |