code clean
This commit is contained in:
parent
f2bd3bab46
commit
67a676c320
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#define BEEP_PIN 2
|
||||||
|
|
||||||
inline void beepSet(const bool state) {
|
inline void beepSet(const bool state) {
|
||||||
digitalWrite(2, state ? HIGH : LOW);
|
digitalWrite(BEEP_PIN, state ? HIGH : LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void beepSetup() {
|
inline void beepSetup() {
|
||||||
pinMode(2,OUTPUT);
|
pinMode(BEEP_PIN,OUTPUT);
|
||||||
beepSet(false);
|
beepSet(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
32
src/main.cpp
32
src/main.cpp
@ -3,19 +3,16 @@
|
|||||||
#include "mode/Mode.h"
|
#include "mode/Mode.h"
|
||||||
#include "mode/ModeTimer.h"
|
#include "mode/ModeTimer.h"
|
||||||
|
|
||||||
|
void stepMode();
|
||||||
|
|
||||||
|
void readConsole();
|
||||||
|
|
||||||
|
void buttonCallback(ButtonEvent event);
|
||||||
|
|
||||||
Display display;
|
Display display;
|
||||||
|
|
||||||
ModeTimer mode;
|
ModeTimer mode;
|
||||||
|
|
||||||
void buttonCallback(const ButtonEvent event) {
|
|
||||||
if (event == BUTTON_PRESSED) {
|
|
||||||
mode.buttonOK();
|
|
||||||
}
|
|
||||||
if (BUTTON_PRESSED_LONG) {
|
|
||||||
mode.buttonESC();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button button(23, buttonCallback);
|
Button button(23, buttonCallback);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -29,14 +26,20 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
stepMode();
|
||||||
|
readConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
void stepMode() {
|
||||||
const uint64_t now = millis();
|
const uint64_t now = millis();
|
||||||
static uint64_t lastMillis = 0;
|
static uint64_t lastMillis = 0;
|
||||||
const uint64_t deltaMillis = now - lastMillis;
|
const uint64_t deltaMillis = now - lastMillis;
|
||||||
lastMillis = now;
|
lastMillis = now;
|
||||||
|
|
||||||
mode.step(deltaMillis);
|
mode.step(deltaMillis);
|
||||||
mode.draw(display);
|
mode.draw(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
void readConsole() {
|
||||||
const auto code = Serial.read();
|
const auto code = Serial.read();
|
||||||
if (code == ' ') {
|
if (code == ' ') {
|
||||||
mode.buttonOK();
|
mode.buttonOK();
|
||||||
@ -45,3 +48,12 @@ void loop() {
|
|||||||
mode.buttonESC();
|
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