From e3d9417b84dfac3e64b8634b78e3cd29ed3027de Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 14 Sep 2024 11:39:56 +0200 Subject: [PATCH] Minor fixes - rely on HAL for RO pins and max pins - remove isPinDefined() and do clash check inline - JS fix to use HAL max pins --- wled00/FX_fcn.cpp | 16 +++++++++++++--- wled00/const.h | 13 ------------- wled00/data/settings_leds.htm | 2 +- wled00/data/settings_um.htm | 12 ++++++------ wled00/pin_manager.cpp | 21 +++------------------ wled00/pin_manager.h | 1 - wled00/xml.cpp | 12 +----------- 7 files changed, 24 insertions(+), 53 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 447ceaab9..09b2ee517 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1256,18 +1256,28 @@ void WS2812FX::finalizeInit() { // When booting without config (1st boot) we need to make sure GPIOs defined for LED output don't clash with hardware // i.e. DEBUG (GPIO1), DMX (2), SPI RAM/FLASH (16&17 on ESP32-WROVER/PICO), read/only pins, etc. // Pin should not be already allocated, read/only or defined for current bus - while (pinManager.isPinAllocated(defPin[j]) || pinManager.isReadOnlyPin(defPin[j]) || pinManager.isPinDefined(defPin[j], defPin, j)) { + while (pinManager.isPinAllocated(defPin[j]) || !pinManager.isPinOk(defPin[j],true)) { if (validPin) { DEBUG_PRINTLN(F("Some of the provided pins cannot be used to configure this LED output.")); defPin[j] = 1; // start with GPIO1 and work upwards validPin = false; - } - if (defPin[j] < WLED_NUM_PINS) { + } else if (defPin[j] < WLED_NUM_PINS) { defPin[j]++; } else { DEBUG_PRINTLN(F("No available pins left! Can't configure output.")); return; } + // is the newly assigned pin already defined? try next in line until there are no clashes + bool clash; + do { + clash = false; + for (const auto pin : defDataPins) { + if (pin == defPin[j]) { + defPin[j]++; + if (defPin[j] < WLED_NUM_PINS) clash = true; + } + } + } while (clash); } } pinsIndex += busPins; diff --git a/wled00/const.h b/wled00/const.h index a0ebeebb1..47ec02c6a 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -567,19 +567,6 @@ #define WLED_MAX_NODES 150 #endif -// List of read only pins. Cannot be used for LED outputs. -#if defined(CONFIG_IDF_TARGET_ESP32S2) - #define READ_ONLY_PINS 46 -#elif defined(CONFIG_IDF_TARGET_ESP32S3) -// none for S3 -#elif defined(CONFIG_IDF_TARGET_ESP32C3) -// none for C3 -#elif defined(ESP32) - #define READ_ONLY_PINS 34,35,36,37,38,39 -#else -// none for ESP8266 -#endif - #ifdef WLED_ENABLE_DMX #if (LEDPIN == 2) #undef LEDPIN diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index b3188f0d8..206d4a8c7 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -671,7 +671,7 @@ Swap: