code clean

This commit is contained in:
Patrick Haßel 2025-08-07 11:04:23 +02:00
parent f2bd3bab46
commit 67a676c320
2 changed files with 26 additions and 12 deletions

View File

@ -3,12 +3,14 @@
#include <Arduino.h>
#define BEEP_PIN 2
inline void beepSet(const bool state) {
digitalWrite(2, state ? HIGH : LOW);
digitalWrite(BEEP_PIN, state ? HIGH : LOW);
}
inline void beepSetup() {
pinMode(2,OUTPUT);
pinMode(BEEP_PIN,OUTPUT);
beepSet(false);
}

View File

@ -3,19 +3,16 @@
#include "mode/Mode.h"
#include "mode/ModeTimer.h"
void stepMode();
void readConsole();
void buttonCallback(ButtonEvent event);
Display display;
ModeTimer mode;
void buttonCallback(const ButtonEvent event) {
if (event == BUTTON_PRESSED) {
mode.buttonOK();
}
if (BUTTON_PRESSED_LONG) {
mode.buttonESC();
}
}
Button button(23, buttonCallback);
void setup() {
@ -29,14 +26,20 @@ void setup() {
}
void loop() {
stepMode();
readConsole();
}
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();
@ -45,3 +48,12 @@ void loop() {
mode.buttonESC();
}
}
void buttonCallback(const ButtonEvent event) {
if (event == BUTTON_PRESSED) {
mode.buttonOK();
}
if (BUTTON_PRESSED_LONG) {
mode.buttonESC();
}
}