From e8b5d5cb0840d3da931fe87b5e9b5cb3e3e77d5d Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 11 Oct 2023 10:19:46 +0200 Subject: use BlinkControl --- main.ino | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'main.ino') 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 +#include 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); -} -*/ -- cgit v1.2.3