code clean
This commit is contained in:
parent
f2bd3bab46
commit
67a676c320
@ -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);
|
||||
}
|
||||
|
||||
|
||||
32
src/main.cpp
32
src/main.cpp
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user