From 82d099fc8ea01e72811be67314cebf869111ce37 Mon Sep 17 00:00:00 2001 From: "rami.zayat9" Date: Mon, 28 Jul 2025 23:59:45 +0200 Subject: [PATCH 1/2] fixed ADA light Serial conditions for USB CDC (aka ESP32 C3 / S2 / S3 ) --- wled00/wled.cpp | 7 +++++++ wled00/wled_serial.cpp | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index c372d22abd..86d4cc02c3 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -453,8 +453,15 @@ void WLED::setup() findWiFi(true); // start scanning for available WiFi-s // all GPIOs are allocated at this point +#ifdef ARDUINO_USB_CDC_ON_BOOT + // USB CDC means USB D+ D- are used .. pin allocator will always return. force it as enabled instead + serialCanRX = true; + serialCanTX = true; +#else + // use RX/TX as set by the framework - these boards do _not_ have RX=3 and TX=1 serialCanRX = !PinManager::isPinAllocated(hardwareRX); // Serial RX pin (GPIO 3 on ESP32 and ESP8266) serialCanTX = !PinManager::isPinAllocated(hardwareTX) || PinManager::getPinOwner(hardwareTX) == PinOwner::DebugOut; // Serial TX pin (GPIO 1 on ESP32 and ESP8266) +#endif // ARDUINO_USB_CDC_ON_BOOT #ifdef WLED_ENABLE_ADALIGHT //Serial RX (Adalight, Improv, Serial JSON) only possible if GPIO3 unused diff --git a/wled00/wled_serial.cpp b/wled00/wled_serial.cpp index a0e59c531f..a6658dcf45 100644 --- a/wled00/wled_serial.cpp +++ b/wled00/wled_serial.cpp @@ -69,7 +69,9 @@ void sendBytes(){ void handleSerial() { - if (!(serialCanRX && Serial)) return; // arduino docs: `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all non-USB CDC ports, this will always return true + if (serialCanRX == false) { + return; + }; // arduino docs: `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all non-USB CDC ports, this will always return true static auto state = AdaState::Header_A; static uint16_t count = 0; From 48d698b682931a3ef7dc0dc601668f77d2799324 Mon Sep 17 00:00:00 2001 From: "rami.zayat9" Date: Tue, 29 Jul 2025 00:06:18 +0200 Subject: [PATCH 2/2] restored missing Serial condition --- wled00/wled_serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/wled_serial.cpp b/wled00/wled_serial.cpp index a6658dcf45..5d72a297db 100644 --- a/wled00/wled_serial.cpp +++ b/wled00/wled_serial.cpp @@ -69,7 +69,7 @@ void sendBytes(){ void handleSerial() { - if (serialCanRX == false) { + if (serialCanRX == false && Serial) { return; }; // arduino docs: `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all non-USB CDC ports, this will always return true