summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2023-10-11 10:19:46 +0200
committerJonas Smedegaard <dr@jones.dk>2023-10-11 10:45:26 +0200
commite8b5d5cb0840d3da931fe87b5e9b5cb3e3e77d5d (patch)
tree307aa38d74dd96e58bc76db6ecd6657bc87abc49
parent035db63e6f50b3f05fd332b82efec6b6c178444a (diff)
use BlinkControl
-rw-r--r--main.ino25
1 files changed, 10 insertions, 15 deletions
diff --git a/main.ino b/main.ino
index 571bfe0..88d132f 100644
--- a/main.ino
+++ b/main.ino
@@ -7,24 +7,22 @@
// https://github.com/Spirik/GEM
#include <EasyButton.h>
+#include <BlinkControl.h>
const int longpress_duration = 2000; // time in milliseconds
+// use built-in buttons and LEDs when possible
#if defined(ESP32)
// dirty hack: assume that any ESP32 board is a Lilygo T5 V2.2
#define LILYGO_T5_V22
-#endif
-
-// use built-in buttons and LEDs when possible
-#if defined(LILYGO_T5_V22)
#include "boards.h" // source: https://github.com/lewisxhe/GxEPD/blob/master/src/boards.h
const byte BUTTON_PIN_MOVE = BUTTON_1;
const byte BUTTON_PIN_SELECT = BUTTON_2;
-const int LED_PIN_STATUS = LED_PIN;
+BlinkControl led(LED_PIN);
#else
const byte BUTTON_PIN_MOVE = 2;
const byte BUTTON_PIN_SELECT = 3;
-const int LED_PIN_STATUS = LED_BUILTIN; // pin 13 is built-in LED on many Arduino boards
+BlinkControl led(LED_BUILTIN); // pin 13 is built-in LED on many Arduino boards
#endif
// serial port speed
@@ -46,30 +44,27 @@ void setup() {
button_move.onPressedFor(longpress_duration, onButtonMoveLongpressed);
button_select.onPressed(onButtonSelectPressed);
- // Emit actions on pin #3
- pinMode(LED_PIN_STATUS, OUTPUT);
+ led.begin();
+ led.breathe(2000);
}
void loop() {
+ led.loop();
button_move.read();
button_select.read();
}
void onButtonMovePressed() {
Serial.println("button MOVE clicked");
+ led.blink2();
}
void onButtonMoveLongpressed() {
Serial.println("button MOVE long-clicked");
+ led.off();
}
void onButtonSelectPressed() {
Serial.println("button SELECT clicked");
+ led.on();
}
-
-/*
-void blink() {
- state = !state;
- Serial.println(state);
-}
-*/