kopia lustrzana https://github.com/Aircoookie/WLED
- More optimization on bus configuration logic.
- Renamed LEDPIN to DEFAULT_LED_PIN. - Removed ability to override DEFAULT_LED_PIN, DEFAULT_LED_TYPE and DEFAULT_LED_COUNT. Use DATA_PINS, LED_TYPES and PIXEL_COUNTS instead.pull/4107/head
rodzic
eb06e575c2
commit
5869627b32
|
@ -53,7 +53,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef DATA_PINS
|
||||
#define DATA_PINS LEDPIN
|
||||
#define DATA_PINS DEFAULT_LED_PIN
|
||||
#endif
|
||||
|
||||
#ifndef LED_TYPES
|
||||
|
@ -1245,32 +1245,27 @@ void WS2812FX::finalizeInit(void) {
|
|||
unsigned dataType = defDataTypes[(i < defNumTypes) ? i : defNumTypes -1];
|
||||
unsigned busPins = Bus::getNumberOfPins(dataType);
|
||||
|
||||
// check if we have enough pins left to configure an output of this type
|
||||
// should never happen due to static assert above
|
||||
if (pinsIndex + busPins > defNumPins) {
|
||||
DEBUG_PRINTLN(F("LED outputs misaligned with defined pins. Some pins will remain unused."));
|
||||
break;
|
||||
}
|
||||
// if we need more pins than available all outputs have been configured
|
||||
if (pinsIndex + busPins > defNumPins) break;
|
||||
|
||||
for (unsigned j = 0; j < busPins && j < OUTPUT_MAX_PINS; j++) {
|
||||
defPin[j] = defDataPins[pinsIndex + j];
|
||||
|
||||
// when booting without config (1st boot) we need to make sure GPIOs defined for LED output don't clash with hardware
|
||||
bool validPin = true;
|
||||
// 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.
|
||||
if (pinManager.isPinAllocated(defPin[j]) || pinManager.isReadOnlyPin(defPin[j])) {
|
||||
defPin[j] = 1; // start with GPIO1 and work upwards
|
||||
while (
|
||||
(
|
||||
pinManager.isPinAllocated(defPin[j]) ||
|
||||
pinManager.isReadOnlyPin(defPin[j]) ||
|
||||
// Check if pin is defined for current bus
|
||||
pinManager.isPinDefined(defPin[j], defDataPins, pinsIndex + j, pinsIndex + busPins)
|
||||
)
|
||||
&&
|
||||
defPin[j] < WLED_NUM_PINS
|
||||
)
|
||||
{
|
||||
defPin[j]++;
|
||||
// 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], defDataPins, pinsIndex + j + 1, pinsIndex + busPins)) {
|
||||
if (validPin) {
|
||||
defPin[j] = 1; // start with GPIO1 and work upwards
|
||||
validPin = false;
|
||||
}
|
||||
if (defPin[j] < WLED_NUM_PINS) {
|
||||
defPin[j]++;
|
||||
} else {
|
||||
DEBUG_PRINTLN(F("No available pins left! Can't configure output."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,15 +563,6 @@
|
|||
#define WLED_MAX_NODES 150
|
||||
#endif
|
||||
|
||||
//this is merely a default now and can be changed at runtime
|
||||
#ifndef LEDPIN
|
||||
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) //|| (defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM)) || defined(ARDUINO_ESP32_PICO)
|
||||
#define LEDPIN 2 // GPIO2 (D4) on Wemos D1 mini compatible boards, safe to use on any board
|
||||
#else
|
||||
#define LEDPIN 16 // aligns with GPIO2 (D4) on Wemos D1 mini32 compatible boards (if it is unusable it will be reassigned in WS2812FX::finalizeInit())
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// List of read only pins. Cannot be used for LED outputs.
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
#define READ_ONLY_PINS 46
|
||||
|
@ -593,13 +584,14 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_LED_TYPE
|
||||
#define DEFAULT_LED_TYPE TYPE_WS2812_RGB
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_LED_COUNT
|
||||
#define DEFAULT_LED_COUNT 30
|
||||
// Defaults pins, type and counts to configure LED output
|
||||
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
#define DEFAULT_LED_PIN 2 // GPIO2 (D4) on Wemos D1 mini compatible boards, safe to use on any board
|
||||
#else
|
||||
#define DEFAULT_LED_PIN 16 // aligns with GPIO2 (D4) on Wemos D1 mini32 compatible boards (if it is unusable it will be reassigned in WS2812FX::finalizeInit())
|
||||
#endif
|
||||
#define DEFAULT_LED_TYPE TYPE_WS2812_RGB
|
||||
#define DEFAULT_LED_COUNT 30
|
||||
|
||||
#define INTERFACE_UPDATE_COOLDOWN 1000 // time in ms to wait between websockets, alexa, and MQTT updates
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue