Skip to content

Commit 82d099f

Browse files
committed
fixed ADA light Serial conditions for USB CDC (aka ESP32 C3 / S2 / S3 )
1 parent 591dbe3 commit 82d099f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

wled00/wled.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,15 @@ void WLED::setup()
453453
findWiFi(true); // start scanning for available WiFi-s
454454

455455
// all GPIOs are allocated at this point
456+
#ifdef ARDUINO_USB_CDC_ON_BOOT
457+
// USB CDC means USB D+ D- are used .. pin allocator will always return. force it as enabled instead
458+
serialCanRX = true;
459+
serialCanTX = true;
460+
#else
461+
// use RX/TX as set by the framework - these boards do _not_ have RX=3 and TX=1
456462
serialCanRX = !PinManager::isPinAllocated(hardwareRX); // Serial RX pin (GPIO 3 on ESP32 and ESP8266)
457463
serialCanTX = !PinManager::isPinAllocated(hardwareTX) || PinManager::getPinOwner(hardwareTX) == PinOwner::DebugOut; // Serial TX pin (GPIO 1 on ESP32 and ESP8266)
464+
#endif // ARDUINO_USB_CDC_ON_BOOT
458465

459466
#ifdef WLED_ENABLE_ADALIGHT
460467
//Serial RX (Adalight, Improv, Serial JSON) only possible if GPIO3 unused

wled00/wled_serial.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ void sendBytes(){
6969

7070
void handleSerial()
7171
{
72-
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
72+
if (serialCanRX == false) {
73+
return;
74+
}; // 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
7375

7476
static auto state = AdaState::Header_A;
7577
static uint16_t count = 0;

0 commit comments

Comments
 (0)