65 lines
1.0 KiB
C++
65 lines
1.0 KiB
C++
#include "Button.h"
|
|
#include "server.h"
|
|
#include "wifi.h"
|
|
#include "mode/Mode.h"
|
|
#include "mode/ModeTimer.h"
|
|
|
|
void stepMode();
|
|
|
|
void readConsole();
|
|
|
|
void buttonCallback(ButtonEvent event);
|
|
|
|
Display display;
|
|
|
|
ModeTimer mode;
|
|
|
|
Button button(23, buttonCallback);
|
|
|
|
void setup() {
|
|
delay(500);
|
|
Serial.begin(115200);
|
|
Serial.println("\n\n\nStartup!");
|
|
|
|
beepSetup();
|
|
button.setup();
|
|
display.setup();
|
|
mode.init();
|
|
serverSetup();
|
|
}
|
|
|
|
void loop() {
|
|
stepMode();
|
|
readConsole();
|
|
wifiLoop();
|
|
button.loop();
|
|
}
|
|
|
|
void stepMode() {
|
|
const uint64_t now = millis();
|
|
static uint64_t lastMillis = 0;
|
|
const uint64_t deltaMillis = now - lastMillis;
|
|
lastMillis = now;
|
|
mode.step(deltaMillis);
|
|
mode.draw(display);
|
|
}
|
|
|
|
void readConsole() {
|
|
const auto code = Serial.read();
|
|
if (code == ' ') {
|
|
mode.buttonOK();
|
|
}
|
|
if (code == 'x') {
|
|
mode.buttonESC();
|
|
}
|
|
}
|
|
|
|
void buttonCallback(const ButtonEvent event) {
|
|
if (event == BUTTON_PRESSED) {
|
|
mode.buttonOK();
|
|
}
|
|
if (event == BUTTON_PRESSED_LONG) {
|
|
mode.buttonESC();
|
|
}
|
|
}
|