mirror of
https://github.com/wled/WLED.git
synced 2025-07-27 12:46:38 +00:00
bug fix on pin already defined check
This commit is contained in:
parent
c5435ec1fa
commit
daf0bcfac3
@ -1248,15 +1248,16 @@ void WS2812FX::finalizeInit(void) {
|
|||||||
// if we need more pins than available all outputs have been configured
|
// if we need more pins than available all outputs have been configured
|
||||||
if (pinsIndex + busPins > defNumPins) break;
|
if (pinsIndex + busPins > defNumPins) break;
|
||||||
|
|
||||||
for (unsigned j = 0; j < busPins && j < OUTPUT_MAX_PINS; j++) {
|
// Assign all pins first so we can check for conflicts on this bus
|
||||||
defPin[j] = defDataPins[pinsIndex + j];
|
for (unsigned j = 0; j < busPins && j < OUTPUT_MAX_PINS; j++) defPin[j] = defDataPins[pinsIndex + j];
|
||||||
|
|
||||||
|
for (unsigned j = 0; j < busPins && j < OUTPUT_MAX_PINS; j++) {
|
||||||
bool validPin = true;
|
bool validPin = true;
|
||||||
// When booting without config (1st boot) we need to make sure GPIOs defined for LED output don't clash with hardware
|
// 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.
|
// 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
|
// Pin should not be already allocated, read/only or defined for current bus
|
||||||
while (pinManager.isPinAllocated(defPin[j]) || pinManager.isReadOnlyPin(defPin[j]) ||
|
while (pinManager.isPinAllocated(defPin[j]) || pinManager.isReadOnlyPin(defPin[j]) || pinManager.isPinDefined(defPin[j], defPin, j)) {
|
||||||
pinManager.isPinDefined(defPin[j], defDataPins, pinsIndex + j + 1, pinsIndex + busPins)) {
|
DEBUG_PRINTLN(F("Some of the provided pins cannot be used to configure this LED output."));
|
||||||
if (validPin) {
|
if (validPin) {
|
||||||
defPin[j] = 1; // start with GPIO1 and work upwards
|
defPin[j] = 1; // start with GPIO1 and work upwards
|
||||||
validPin = false;
|
validPin = false;
|
||||||
|
@ -281,9 +281,11 @@ bool PinManagerClass::isReadOnlyPin(byte gpio)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PinManagerClass::isPinDefined(byte gpio, const unsigned *pins, unsigned start, unsigned end) {
|
// Given an array of pins, check if a given pin is defined except at given index
|
||||||
for (unsigned i = start; i < end; i++) {
|
bool PinManagerClass::isPinDefined(const byte gpio, const uint8_t *pins, const unsigned index) {
|
||||||
if (pins[i] == gpio) return true;
|
unsigned numPins = ((sizeof pins) / (sizeof pins[0]));
|
||||||
|
for (unsigned i = 0; i < numPins; i++) {
|
||||||
|
if ((pins[i] == gpio) && (i != index)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class PinManagerClass {
|
|||||||
bool isPinOk(byte gpio, bool output = true) const;
|
bool isPinOk(byte gpio, bool output = true) const;
|
||||||
|
|
||||||
static bool isReadOnlyPin(byte gpio);
|
static bool isReadOnlyPin(byte gpio);
|
||||||
static bool isPinDefined(byte gpio, const unsigned* pins, unsigned start = 0, unsigned end = WLED_NUM_PINS);
|
static bool isPinDefined(const byte gpio, const uint8_t* pins, const unsigned index = 255);
|
||||||
|
|
||||||
PinOwner getPinOwner(byte gpio) const;
|
PinOwner getPinOwner(byte gpio) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user