mirror of
https://github.com/wled/WLED.git
synced 2025-04-23 22:37:18 +00:00
Use refernece to avoid ctor/dtor
Use PinManager to determine reserved pins
This commit is contained in:
parent
e3d9417b84
commit
81e412fe5b
@ -1271,7 +1271,7 @@ void WS2812FX::finalizeInit() {
|
||||
bool clash;
|
||||
do {
|
||||
clash = false;
|
||||
for (const auto pin : defDataPins) {
|
||||
for (const auto &pin : defDataPins) {
|
||||
if (pin == defPin[j]) {
|
||||
defPin[j]++;
|
||||
if (defPin[j] < WLED_NUM_PINS) clash = true;
|
||||
|
@ -121,6 +121,7 @@ void fillUMPins(JsonObject &mods)
|
||||
void appendGPIOinfo() {
|
||||
char nS[8];
|
||||
|
||||
// add usermod pins as d.um_p array
|
||||
oappend(SET_F("d.um_p=[-1")); // has to have 1 element
|
||||
if (i2c_sda > -1 && i2c_scl > -1) {
|
||||
oappend(","); oappend(itoa(i2c_sda,nS,10));
|
||||
@ -140,54 +141,41 @@ void appendGPIOinfo() {
|
||||
}
|
||||
oappend(SET_F("];"));
|
||||
|
||||
// add reserved and usermod pins as d.um_p array
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
oappend(SET_F("d.rsvd=[22,23,24,25,26,27,28,29,30,31,32"));
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
oappend(SET_F("d.rsvd=[19,20,22,23,24,25,26,27,28,29,30,31,32")); // includes 19+20 for USB OTG (JTAG)
|
||||
if (psramFound()) oappend(SET_F(",33,34,35,36,37")); // in use for "octal" PSRAM or "octal" FLASH -seems that octal PSRAM is very common on S3.
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
oappend(SET_F("d.rsvd=[11,12,13,14,15,16,17"));
|
||||
#elif defined(ESP32)
|
||||
oappend(SET_F("d.rsvd=[6,7,8,9,10,11,24,28,29,30,31,37,38"));
|
||||
if (!pinManager.isPinOk(16,false)) oappend(SET_F(",16")); // covers PICO & WROVER
|
||||
if (!pinManager.isPinOk(17,false)) oappend(SET_F(",17")); // covers PICO & WROVER
|
||||
#else
|
||||
oappend(SET_F("d.rsvd=[6,7,8,9,10,11"));
|
||||
#endif
|
||||
|
||||
// add reserved (unusable) pins
|
||||
oappend(SET_F("d.rsvd=["));
|
||||
for (unsigned i = 0; i < WLED_NUM_PINS; i++) {
|
||||
if (!pinManager.isPinOk(i, false)) { // include readonly pins
|
||||
oappendi(i); oappend(",");
|
||||
}
|
||||
}
|
||||
#ifdef WLED_ENABLE_DMX
|
||||
oappend(SET_F(",2")); // DMX hardcoded pin
|
||||
oappend(SET_F("2,")); // DMX hardcoded pin
|
||||
#endif
|
||||
|
||||
#if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST)
|
||||
oappend(SET_F(",")); oappend(itoa(hardwareTX,nS,10)); // debug output (TX) pin
|
||||
oappend(itoa(hardwareTX,nS,10)); oappend(","); // debug output (TX) pin
|
||||
#endif
|
||||
|
||||
//Note: Using pin 3 (RX) disables Adalight / Serial JSON
|
||||
|
||||
#ifdef WLED_USE_ETHERNET
|
||||
if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) {
|
||||
for (unsigned p=0; p<WLED_ETH_RSVD_PINS_COUNT; p++) { oappend(","); oappend(itoa(esp32_nonconfigurable_ethernet_pins[p].pin,nS,10)); }
|
||||
if (ethernetBoards[ethernetType].eth_power>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_power,nS,10)); }
|
||||
if (ethernetBoards[ethernetType].eth_mdc>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_mdc,nS,10)); }
|
||||
if (ethernetBoards[ethernetType].eth_mdio>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_mdio,nS,10)); }
|
||||
switch (ethernetBoards[ethernetType].eth_clk_mode) {
|
||||
for (unsigned p=0; p<WLED_ETH_RSVD_PINS_COUNT; p++) { oappend(itoa(esp32_nonconfigurable_ethernet_pins[p].pin,nS,10)); oappend(","); }
|
||||
if (ethernetBoards[ethernetType].eth_power>=0) { oappend(itoa(ethernetBoards[ethernetType].eth_power,nS,10)); oappend(","); }
|
||||
if (ethernetBoards[ethernetType].eth_mdc>=0) { oappend(itoa(ethernetBoards[ethernetType].eth_mdc,nS,10)); oappend(","); }
|
||||
if (ethernetBoards[ethernetType].eth_mdio>=0) { oappend(itoa(ethernetBoards[ethernetType].eth_mdio,nS,10)); oappend(","); }
|
||||
switch (ethernetBoards[ethernetType].eth_clk_mode) {
|
||||
case ETH_CLOCK_GPIO0_IN:
|
||||
case ETH_CLOCK_GPIO0_OUT:
|
||||
oappend(SET_F(",0"));
|
||||
oappend(SET_F("0"));
|
||||
break;
|
||||
case ETH_CLOCK_GPIO16_OUT:
|
||||
oappend(SET_F(",16"));
|
||||
oappend(SET_F("16"));
|
||||
break;
|
||||
case ETH_CLOCK_GPIO17_OUT:
|
||||
oappend(SET_F(",17"));
|
||||
oappend(SET_F("17"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
oappend(SET_F("];"));
|
||||
oappend(SET_F("];")); // rsvd
|
||||
|
||||
// add info for read-only GPIO
|
||||
oappend(SET_F("d.ro_gpio=["));
|
||||
|
Loading…
x
Reference in New Issue
Block a user