mirror of
https://github.com/wled/WLED.git
synced 2025-07-23 18:56:41 +00:00
- 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.
This commit is contained in:
parent
eb06e575c2
commit
5869627b32
@ -53,7 +53,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DATA_PINS
|
#ifndef DATA_PINS
|
||||||
#define DATA_PINS LEDPIN
|
#define DATA_PINS DEFAULT_LED_PIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LED_TYPES
|
#ifndef LED_TYPES
|
||||||
@ -1245,32 +1245,27 @@ void WS2812FX::finalizeInit(void) {
|
|||||||
unsigned dataType = defDataTypes[(i < defNumTypes) ? i : defNumTypes -1];
|
unsigned dataType = defDataTypes[(i < defNumTypes) ? i : defNumTypes -1];
|
||||||
unsigned busPins = Bus::getNumberOfPins(dataType);
|
unsigned busPins = Bus::getNumberOfPins(dataType);
|
||||||
|
|
||||||
// check if we have enough pins left to configure an output of this type
|
// if we need more pins than available all outputs have been configured
|
||||||
// should never happen due to static assert above
|
if (pinsIndex + busPins > defNumPins) break;
|
||||||
if (pinsIndex + busPins > defNumPins) {
|
|
||||||
DEBUG_PRINTLN(F("LED outputs misaligned with defined pins. Some pins will remain unused."));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned j = 0; j < busPins && j < OUTPUT_MAX_PINS; j++) {
|
for (unsigned j = 0; j < busPins && j < OUTPUT_MAX_PINS; j++) {
|
||||||
defPin[j] = defDataPins[pinsIndex + 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.
|
// 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])) {
|
// Pin should not be already allocated, read/only or defined for current bus
|
||||||
defPin[j] = 1; // start with GPIO1 and work upwards
|
while (pinManager.isPinAllocated(defPin[j]) || pinManager.isReadOnlyPin(defPin[j]) ||
|
||||||
while (
|
pinManager.isPinDefined(defPin[j], defDataPins, pinsIndex + j + 1, pinsIndex + busPins)) {
|
||||||
(
|
if (validPin) {
|
||||||
pinManager.isPinAllocated(defPin[j]) ||
|
defPin[j] = 1; // start with GPIO1 and work upwards
|
||||||
pinManager.isReadOnlyPin(defPin[j]) ||
|
validPin = false;
|
||||||
// Check if pin is defined for current bus
|
}
|
||||||
pinManager.isPinDefined(defPin[j], defDataPins, pinsIndex + j, pinsIndex + busPins)
|
if (defPin[j] < WLED_NUM_PINS) {
|
||||||
)
|
defPin[j]++;
|
||||||
&&
|
} else {
|
||||||
defPin[j] < WLED_NUM_PINS
|
DEBUG_PRINTLN(F("No available pins left! Can't configure output."));
|
||||||
)
|
return;
|
||||||
{
|
|
||||||
defPin[j]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,15 +563,6 @@
|
|||||||
#define WLED_MAX_NODES 150
|
#define WLED_MAX_NODES 150
|
||||||
#endif
|
#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.
|
// List of read only pins. Cannot be used for LED outputs.
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||||
#define READ_ONLY_PINS 46
|
#define READ_ONLY_PINS 46
|
||||||
@ -593,13 +584,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DEFAULT_LED_TYPE
|
// Defaults pins, type and counts to configure LED output
|
||||||
#define DEFAULT_LED_TYPE TYPE_WS2812_RGB
|
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
#endif
|
#define DEFAULT_LED_PIN 2 // GPIO2 (D4) on Wemos D1 mini compatible boards, safe to use on any board
|
||||||
|
#else
|
||||||
#ifndef DEFAULT_LED_COUNT
|
#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())
|
||||||
#define DEFAULT_LED_COUNT 30
|
|
||||||
#endif
|
#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
|
#define INTERFACE_UPDATE_COOLDOWN 1000 // time in ms to wait between websockets, alexa, and MQTT updates
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user