From 895db8c27ff1b342c0a7c9e7324eb194ab4c04ab Mon Sep 17 00:00:00 2001 From: Julio MATARRANZ Date: Tue, 27 Feb 2024 21:56:53 +0100 Subject: [PATCH] feat : disable/enable led on no display board --- platformio.ini | 3 ++- src/drivers/devices/esp32CAM.h | 3 +++ src/drivers/devices/esp32DevKit.h | 8 ++++++++ src/drivers/displays/noDisplayDriver.cpp | 11 ++++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 5a08d6d..d82a21b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -151,7 +151,8 @@ build_flags = -D DEVKITV1=1 -D PIN_BUTTON_1=0 -D LED_PIN=22 - ;-D DEBUG_MINING=1 + -D ACTIVE_LED=LOW + -D INACTIVE_LED=HIGH lib_deps = https://github.com/takkaO/OpenFontRender bblanchon/ArduinoJson@^6.21.2 diff --git a/src/drivers/devices/esp32CAM.h b/src/drivers/devices/esp32CAM.h index c8c1634..a2a0933 100644 --- a/src/drivers/devices/esp32CAM.h +++ b/src/drivers/devices/esp32CAM.h @@ -4,6 +4,9 @@ #define PIN_BUTTON_1 0 #define LED_PIN 33 +#define ACTIVE_LED HIGH +#define INACTIVE_LED LOW + #define NO_DISPLAY // example how to configure SD card. diff --git a/src/drivers/devices/esp32DevKit.h b/src/drivers/devices/esp32DevKit.h index b10aa61..324b46c 100644 --- a/src/drivers/devices/esp32DevKit.h +++ b/src/drivers/devices/esp32DevKit.h @@ -5,6 +5,14 @@ #define PIN_BUTTON_1 0 #endif +#ifndef ACTIVE_LED +#define ACTIVE_LED HIGH +#endif + +#ifndef INACTIVE_LED +#define INACTIVE_LED LOW +#endif + #ifndef LED_PIN #define LED_PIN 2 #endif diff --git a/src/drivers/displays/noDisplayDriver.cpp b/src/drivers/displays/noDisplayDriver.cpp index cc42812..d68d5ce 100644 --- a/src/drivers/displays/noDisplayDriver.cpp +++ b/src/drivers/displays/noDisplayDriver.cpp @@ -7,6 +7,7 @@ #include "wManager.h" extern monitor_data mMonitor; +bool ledOn = false; void noDisplay_Init(void) { @@ -16,6 +17,8 @@ void noDisplay_Init(void) void noDisplay_AlternateScreenState(void) { + Serial.println("Switching display state"); + ledOn = !ledOn; } void noDisplay_AlternateRotation(void) @@ -56,11 +59,17 @@ void noDisplay_DoLedStuff(unsigned long frame) { unsigned long currentMillis = millis(); + if (!ledOn) + { + digitalWrite(LED_PIN, INACTIVE_LED); + return; + } + switch (mMonitor.NerdStatus) { case NM_waitingConfig: - digitalWrite(LED_PIN, HIGH); // LED encendido de forma continua + digitalWrite(LED_PIN, ACTIVE_LED); // LED encendido de forma continua break; case NM_Connecting: