From c0a115ada3ea79e47ac68a1ef45649e9075897be Mon Sep 17 00:00:00 2001 From: TroyHacks <5659019+troyhacks@users.noreply.github.com> Date: Wed, 6 Dec 2023 23:51:43 -0500 Subject: [PATCH 001/193] Pin reservation and better include logic for S3 --- wled00/data/settings_wifi.htm | 3 +- wled00/src/dependencies/network/Network.h | 3 ++ wled00/wled.cpp | 49 ++++++++++++++++++++--- wled00/wled.h | 6 ++- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/wled00/data/settings_wifi.htm b/wled00/data/settings_wifi.htm index 8d4aebe13d..080d500d01 100644 --- a/wled00/data/settings_wifi.htm +++ b/wled00/data/settings_wifi.htm @@ -200,10 +200,11 @@

Ethernet Type

- + + diff --git a/wled00/src/dependencies/network/Network.h b/wled00/src/dependencies/network/Network.h index 9201d514ea..872cccb911 100644 --- a/wled00/src/dependencies/network/Network.h +++ b/wled00/src/dependencies/network/Network.h @@ -1,5 +1,8 @@ #ifdef ESP8266 #include +#elif CONFIG_IDF_TARGET_ESP32S3 + #include + #include #else // ESP32 #include #include diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 2fd8811701..7c2db55fbc 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -856,14 +856,14 @@ void WLED::initAP(bool resetAP) apActive = true; } +static bool successfullyConfiguredEthernet = false; + bool WLED::initEthernet() { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - static bool successfullyConfiguredEthernet = false; - if (successfullyConfiguredEthernet) { - // DEBUG_PRINTLN(F("initE: ETH already successfully configured, ignoring")); + DEBUG_PRINTLN(F("initE: ETH already successfully configured, ignoring")); return false; } if (ethernetType == WLED_ETH_NONE) { @@ -876,6 +876,7 @@ bool WLED::initEthernet() DEBUG_PRINT(F("initE: Attempting ETH config: ")); DEBUG_PRINTLN(ethernetType); + #ifndef ARDUINO_ARCH_ESP32S3 // Ethernet initialization should only succeed once -- else reboot required ethernet_settings es = ethernetBoards[ethernetType]; managed_pin_type pinsToAllocate[10] = { @@ -932,7 +933,6 @@ bool WLED::initEthernet() digitalWrite(es.eth_power, 1); delayMicroseconds(10); } - #endif if (!ETH.begin( (uint8_t) es.eth_address, @@ -950,6 +950,38 @@ bool WLED::initEthernet() return false; } + #endif + + #elif defined (ARDUINO_ARCH_ESP32S3) + + #define ETH_MISO_PIN 11 + #define ETH_MOSI_PIN 12 + #define ETH_SCLK_PIN 10 + #define ETH_CS_PIN 9 + #define ETH_INT_PIN 13 + #define ETH_RST_PIN 14 + #define ETH_ADDR 1 + + managed_pin_type pinsToAllocate[12] = { ETH_MISO_PIN,true,ETH_MOSI_PIN,true,ETH_SCLK_PIN,true,ETH_CS_PIN,true,ETH_INT_PIN,true,ETH_RST_PIN,true }; + + if (!pinManager.allocateMultiplePins(pinsToAllocate, 6, PinOwner::Ethernet)) { + DEBUG_PRINTLN(F("initE: Failed to allocate ethernet pins")); + return false; + } + + if (!ETH.beginSPI(ETH_MISO_PIN, ETH_MOSI_PIN, ETH_SCLK_PIN, ETH_CS_PIN, ETH_RST_PIN, ETH_INT_PIN)) { + DEBUG_PRINTLN(F("initC: ETH.beginSPI() failed")); + // de-allocate the allocated pins + for (managed_pin_type mpt : pinsToAllocate) { + pinManager.deallocatePin(mpt.pin, PinOwner::Ethernet); + } + return false; + } else { + Serial.println("ETH initialized W5500!"); + } + + #endif + successfullyConfiguredEthernet = true; USER_PRINTLN(F("initC: *** Ethernet successfully configured! ***")); // WLEDMM return true; @@ -1046,7 +1078,7 @@ void WLED::initInterfaces() WiFi.hostByName(WLED_DEBUG_HOST, netDebugPrintIP, 750); #else #ifdef WLED_USE_ETHERNET - // ETH.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); WLEDMM: ETH.hostByName does not exist, WiFi.hostByName seems to do the same, but must be tested. + // ETH.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); // WLEDMM: ETH.hostByName does not exist, WiFi.hostByName seems to do the same, but must be tested. WiFi.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); #else WiFi.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); @@ -1226,7 +1258,12 @@ void WLED::handleConnection() } else if (!interfacesInited) { //newly connected DEBUG_PRINTLN(""); USER_PRINT(F("Connected! IP address: ")); - USER_PRINTLN(Network.localIP()); + USER_PRINT(Network.localIP()); + if (successfullyConfiguredEthernet) { + USER_PRINTLN(" via Ethernet"); + } else { + USER_PRINTLN(" via WiFi"); + } if (improvActive) { if (improvError == 3) sendImprovStateResponse(0x00, true); sendImprovStateResponse(0x04); diff --git a/wled00/wled.h b/wled00/wled.h index 3b0cffe67e..3d8111495b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -103,7 +103,11 @@ #else // ESP32 #include // ensure we have the correct "Serial" on new MCUs (depends on ARDUINO_USB_MODE and ARDUINO_USB_CDC_ON_BOOT) #include - #include + #ifdef CONFIG_IDF_TARGET_ESP32S3 + #include + #else // ESP32 + #include + #endif #include "esp_wifi.h" #include #include From cca0055611e9acc0b50f838fc94fe3ab916a3224 Mon Sep 17 00:00:00 2001 From: TroyHacks <5659019+troyhacks@users.noreply.github.com> Date: Mon, 11 Dec 2023 09:29:22 -0500 Subject: [PATCH 002/193] Added WLED_DISABLE_MDNS for no really great reason --- wled00/wled.cpp | 3 +++ wled00/wled.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 7c2db55fbc..ec07fc28f2 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1117,6 +1117,7 @@ void WLED::initInterfaces() } #endif // WLEDMM end + #ifndef WLED_DISABLE_MDNS // WLEDMM // Set up mDNS responder: if (strlen(cmDNS) > 0) { // "end" must be called before "begin" is called a 2nd time @@ -1129,6 +1130,8 @@ void WLED::initInterfaces() MDNS.addService("wled", "tcp", 80); MDNS.addServiceTxt("wled", "tcp", "mac", escapedMac.c_str()); } + #endif // WLEDMM end + server.begin(); if (udpPort > 0 && udpPort != ntpLocalPort) { diff --git a/wled00/wled.h b/wled00/wled.h index 3d8111495b..9063952f13 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -109,7 +109,9 @@ #include #endif #include "esp_wifi.h" - #include + #ifndef WLED_DISABLE_MDNS + #include + #endif // WLEDMM end #include #if LOROL_LITTLEFS #ifndef CONFIG_LITTLEFS_FOR_IDF_3_2 From ddfa90a12b4623c765864e72ac2c7ce0026796cd Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:49:32 -0400 Subject: [PATCH 003/193] Overhaul Art-Net to be more "professionally" good --- wled00/bus_manager.cpp | 55 +++++++++++++++++++++--- wled00/bus_manager.h | 8 +++- wled00/udp.cpp | 96 ++++++++++++++++++++++++++---------------- 3 files changed, 114 insertions(+), 45 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 3801c534de..142274d4db 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -394,7 +394,7 @@ uint8_t BusOnOff::getPins(uint8_t* pinArray) { } -BusNetwork::BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { +BusNetwork::BusNetwork(BusConfig &bc, const ColorOrderMap &com) : Bus(bc.type, bc.start, bc.autoWhite), _colorOrderMap(com) { _valid = false; switch (bc.type) { case TYPE_NET_ARTNET_RGB: @@ -418,6 +418,7 @@ BusNetwork::BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { _client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]); _broadcastLock = false; _valid = true; + _colorOrder = bc.colorOrder; } void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { @@ -425,16 +426,56 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { if (hasWhite()) c = autoWhiteCalc(c); if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT uint16_t offset = pix * _UDPchannels; - _data[offset] = R(c); - _data[offset+1] = G(c); - _data[offset+2] = B(c); - if (_rgbw) _data[offset+3] = W(c); + uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder); + if (_colorOrder != co) { + if (co == COL_ORDER_GRB) { + _data[offset] = G(c); + _data[offset+1] = R(c); + _data[offset+2] = B(c); + } else if (co == COL_ORDER_RGB) { + _data[offset] = R(c); + _data[offset+1] = G(c); + _data[offset+2] = B(c); + } else if (co == COL_ORDER_BRG) { + _data[offset] = B(c); + _data[offset+1] = R(c); + _data[offset+2] = G(c); + } else if (co == COL_ORDER_RBG) { + _data[offset] = R(c); + _data[offset+1] = B(c); + _data[offset+2] = G(c); + } else if (co == COL_ORDER_GBR) { + _data[offset] = G(c); + _data[offset+1] = B(c); + _data[offset+2] = R(c); + } + if (_rgbw) _data[offset+3] = W(c); + } else { + _data[offset] = R(c); + _data[offset+1] = G(c); + _data[offset+2] = B(c); + if (_rgbw) _data[offset+3] = W(c); + } } uint32_t BusNetwork::getPixelColor(uint16_t pix) { if (!_valid || pix >= _len) return 0; uint16_t offset = pix * _UDPchannels; - return RGBW32(_data[offset], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder); + if (_colorOrder != co) { + if (co == COL_ORDER_GRB) { + return RGBW32(_data[offset+1], _data[offset+0], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_RGB) { + return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_BRG) { + return RGBW32(_data[offset+2], _data[offset+0], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_RBG) { + return RGBW32(_data[offset+0], _data[offset+2], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_GBR) { + return RGBW32(_data[offset+1], _data[offset+2], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); + } + } + return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); } void BusNetwork::show() { @@ -711,7 +752,7 @@ int BusManager::add(BusConfig &bc) { if (getNumBusses() - getNumVirtualBusses() >= WLED_MAX_BUSSES) return -1; USER_PRINTF("BusManager::add(bc.type=%u)\n", bc.type); if (bc.type >= TYPE_NET_DDP_RGB && bc.type < 96) { - busses[numBusses] = new BusNetwork(bc); + busses[numBusses] = new BusNetwork(bc,colorOrderMap); #ifdef WLED_ENABLE_HUB75MATRIX } else if (bc.type >= TYPE_HUB75MATRIX && bc.type <= (TYPE_HUB75MATRIX + 10)) { USER_PRINTLN("BusManager::add - Adding BusHub75Matrix"); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index f089b52985..5c7374f807 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -295,7 +295,7 @@ class BusOnOff : public Bus { class BusNetwork : public Bus { public: - BusNetwork(BusConfig &bc); + BusNetwork(BusConfig &bc, const ColorOrderMap &com); uint16_t getMaxPixels() override { return 4096; }; bool hasRGB() { return true; } @@ -318,6 +318,10 @@ class BusNetwork : public Bus { return _len; } + uint8_t getColorOrder() { + return _colorOrder; + } + void cleanup(); ~BusNetwork() { @@ -331,6 +335,8 @@ class BusNetwork : public Bus { bool _rgbw; bool _broadcastLock; byte *_data; + uint8_t _colorOrder = COL_ORDER_RGB; + const ColorOrderMap &_colorOrderMap; }; #ifdef WLED_ENABLE_HUB75MATRIX diff --git a/wled00/udp.cpp b/wled00/udp.cpp index c2395357b5..5a03f33792 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -837,58 +837,80 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 2: //ArtNet { - // calculate the number of UDP packets we need to send - const size_t channelCount = length * (isRGBW?4:3); // 1 channel for every R,G,B,(W?) value + /* + We don't really care about the number of universes - just how many hardware outputs we have. + + WLED rendering Art-Net data considers itself to be 1 hardware output with many universes - but + many Art-Net controllers like the H807SA can be manually set to "X universes per output." + + We need to know the channels per output so we can break the pixel data across physically attached universes. + + The H807SA obeys the "510 channels for RGB" rule like WLED and xLights - some other controllers do not care, + but we're not supporting those here. If you run into one of these, override ARTNET_CHANNELS_PER_PACKET to 512. + + We're expecting equal numbers of channels per output, common for controllers like the H807SA - at some point + we could consider an Art-Net mapping system to adjust universe starts for weird wiring situations. + */ const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs - const size_t packetCount = ((channelCount-1)/ARTNET_CHANNELS_PER_PACKET)+1; + const size_t hardware_outputs = 4; // WLED as an Art-Net renderer would be considered "1 hardware output" with many universes + const size_t channels_per_hardware_output = length/hardware_outputs * (isRGBW?4:3); - uint32_t channel = 0; size_t bufferOffset = 0; + size_t hardware_output_universe = 0; sequenceNumber++; - for (size_t currentPacket = 0; currentPacket < packetCount; currentPacket++) { + for (size_t hardware_output = 0; hardware_output < hardware_outputs; hardware_output++){ - if (sequenceNumber > 255) sequenceNumber = 0; + size_t channels_remaining = channels_per_hardware_output; - if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { - DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); - return 1; // borked - } + while (channels_remaining > 0) { - size_t packetSize = ARTNET_CHANNELS_PER_PACKET; + if (sequenceNumber > 255) sequenceNumber = 0; - if (currentPacket == (packetCount - 1U)) { - // last packet - if (channelCount % ARTNET_CHANNELS_PER_PACKET) { - packetSize = channelCount % ARTNET_CHANNELS_PER_PACKET; + if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { + DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); + return 1; // borked } - } - byte header_buffer[ART_NET_HEADER_SIZE]; - memcpy_P(header_buffer, ART_NET_HEADER, ART_NET_HEADER_SIZE); - ddpUdp.write(header_buffer, ART_NET_HEADER_SIZE); // This doesn't change. Hard coded ID, OpCode, and protocol version. - ddpUdp.write(sequenceNumber & 0xFF); // sequence number. 1..255 - ddpUdp.write(0x00); // physical - more an FYI, not really used for anything. 0..3 - ddpUdp.write((currentPacket) & 0xFF); // Universe LSB. 1 full packet == 1 full universe, so just use current packet number. - ddpUdp.write(0x00); // Universe MSB, unused. - ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB - ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB + size_t packetSize = ARTNET_CHANNELS_PER_PACKET; - for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B - if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // W - } + if (channels_remaining < ARTNET_CHANNELS_PER_PACKET) { + packetSize = channels_remaining; + channels_remaining = 0; + } else { + channels_remaining -= packetSize; + } - if (!ddpUdp.endPacket()) { - DEBUG_PRINTLN(F("Art-Net WiFiUDP.endPacket returned an error")); - return 1; // borked + byte header_buffer[ART_NET_HEADER_SIZE]; + memcpy_P(header_buffer, ART_NET_HEADER, ART_NET_HEADER_SIZE); + ddpUdp.write(header_buffer, ART_NET_HEADER_SIZE); // This doesn't change. Hard coded ID, OpCode, and protocol version. + ddpUdp.write(sequenceNumber & 0xFF); // sequence number. 1..255 + ddpUdp.write(0x00); // physical - more an FYI, not really used for anything. 0..3 + ddpUdp.write(hardware_output_universe & 0xFF); // Universe LSB. 1 full packet == 1 full universe. + ddpUdp.write(0x00); // Universe MSB, unused. + ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB + ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB + + for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { + // TODO: TroyHacks - some controllers do not have onboard color order remapping. Add something to do this. + // Currently remapped manually for GRB, but WLED rendering Art-Net expects RGB. + // Color order override maps would be useful here, but doesn't seem to work for "busNetwork" (yet). + ddpUdp.write(scale8(buffer[bufferOffset+0], bri)); // G + ddpUdp.write(scale8(buffer[bufferOffset+1], bri)); // R + ddpUdp.write(scale8(buffer[bufferOffset+2], bri)); // B + if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset+3], bri)); // W + bufferOffset += isRGBW?4:3; + } + + if (!ddpUdp.endPacket()) { + DEBUG_PRINTLN(F("Art-Net WiFiUDP.endPacket returned an error")); + return 1; // borked + } + hardware_output_universe++; } - channel += packetSize; - } - } break; + } break; + } } return 0; } From 1a90b73a3a7e28376549ce967f9c0869d4425e83 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:57:56 -0400 Subject: [PATCH 004/193] hardware_outputs back to 1 to not break defaults --- wled00/udp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 5a03f33792..a955039430 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -852,7 +852,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 we could consider an Art-Net mapping system to adjust universe starts for weird wiring situations. */ const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs - const size_t hardware_outputs = 4; // WLED as an Art-Net renderer would be considered "1 hardware output" with many universes + const size_t hardware_outputs = 1; // WLED as an Art-Net renderer would be considered "1 hardware output" with many universes const size_t channels_per_hardware_output = length/hardware_outputs * (isRGBW?4:3); size_t bufferOffset = 0; From d398a4d62b20c34969322bbcdb7b10171736062b Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:16:17 -0400 Subject: [PATCH 005/193] Comments fixed, minor code tidy/revert. --- wled00/udp.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index a955039430..d93f9d04b4 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -893,14 +893,11 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { - // TODO: TroyHacks - some controllers do not have onboard color order remapping. Add something to do this. - // Currently remapped manually for GRB, but WLED rendering Art-Net expects RGB. - // Color order override maps would be useful here, but doesn't seem to work for "busNetwork" (yet). - ddpUdp.write(scale8(buffer[bufferOffset+0], bri)); // G - ddpUdp.write(scale8(buffer[bufferOffset+1], bri)); // R - ddpUdp.write(scale8(buffer[bufferOffset+2], bri)); // B - if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset+3], bri)); // W - bufferOffset += isRGBW?4:3; + // "Color Order Override" works on top of this if you need to change the color order before sending. + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B + if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // W } if (!ddpUdp.endPacket()) { From b1a099c158c2e47d48b1ec2e33cfd88800992a11 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:32:32 -0400 Subject: [PATCH 006/193] Minor tidy. --- wled00/udp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index d93f9d04b4..18e59e834a 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -860,14 +860,14 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 sequenceNumber++; - for (size_t hardware_output = 0; hardware_output < hardware_outputs; hardware_output++){ + if (sequenceNumber > 255) sequenceNumber = 0; + + for (size_t hardware_output = 0; hardware_output < hardware_outputs; hardware_output++) { size_t channels_remaining = channels_per_hardware_output; while (channels_remaining > 0) { - if (sequenceNumber > 255) sequenceNumber = 0; - if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); return 1; // borked From 334884a0b24984e012d80c24fec255bb9c209bc2 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Sat, 30 Mar 2024 08:45:00 -0400 Subject: [PATCH 007/193] Forgot BGR and default RGB order --- wled00/bus_manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 142274d4db..f3604b41d3 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -393,7 +393,6 @@ uint8_t BusOnOff::getPins(uint8_t* pinArray) { return 1; } - BusNetwork::BusNetwork(BusConfig &bc, const ColorOrderMap &com) : Bus(bc.type, bc.start, bc.autoWhite), _colorOrderMap(com) { _valid = false; switch (bc.type) { @@ -418,7 +417,6 @@ BusNetwork::BusNetwork(BusConfig &bc, const ColorOrderMap &com) : Bus(bc.type, b _client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]); _broadcastLock = false; _valid = true; - _colorOrder = bc.colorOrder; } void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { @@ -448,6 +446,10 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { _data[offset] = G(c); _data[offset+1] = B(c); _data[offset+2] = R(c); + } else if (co == COL_ORDER_BGR) { + _data[offset] = B(c); + _data[offset+1] = G(c); + _data[offset+2] = R(c); } if (_rgbw) _data[offset+3] = W(c); } else { @@ -473,6 +475,8 @@ uint32_t BusNetwork::getPixelColor(uint16_t pix) { return RGBW32(_data[offset+0], _data[offset+2], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); } else if (co == COL_ORDER_GBR) { return RGBW32(_data[offset+1], _data[offset+2], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_BGR) { + return RGBW32(_data[offset+2], _data[offset+1], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); } } return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); From 549f0141f85b45672fa95601bc053704a3b81dad Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:42:24 -0400 Subject: [PATCH 008/193] Start of custom mapping ability --- wled00/udp.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 18e59e834a..cb17ccb661 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -852,19 +852,33 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 we could consider an Art-Net mapping system to adjust universe starts for weird wiring situations. */ const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs - const size_t hardware_outputs = 1; // WLED as an Art-Net renderer would be considered "1 hardware output" with many universes - const size_t channels_per_hardware_output = length/hardware_outputs * (isRGBW?4:3); + + // Default WLED-to-WLED Art-Net output + // + const size_t hardware_outputs[1] = { length }; // specified in LED counts. "length" = all LEDs + const size_t hardware_outputs_universe_start[1] = { 0 }; // universe start # per output + + // Example of more than 1 output, currently you can only hard-code this kind of setup here. + // You get 170 RGB LEDs per universe (128 RGBW) so the receiving hardware needs to be configured correctly. + // The H807SA, for example, only allows one global setting of Art-Net universes-per-output. + // + // const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts + // const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output size_t bufferOffset = 0; size_t hardware_output_universe = 0; - + sequenceNumber++; if (sequenceNumber > 255) sequenceNumber = 0; - for (size_t hardware_output = 0; hardware_output < hardware_outputs; hardware_output++) { + for (size_t hardware_output = 0; hardware_output < sizeof(hardware_outputs)/sizeof(size_t); hardware_output++) { + + if (bufferOffset > length * (isRGBW?4:3)) return 1; // stop when we hit end of LEDs + + hardware_output_universe = hardware_outputs_universe_start[hardware_output]; - size_t channels_remaining = channels_per_hardware_output; + size_t channels_remaining = hardware_outputs[hardware_output] * (isRGBW?4:3); while (channels_remaining > 0) { From 3f574a9d7677eff5e31290cbd53789c78e0f4f44 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:33:34 -0400 Subject: [PATCH 009/193] Force use of Ethernet if configured. --- wled00/udp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index cb17ccb661..08ee0b069d 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -769,6 +769,8 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 switch (type) { case 0: // DDP { + ddpUdp.begin(Network.localIP(), DDP_DEFAULT_PORT); // in case we have Ethernet, this forces that source IP/routing. + // calculate the number of UDP packets we need to send size_t channelCount = length * (isRGBW? 4:3); // 1 channel for every R,G,B value size_t packetCount = ((channelCount-1) / DDP_CHANNELS_PER_PACKET) +1; @@ -837,6 +839,8 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 2: //ArtNet { + ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet, this forces that source IP/routing. + /* We don't really care about the number of universes - just how many hardware outputs we have. From f5b97f27b5a3b4548aaf89a667c7ab4408895743 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:18:20 -0400 Subject: [PATCH 010/193] Force routing only on non-ESP8266 --- wled00/udp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 08ee0b069d..737d6a828d 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -769,7 +769,9 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 switch (type) { case 0: // DDP { - ddpUdp.begin(Network.localIP(), DDP_DEFAULT_PORT); // in case we have Ethernet, this forces that source IP/routing. + #if defined WLED_USE_ETHERNET && !defined ESP8266 + ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + #endif // calculate the number of UDP packets we need to send size_t channelCount = length * (isRGBW? 4:3); // 1 channel for every R,G,B value @@ -839,8 +841,9 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 2: //ArtNet { - ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet, this forces that source IP/routing. - + #if defined WLED_USE_ETHERNET && !defined ESP8266 + ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + #endif /* We don't really care about the number of universes - just how many hardware outputs we have. From 483daa945226cf444f8102a298e78696eb68d7f4 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:43:24 -0400 Subject: [PATCH 011/193] Logic for new ethernet board --- wled00/const.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wled00/const.h b/wled00/const.h index 14f419c224..628f8d2cea 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -280,7 +280,7 @@ #define BTN_TYPE_ANALOG_INVERTED 8 //Ethernet board types -#define WLED_NUM_ETH_TYPES 12 //WLEDMM +1 for Olimex ESP32-Gateway +#define WLED_NUM_ETH_TYPES 13 //WLEDMM +1 for Olimex ESP32-Gateway +1 for W5500 #define WLED_ETH_NONE 0 #define WLED_ETH_WT32_ETH01 1 @@ -294,6 +294,7 @@ #define WLED_ETH_ABCWLEDV43ETH 9 #define WLED_ETH_SERG74 10 #define WLED_ETH_OLIMEX_GTW 11 +#define WLED_ETH_W5500 12 //Hue error codes #define HUE_ERROR_INACTIVE 0 From 5dde1f9840f3327e5d7591635a5084338a5ecf1b Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:16:24 -0400 Subject: [PATCH 012/193] Bring in a fixed version of AsyncUDP --- wled00/src/dependencies/e131/ESPAsyncE131.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wled00/src/dependencies/e131/ESPAsyncE131.h b/wled00/src/dependencies/e131/ESPAsyncE131.h index 40d7154e28..9d03ef602f 100644 --- a/wled00/src/dependencies/e131/ESPAsyncE131.h +++ b/wled00/src/dependencies/e131/ESPAsyncE131.h @@ -28,7 +28,11 @@ #ifdef ESP32 #include +#ifdef ARDUINO_ARCH_ESP32S3 +#include +#else #include +#endif #elif defined (ESP8266) #include #include From 16ee90bfba5d9fcbfbf77f5ce4d944eac362ca99 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:17:38 -0400 Subject: [PATCH 013/193] Comments --- wled00/src/dependencies/e131/ESPAsyncE131.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/src/dependencies/e131/ESPAsyncE131.h b/wled00/src/dependencies/e131/ESPAsyncE131.h index 9d03ef602f..204395ef4e 100644 --- a/wled00/src/dependencies/e131/ESPAsyncE131.h +++ b/wled00/src/dependencies/e131/ESPAsyncE131.h @@ -29,7 +29,7 @@ #ifdef ESP32 #include #ifdef ARDUINO_ARCH_ESP32S3 -#include +#include // backport some fixes from 5.1 to 4.4 #else #include #endif From e6d127de0a24f0a4801228eedf37c717e395a38f Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:33:32 -0400 Subject: [PATCH 014/193] Updated to ETHClass2 --- wled00/cfg.cpp | 2 ++ wled00/network.cpp | 4 ++-- wled00/src/dependencies/network/Network.h | 3 ++- wled00/wled.cpp | 4 ++-- wled00/wled.h | 2 +- wled00/wled_ethernet.h | 2 ++ wled00/xml.cpp | 2 ++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 54c32f9c07..2474ad3401 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -746,6 +746,7 @@ void serializeConfig() { if (ethernetBoards[ethernetType].eth_power>=0) pins.add(ethernetBoards[ethernetType].eth_power); if (ethernetBoards[ethernetType].eth_mdc>=0) pins.add(ethernetBoards[ethernetType].eth_mdc); if (ethernetBoards[ethernetType].eth_mdio>=0) pins.add(ethernetBoards[ethernetType].eth_mdio); + #ifndef CONFIG_IDF_TARGET_ESP32S3 switch (ethernetBoards[ethernetType].eth_clk_mode) { case ETH_CLOCK_GPIO0_IN: case ETH_CLOCK_GPIO0_OUT: @@ -758,6 +759,7 @@ void serializeConfig() { pins.add(17); break; } + #endif } #endif diff --git a/wled00/network.cpp b/wled00/network.cpp index 6c94c4472c..3ca8e3906d 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -20,7 +20,7 @@ const ethernet_settings ethernetBoards[] = { // None { }, - + #ifndef CONFIG_IDF_TARGET_ESP32S3 // WT32-EHT01 // Please note, from my testing only these pins work for LED outputs: // IO2, IO4, IO12, IO14, IO15 @@ -134,7 +134,7 @@ const ethernet_settings ethernetBoards[] = { ETH_PHY_LAN8720, // eth_type, ETH_CLOCK_GPIO17_OUT // eth_clk_mode } - + #endif }; #endif diff --git a/wled00/src/dependencies/network/Network.h b/wled00/src/dependencies/network/Network.h index 872cccb911..dac3c8706b 100644 --- a/wled00/src/dependencies/network/Network.h +++ b/wled00/src/dependencies/network/Network.h @@ -2,7 +2,8 @@ #include #elif CONFIG_IDF_TARGET_ESP32S3 #include - #include + #include + #define ETH ETH2 #else // ESP32 #include #include diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 5570cd0a20..15656e093d 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1039,8 +1039,8 @@ bool WLED::initEthernet() return false; } - if (!ETH.beginSPI(ETH_MISO_PIN, ETH_MOSI_PIN, ETH_SCLK_PIN, ETH_CS_PIN, ETH_RST_PIN, ETH_INT_PIN)) { - DEBUG_PRINTLN(F("initC: ETH.beginSPI() failed")); + if (!ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN)) { + DEBUG_PRINTLN(F("initC: ETH.begin() [SPI Ethernet] failed")); // de-allocate the allocated pins for (managed_pin_type mpt : pinsToAllocate) { pinManager.deallocatePin(mpt.pin, PinOwner::Ethernet); diff --git a/wled00/wled.h b/wled00/wled.h index 3a4ff8e9c8..2499bfd0ac 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -107,7 +107,7 @@ #include // ensure we have the correct "Serial" on new MCUs (depends on ARDUINO_USB_MODE and ARDUINO_USB_CDC_ON_BOOT) #include #ifdef CONFIG_IDF_TARGET_ESP32S3 - #include + #include #else // ESP32 #include #endif diff --git a/wled00/wled_ethernet.h b/wled00/wled_ethernet.h index 6b8f0ba56f..db6f989cdf 100644 --- a/wled00/wled_ethernet.h +++ b/wled00/wled_ethernet.h @@ -23,7 +23,9 @@ typedef struct EthernetSettings { int eth_mdc; int eth_mdio; eth_phy_type_t eth_type; + #ifndef CONFIG_IDF_TARGET_ESP32S3 eth_clock_mode_t eth_clk_mode; + #endif } ethernet_settings; extern const ethernet_settings ethernetBoards[]; diff --git a/wled00/xml.cpp b/wled00/xml.cpp index ee647217c1..0da829b180 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -241,6 +241,7 @@ void appendGPIOinfo() { 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)); } + #ifndef CONFIG_IDF_TARGET_ESP32S3 switch (ethernetBoards[ethernetType].eth_clk_mode) { case ETH_CLOCK_GPIO0_IN: case ETH_CLOCK_GPIO0_OUT: @@ -253,6 +254,7 @@ void appendGPIOinfo() { oappend(SET_F(",17")); break; } + #endif } #endif From e72a77977757cd00cc99b4ad2b6c6da7d57925f6 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:59:30 -0400 Subject: [PATCH 015/193] Packet sequence numbering to Art-Net spec --- wled00/udp.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 3ffc12c93b..463f0ce308 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -876,10 +876,6 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 size_t bufferOffset = 0; size_t hardware_output_universe = 0; - sequenceNumber++; - - if (sequenceNumber > 255) sequenceNumber = 0; - for (size_t hardware_output = 0; hardware_output < sizeof(hardware_outputs)/sizeof(size_t); hardware_output++) { if (bufferOffset > length * (isRGBW?4:3)) return 1; // stop when we hit end of LEDs @@ -893,6 +889,16 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); return 1; // borked + } else { + // https://art-net.org.uk/how-it-works/streaming-packets/artnzs-packet-definition/ + // Art-Net spec says: + // "The generating device increments this number for every packet sent to a + // specific Port-Address. The number increments from 1 to 255 and then rolls + // over to 1 and repeats. This is because the value 0 is reserved to show that + // Sequence is not implemented." + sequenceNumber++; + if (sequenceNumber == 0) sequenceNumber = 1; // 0 is reserved in Art-Net for "we're not using sequence numbers" + if (sequenceNumber > 255) sequenceNumber = 1; } size_t packetSize = ARTNET_CHANNELS_PER_PACKET; From 42926f629ec3d670680ab108d8fadf20a98fe0d5 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:09:30 -0400 Subject: [PATCH 016/193] Revert. Art-Net compliance app complained about missing packets due to sequence numbers. --- wled00/udp.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 463f0ce308..27924b762c 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -876,6 +876,10 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 size_t bufferOffset = 0; size_t hardware_output_universe = 0; + sequenceNumber++; + + if (sequenceNumber > 255) sequenceNumber = 1; + for (size_t hardware_output = 0; hardware_output < sizeof(hardware_outputs)/sizeof(size_t); hardware_output++) { if (bufferOffset > length * (isRGBW?4:3)) return 1; // stop when we hit end of LEDs @@ -889,16 +893,6 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); return 1; // borked - } else { - // https://art-net.org.uk/how-it-works/streaming-packets/artnzs-packet-definition/ - // Art-Net spec says: - // "The generating device increments this number for every packet sent to a - // specific Port-Address. The number increments from 1 to 255 and then rolls - // over to 1 and repeats. This is because the value 0 is reserved to show that - // Sequence is not implemented." - sequenceNumber++; - if (sequenceNumber == 0) sequenceNumber = 1; // 0 is reserved in Art-Net for "we're not using sequence numbers" - if (sequenceNumber > 255) sequenceNumber = 1; } size_t packetSize = ARTNET_CHANNELS_PER_PACKET; From 3987960f272a34e7c742ff9f97aa87c2911f000d Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:10:53 -0400 Subject: [PATCH 017/193] Make sure "0" is never a sequence number --- wled00/udp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 27924b762c..4552d6249b 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -878,6 +878,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 sequenceNumber++; + if (sequenceNumber == 0) sequenceNumber = 1; // just in case, as 0 is considered "Sequence not in use" if (sequenceNumber > 255) sequenceNumber = 1; for (size_t hardware_output = 0; hardware_output < sizeof(hardware_outputs)/sizeof(size_t); hardware_output++) { From fe2958adf68a98d1a7cea5c59291020eb0fb696f Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:25:19 -0400 Subject: [PATCH 018/193] For my test setup --- wled00/udp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 4552d6249b..66791f484e 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -863,15 +863,15 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 // Default WLED-to-WLED Art-Net output // - const size_t hardware_outputs[1] = { length }; // specified in LED counts. "length" = all LEDs - const size_t hardware_outputs_universe_start[1] = { 0 }; // universe start # per output + // const size_t hardware_outputs[1] = { length }; // specified in LED counts. "length" = all LEDs + // const size_t hardware_outputs_universe_start[1] = { 0 }; // universe start # per output // Example of more than 1 output, currently you can only hard-code this kind of setup here. // You get 170 RGB LEDs per universe (128 RGBW) so the receiving hardware needs to be configured correctly. // The H807SA, for example, only allows one global setting of Art-Net universes-per-output. // - // const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts - // const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output + const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts + const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output size_t bufferOffset = 0; size_t hardware_output_universe = 0; From c8cfa9df4f63ae53b81a731041c7b3dafe5a4868 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu, 18 Apr 2024 10:42:53 -0400 Subject: [PATCH 019/193] DDP port fix --- wled00/udp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 66791f484e..78816ecc25 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -771,7 +771,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 0: // DDP { #if defined WLED_USE_ETHERNET && !defined ESP8266 - ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + ddpUdp.begin(Network.localIP(),DDP_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. #endif // calculate the number of UDP packets we need to send From d1da20829416ce747c68bbc1d60f3c7fc46c33d1 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:58:54 -0400 Subject: [PATCH 020/193] Network Event fixes --- wled00/network.cpp | 91 ++++++++++++++++++--- wled00/src/dependencies/network/Network.cpp | 10 +-- wled00/wled.cpp | 4 +- wled00/wled.h | 2 +- 4 files changed, 86 insertions(+), 21 deletions(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 3ca8e3906d..29be00b9a3 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -159,21 +159,83 @@ int getSignalQuality(int rssi) return quality; } +const String ARDUINO_EVENT_LIST[41] = { + "ARDUINO_EVENT_WIFI_READY", + "ARDUINO_EVENT_WIFI_SCAN_DONE", + "ARDUINO_EVENT_WIFI_STA_START", + "ARDUINO_EVENT_WIFI_STA_STOP", + "ARDUINO_EVENT_WIFI_STA_CONNECTED", + "ARDUINO_EVENT_WIFI_STA_DISCONNECTED", + "ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE", + "ARDUINO_EVENT_WIFI_STA_GOT_IP", + "ARDUINO_EVENT_WIFI_STA_GOT_IP6", + "ARDUINO_EVENT_WIFI_STA_LOST_IP", + "ARDUINO_EVENT_WIFI_AP_START", + "ARDUINO_EVENT_WIFI_AP_STOP", + "ARDUINO_EVENT_WIFI_AP_STACONNECTED", + "ARDUINO_EVENT_WIFI_AP_STADISCONNECTED", + "ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED", + "ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED", + "ARDUINO_EVENT_WIFI_AP_GOT_IP6", + "ARDUINO_EVENT_WIFI_FTM_REPORT", + "ARDUINO_EVENT_ETH_START", + "ARDUINO_EVENT_ETH_STOP", + "ARDUINO_EVENT_ETH_CONNECTED", + "ARDUINO_EVENT_ETH_DISCONNECTED", + "ARDUINO_EVENT_ETH_GOT_IP", + "ARDUINO_EVENT_ETH_GOT_IP6", + "ARDUINO_EVENT_WPS_ER_SUCCESS", + "ARDUINO_EVENT_WPS_ER_FAILED", + "ARDUINO_EVENT_WPS_ER_TIMEOUT", + "ARDUINO_EVENT_WPS_ER_PIN", + "ARDUINO_EVENT_WPS_ER_PBC_OVERLAP", + "ARDUINO_EVENT_SC_SCAN_DONE", + "ARDUINO_EVENT_SC_FOUND_CHANNEL", + "ARDUINO_EVENT_SC_GOT_SSID_PSWD", + "ARDUINO_EVENT_SC_SEND_ACK_DONE", + "ARDUINO_EVENT_PROV_INIT", + "ARDUINO_EVENT_PROV_DEINIT", + "ARDUINO_EVENT_PROV_START", + "ARDUINO_EVENT_PROV_END", + "ARDUINO_EVENT_PROV_CRED_RECV", + "ARDUINO_EVENT_PROV_CRED_FAIL", + "ARDUINO_EVENT_PROV_CRED_SUCCESS", + "ARDUINO_EVENT_MAX" +}; + +// Handle network events +void WiFiEvent(WiFiEvent_t event) { + + DEBUG_PRINT(F("Network Event: ")); + DEBUG_PRINT(ARDUINO_EVENT_LIST[event]); + DEBUG_PRINT(F(" = ")); -//handle Ethernet connection event -void WiFiEvent(WiFiEvent_t event) -{ switch (event) { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - case SYSTEM_EVENT_ETH_START: - DEBUG_PRINTLN(F("ETH Started")); + + case ARDUINO_EVENT_WIFI_STA_GOT_IP: + if (Network.isEthernet()) { + if (!apActive) { + DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Disabling WIFi")); + WiFi.disconnect(true); + } else { + DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Leaving AP WiFi active")); + } + } else { + DEBUG_PRINTLN(F("WiFi Connected. No ETH")); + } break; - case SYSTEM_EVENT_ETH_CONNECTED: - { - DEBUG_PRINTLN(F("ETH Connected")); + + case ARDUINO_EVENT_ETH_GOT_IP: if (!apActive) { + DEBUG_PRINTLN(F("ETH is up. Disabling WIFi")); WiFi.disconnect(true); + } else { + DEBUG_PRINTLN(F("ETH is up. Leaving AP WiFi Active")); } + break; + + case ARDUINO_EVENT_ETH_CONNECTED: // was SYSTEM_EVENT_ETH_CONNECTED: + DEBUG_PRINTLN(F("ETH connected. Setting up ETH")); if (staticIP != (uint32_t)0x00000000 && staticGateway != (uint32_t)0x00000000) { ETH.config(staticIP, staticGateway, staticSubnet, IPAddress(8, 8, 8, 8)); } else { @@ -185,9 +247,9 @@ void WiFiEvent(WiFiEvent_t event) ETH.setHostname(hostname); showWelcomePage = false; break; - } - case SYSTEM_EVENT_ETH_DISCONNECTED: - DEBUG_PRINTLN(F("ETH Disconnected")); + + case ARDUINO_EVENT_ETH_DISCONNECTED: // was SYSTEM_EVENT_ETH_DISCONNECTED: + DEBUG_PRINTLN(F("ETH Disconnected. Forcing reconnect")); // This doesn't really affect ethernet per se, // as it's only configured once. Rather, it // may be necessary to reconnect the WiFi when @@ -195,9 +257,12 @@ void WiFiEvent(WiFiEvent_t event) // alternative access to the device. forceReconnect = true; break; -#endif + default: + DEBUG_PRINTLN(F("No action")); break; + } + } diff --git a/wled00/src/dependencies/network/Network.cpp b/wled00/src/dependencies/network/Network.cpp index d86bf127fd..40dbf8edf4 100644 --- a/wled00/src/dependencies/network/Network.cpp +++ b/wled00/src/dependencies/network/Network.cpp @@ -3,7 +3,7 @@ IPAddress NetworkClass::localIP() { IPAddress localIP; -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) localIP = ETH.localIP(); if (localIP[0] != 0) { return localIP; @@ -19,7 +19,7 @@ IPAddress NetworkClass::localIP() IPAddress NetworkClass::subnetMask() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { return ETH.subnetMask(); } @@ -32,7 +32,7 @@ IPAddress NetworkClass::subnetMask() IPAddress NetworkClass::gatewayIP() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { return ETH.gatewayIP(); } @@ -45,7 +45,7 @@ IPAddress NetworkClass::gatewayIP() void NetworkClass::localMAC(uint8_t* MAC) { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) // ETH.macAddress(MAC); // Does not work because of missing ETHClass:: in ETH.ccp // Start work around @@ -73,7 +73,7 @@ void NetworkClass::localMAC(uint8_t* MAC) bool NetworkClass::isConnected() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || ETH.localIP()[0] != 0; #else return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED); diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 15656e093d..b08c1f51b1 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1325,10 +1325,10 @@ void WLED::handleConnection() } if (forceReconnect) { USER_PRINTLN(F("Forcing reconnect.")); - initConnection(); interfacesInited = false; forceReconnect = false; wasConnected = false; + initConnection(); return; } if (!Network.isConnected()) { @@ -1355,7 +1355,7 @@ void WLED::handleConnection() DEBUG_PRINTLN(""); USER_PRINT(F("Connected! IP address: ")); USER_PRINT(Network.localIP()); - if (successfullyConfiguredEthernet) { + if (Network.isEthernet()) { USER_PRINTLN(" via Ethernet"); } else { USER_PRINTLN(" via WiFi"); diff --git a/wled00/wled.h b/wled00/wled.h index 2499bfd0ac..4f5edc7ee2 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -877,7 +877,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); WLED_GLOBAL unsigned long loops _INIT(0); #endif -#ifdef ARDUINO_ARCH_ESP32 +#if defined ARDUINO_ARCH_ESP32 || defined ARDUINO_ARCH_ESP32S3 #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED || ETH.localIP()[0] != 0) #else #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) From 8d3af36aa89201f9682cedd7d2a6fe94ce761f8a Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:58:54 -0400 Subject: [PATCH 021/193] Network Event fixes --- wled00/network.cpp | 91 ++++++++++++++++++--- wled00/src/dependencies/network/Network.cpp | 10 +-- wled00/wled.cpp | 4 +- wled00/wled.h | 2 +- 4 files changed, 86 insertions(+), 21 deletions(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 3ca8e3906d..29be00b9a3 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -159,21 +159,83 @@ int getSignalQuality(int rssi) return quality; } +const String ARDUINO_EVENT_LIST[41] = { + "ARDUINO_EVENT_WIFI_READY", + "ARDUINO_EVENT_WIFI_SCAN_DONE", + "ARDUINO_EVENT_WIFI_STA_START", + "ARDUINO_EVENT_WIFI_STA_STOP", + "ARDUINO_EVENT_WIFI_STA_CONNECTED", + "ARDUINO_EVENT_WIFI_STA_DISCONNECTED", + "ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE", + "ARDUINO_EVENT_WIFI_STA_GOT_IP", + "ARDUINO_EVENT_WIFI_STA_GOT_IP6", + "ARDUINO_EVENT_WIFI_STA_LOST_IP", + "ARDUINO_EVENT_WIFI_AP_START", + "ARDUINO_EVENT_WIFI_AP_STOP", + "ARDUINO_EVENT_WIFI_AP_STACONNECTED", + "ARDUINO_EVENT_WIFI_AP_STADISCONNECTED", + "ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED", + "ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED", + "ARDUINO_EVENT_WIFI_AP_GOT_IP6", + "ARDUINO_EVENT_WIFI_FTM_REPORT", + "ARDUINO_EVENT_ETH_START", + "ARDUINO_EVENT_ETH_STOP", + "ARDUINO_EVENT_ETH_CONNECTED", + "ARDUINO_EVENT_ETH_DISCONNECTED", + "ARDUINO_EVENT_ETH_GOT_IP", + "ARDUINO_EVENT_ETH_GOT_IP6", + "ARDUINO_EVENT_WPS_ER_SUCCESS", + "ARDUINO_EVENT_WPS_ER_FAILED", + "ARDUINO_EVENT_WPS_ER_TIMEOUT", + "ARDUINO_EVENT_WPS_ER_PIN", + "ARDUINO_EVENT_WPS_ER_PBC_OVERLAP", + "ARDUINO_EVENT_SC_SCAN_DONE", + "ARDUINO_EVENT_SC_FOUND_CHANNEL", + "ARDUINO_EVENT_SC_GOT_SSID_PSWD", + "ARDUINO_EVENT_SC_SEND_ACK_DONE", + "ARDUINO_EVENT_PROV_INIT", + "ARDUINO_EVENT_PROV_DEINIT", + "ARDUINO_EVENT_PROV_START", + "ARDUINO_EVENT_PROV_END", + "ARDUINO_EVENT_PROV_CRED_RECV", + "ARDUINO_EVENT_PROV_CRED_FAIL", + "ARDUINO_EVENT_PROV_CRED_SUCCESS", + "ARDUINO_EVENT_MAX" +}; + +// Handle network events +void WiFiEvent(WiFiEvent_t event) { + + DEBUG_PRINT(F("Network Event: ")); + DEBUG_PRINT(ARDUINO_EVENT_LIST[event]); + DEBUG_PRINT(F(" = ")); -//handle Ethernet connection event -void WiFiEvent(WiFiEvent_t event) -{ switch (event) { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - case SYSTEM_EVENT_ETH_START: - DEBUG_PRINTLN(F("ETH Started")); + + case ARDUINO_EVENT_WIFI_STA_GOT_IP: + if (Network.isEthernet()) { + if (!apActive) { + DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Disabling WIFi")); + WiFi.disconnect(true); + } else { + DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Leaving AP WiFi active")); + } + } else { + DEBUG_PRINTLN(F("WiFi Connected. No ETH")); + } break; - case SYSTEM_EVENT_ETH_CONNECTED: - { - DEBUG_PRINTLN(F("ETH Connected")); + + case ARDUINO_EVENT_ETH_GOT_IP: if (!apActive) { + DEBUG_PRINTLN(F("ETH is up. Disabling WIFi")); WiFi.disconnect(true); + } else { + DEBUG_PRINTLN(F("ETH is up. Leaving AP WiFi Active")); } + break; + + case ARDUINO_EVENT_ETH_CONNECTED: // was SYSTEM_EVENT_ETH_CONNECTED: + DEBUG_PRINTLN(F("ETH connected. Setting up ETH")); if (staticIP != (uint32_t)0x00000000 && staticGateway != (uint32_t)0x00000000) { ETH.config(staticIP, staticGateway, staticSubnet, IPAddress(8, 8, 8, 8)); } else { @@ -185,9 +247,9 @@ void WiFiEvent(WiFiEvent_t event) ETH.setHostname(hostname); showWelcomePage = false; break; - } - case SYSTEM_EVENT_ETH_DISCONNECTED: - DEBUG_PRINTLN(F("ETH Disconnected")); + + case ARDUINO_EVENT_ETH_DISCONNECTED: // was SYSTEM_EVENT_ETH_DISCONNECTED: + DEBUG_PRINTLN(F("ETH Disconnected. Forcing reconnect")); // This doesn't really affect ethernet per se, // as it's only configured once. Rather, it // may be necessary to reconnect the WiFi when @@ -195,9 +257,12 @@ void WiFiEvent(WiFiEvent_t event) // alternative access to the device. forceReconnect = true; break; -#endif + default: + DEBUG_PRINTLN(F("No action")); break; + } + } diff --git a/wled00/src/dependencies/network/Network.cpp b/wled00/src/dependencies/network/Network.cpp index d86bf127fd..40dbf8edf4 100644 --- a/wled00/src/dependencies/network/Network.cpp +++ b/wled00/src/dependencies/network/Network.cpp @@ -3,7 +3,7 @@ IPAddress NetworkClass::localIP() { IPAddress localIP; -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) localIP = ETH.localIP(); if (localIP[0] != 0) { return localIP; @@ -19,7 +19,7 @@ IPAddress NetworkClass::localIP() IPAddress NetworkClass::subnetMask() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { return ETH.subnetMask(); } @@ -32,7 +32,7 @@ IPAddress NetworkClass::subnetMask() IPAddress NetworkClass::gatewayIP() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { return ETH.gatewayIP(); } @@ -45,7 +45,7 @@ IPAddress NetworkClass::gatewayIP() void NetworkClass::localMAC(uint8_t* MAC) { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) // ETH.macAddress(MAC); // Does not work because of missing ETHClass:: in ETH.ccp // Start work around @@ -73,7 +73,7 @@ void NetworkClass::localMAC(uint8_t* MAC) bool NetworkClass::isConnected() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || ETH.localIP()[0] != 0; #else return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED); diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 15656e093d..b08c1f51b1 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1325,10 +1325,10 @@ void WLED::handleConnection() } if (forceReconnect) { USER_PRINTLN(F("Forcing reconnect.")); - initConnection(); interfacesInited = false; forceReconnect = false; wasConnected = false; + initConnection(); return; } if (!Network.isConnected()) { @@ -1355,7 +1355,7 @@ void WLED::handleConnection() DEBUG_PRINTLN(""); USER_PRINT(F("Connected! IP address: ")); USER_PRINT(Network.localIP()); - if (successfullyConfiguredEthernet) { + if (Network.isEthernet()) { USER_PRINTLN(" via Ethernet"); } else { USER_PRINTLN(" via WiFi"); diff --git a/wled00/wled.h b/wled00/wled.h index 2499bfd0ac..4f5edc7ee2 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -877,7 +877,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); WLED_GLOBAL unsigned long loops _INIT(0); #endif -#ifdef ARDUINO_ARCH_ESP32 +#if defined ARDUINO_ARCH_ESP32 || defined ARDUINO_ARCH_ESP32S3 #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED || ETH.localIP()[0] != 0) #else #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) From 5d36aa8710ba2568dc382670410a05688d4fd7c6 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:07:07 -0400 Subject: [PATCH 022/193] Check for ethernet support --- wled00/network.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 29be00b9a3..145399778b 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -225,6 +225,7 @@ void WiFiEvent(WiFiEvent_t event) { } break; + #ifdef WLED_USE_ETHERNET case ARDUINO_EVENT_ETH_GOT_IP: if (!apActive) { DEBUG_PRINTLN(F("ETH is up. Disabling WIFi")); @@ -257,7 +258,7 @@ void WiFiEvent(WiFiEvent_t event) { // alternative access to the device. forceReconnect = true; break; - + #endif default: DEBUG_PRINTLN(F("No action")); break; From 494a0f67e1f890888205d01ab3c121958120bd85 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:12:06 -0400 Subject: [PATCH 023/193] Confirm we have an event list included in build --- wled00/network.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 145399778b..2871d17221 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -211,7 +211,7 @@ void WiFiEvent(WiFiEvent_t event) { DEBUG_PRINT(F(" = ")); switch (event) { - + #ifdef ARDUINO_EVENT_WIFI_STA_GOT_IP case ARDUINO_EVENT_WIFI_STA_GOT_IP: if (Network.isEthernet()) { if (!apActive) { @@ -259,6 +259,7 @@ void WiFiEvent(WiFiEvent_t event) { forceReconnect = true; break; #endif + #endif default: DEBUG_PRINTLN(F("No action")); break; From bbb82e22aa73dc3608d56b3466e3c31414a07137 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:17:00 -0400 Subject: [PATCH 024/193] Testing a build fix --- wled00/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 2871d17221..834f0e55be 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -211,7 +211,7 @@ void WiFiEvent(WiFiEvent_t event) { DEBUG_PRINT(F(" = ")); switch (event) { - #ifdef ARDUINO_EVENT_WIFI_STA_GOT_IP + #ifdef ESP32WIFIGENERIC_H_ case ARDUINO_EVENT_WIFI_STA_GOT_IP: if (Network.isEthernet()) { if (!apActive) { From 2d2d300e0f6c2f22267643aa29880dfd03cbea53 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:21:20 -0400 Subject: [PATCH 025/193] Testing build fixes for IDF below 4.0.0 --- wled00/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 834f0e55be..d1182d00a0 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -211,7 +211,7 @@ void WiFiEvent(WiFiEvent_t event) { DEBUG_PRINT(F(" = ")); switch (event) { - #ifdef ESP32WIFIGENERIC_H_ + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) case ARDUINO_EVENT_WIFI_STA_GOT_IP: if (Network.isEthernet()) { if (!apActive) { From 8d54d6a437f96def3d3e0eb9c70b89882c26fc3c Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:25:57 -0400 Subject: [PATCH 026/193] Testing build fixes --- wled00/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index d1182d00a0..549cf5bbbc 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -211,7 +211,7 @@ void WiFiEvent(WiFiEvent_t event) { DEBUG_PRINT(F(" = ")); switch (event) { - #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) + #if !defined (ESP8266) && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) case ARDUINO_EVENT_WIFI_STA_GOT_IP: if (Network.isEthernet()) { if (!apActive) { From 16c782c0769870c61f0a4877c7eacce6465b9d89 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:30:50 -0400 Subject: [PATCH 027/193] Testing build fixes --- wled00/network.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 549cf5bbbc..45827757be 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -211,7 +211,8 @@ void WiFiEvent(WiFiEvent_t event) { DEBUG_PRINT(F(" = ")); switch (event) { - #if !defined (ESP8266) && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) + #ifndef ESP8266 + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) case ARDUINO_EVENT_WIFI_STA_GOT_IP: if (Network.isEthernet()) { if (!apActive) { @@ -260,6 +261,7 @@ void WiFiEvent(WiFiEvent_t event) { break; #endif #endif + #endif default: DEBUG_PRINTLN(F("No action")); break; From df2d327e0e09fd14eb5a628f99293b662b599c9e Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:40:55 -0400 Subject: [PATCH 028/193] Revert "Merge branch 'W5500+Art-Net_Improvements' into W5500_Support" This reverts commit b7acc6a687e3f89863f4a0cc636fdfe278c76136, reversing changes made to f51290c0d97fb395265405572083ba9c491c0a7d. --- wled00/bus_manager.cpp | 61 +++------------------ wled00/bus_manager.h | 8 +-- wled00/network.cpp | 1 + wled00/udp.cpp | 117 +++++++++++++---------------------------- 4 files changed, 48 insertions(+), 139 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index f3604b41d3..3801c534de 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -393,7 +393,8 @@ uint8_t BusOnOff::getPins(uint8_t* pinArray) { return 1; } -BusNetwork::BusNetwork(BusConfig &bc, const ColorOrderMap &com) : Bus(bc.type, bc.start, bc.autoWhite), _colorOrderMap(com) { + +BusNetwork::BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { _valid = false; switch (bc.type) { case TYPE_NET_ARTNET_RGB: @@ -424,62 +425,16 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { if (hasWhite()) c = autoWhiteCalc(c); if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT uint16_t offset = pix * _UDPchannels; - uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder); - if (_colorOrder != co) { - if (co == COL_ORDER_GRB) { - _data[offset] = G(c); - _data[offset+1] = R(c); - _data[offset+2] = B(c); - } else if (co == COL_ORDER_RGB) { - _data[offset] = R(c); - _data[offset+1] = G(c); - _data[offset+2] = B(c); - } else if (co == COL_ORDER_BRG) { - _data[offset] = B(c); - _data[offset+1] = R(c); - _data[offset+2] = G(c); - } else if (co == COL_ORDER_RBG) { - _data[offset] = R(c); - _data[offset+1] = B(c); - _data[offset+2] = G(c); - } else if (co == COL_ORDER_GBR) { - _data[offset] = G(c); - _data[offset+1] = B(c); - _data[offset+2] = R(c); - } else if (co == COL_ORDER_BGR) { - _data[offset] = B(c); - _data[offset+1] = G(c); - _data[offset+2] = R(c); - } - if (_rgbw) _data[offset+3] = W(c); - } else { - _data[offset] = R(c); - _data[offset+1] = G(c); - _data[offset+2] = B(c); - if (_rgbw) _data[offset+3] = W(c); - } + _data[offset] = R(c); + _data[offset+1] = G(c); + _data[offset+2] = B(c); + if (_rgbw) _data[offset+3] = W(c); } uint32_t BusNetwork::getPixelColor(uint16_t pix) { if (!_valid || pix >= _len) return 0; uint16_t offset = pix * _UDPchannels; - uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder); - if (_colorOrder != co) { - if (co == COL_ORDER_GRB) { - return RGBW32(_data[offset+1], _data[offset+0], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); - } else if (co == COL_ORDER_RGB) { - return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); - } else if (co == COL_ORDER_BRG) { - return RGBW32(_data[offset+2], _data[offset+0], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); - } else if (co == COL_ORDER_RBG) { - return RGBW32(_data[offset+0], _data[offset+2], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); - } else if (co == COL_ORDER_GBR) { - return RGBW32(_data[offset+1], _data[offset+2], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); - } else if (co == COL_ORDER_BGR) { - return RGBW32(_data[offset+2], _data[offset+1], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); - } - } - return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + return RGBW32(_data[offset], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); } void BusNetwork::show() { @@ -756,7 +711,7 @@ int BusManager::add(BusConfig &bc) { if (getNumBusses() - getNumVirtualBusses() >= WLED_MAX_BUSSES) return -1; USER_PRINTF("BusManager::add(bc.type=%u)\n", bc.type); if (bc.type >= TYPE_NET_DDP_RGB && bc.type < 96) { - busses[numBusses] = new BusNetwork(bc,colorOrderMap); + busses[numBusses] = new BusNetwork(bc); #ifdef WLED_ENABLE_HUB75MATRIX } else if (bc.type >= TYPE_HUB75MATRIX && bc.type <= (TYPE_HUB75MATRIX + 10)) { USER_PRINTLN("BusManager::add - Adding BusHub75Matrix"); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 5c7374f807..f089b52985 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -295,7 +295,7 @@ class BusOnOff : public Bus { class BusNetwork : public Bus { public: - BusNetwork(BusConfig &bc, const ColorOrderMap &com); + BusNetwork(BusConfig &bc); uint16_t getMaxPixels() override { return 4096; }; bool hasRGB() { return true; } @@ -318,10 +318,6 @@ class BusNetwork : public Bus { return _len; } - uint8_t getColorOrder() { - return _colorOrder; - } - void cleanup(); ~BusNetwork() { @@ -335,8 +331,6 @@ class BusNetwork : public Bus { bool _rgbw; bool _broadcastLock; byte *_data; - uint8_t _colorOrder = COL_ORDER_RGB; - const ColorOrderMap &_colorOrderMap; }; #ifdef WLED_ENABLE_HUB75MATRIX diff --git a/wled00/network.cpp b/wled00/network.cpp index 8aee8a2452..45827757be 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -225,6 +225,7 @@ void WiFiEvent(WiFiEvent_t event) { DEBUG_PRINTLN(F("WiFi Connected. No ETH")); } break; + #ifdef WLED_USE_ETHERNET case ARDUINO_EVENT_ETH_GOT_IP: if (!apActive) { diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 78816ecc25..0a2d53324b 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -770,10 +770,6 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 switch (type) { case 0: // DDP { - #if defined WLED_USE_ETHERNET && !defined ESP8266 - ddpUdp.begin(Network.localIP(),DDP_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. - #endif - // calculate the number of UDP packets we need to send size_t channelCount = length * (isRGBW? 4:3); // 1 channel for every R,G,B value size_t packetCount = ((channelCount-1) / DDP_CHANNELS_PER_PACKET) +1; @@ -842,95 +838,58 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 2: //ArtNet { - #if defined WLED_USE_ETHERNET && !defined ESP8266 - ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. - #endif - /* - We don't really care about the number of universes - just how many hardware outputs we have. - - WLED rendering Art-Net data considers itself to be 1 hardware output with many universes - but - many Art-Net controllers like the H807SA can be manually set to "X universes per output." - - We need to know the channels per output so we can break the pixel data across physically attached universes. - - The H807SA obeys the "510 channels for RGB" rule like WLED and xLights - some other controllers do not care, - but we're not supporting those here. If you run into one of these, override ARTNET_CHANNELS_PER_PACKET to 512. - - We're expecting equal numbers of channels per output, common for controllers like the H807SA - at some point - we could consider an Art-Net mapping system to adjust universe starts for weird wiring situations. - */ + // calculate the number of UDP packets we need to send + const size_t channelCount = length * (isRGBW?4:3); // 1 channel for every R,G,B,(W?) value const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs + const size_t packetCount = ((channelCount-1)/ARTNET_CHANNELS_PER_PACKET)+1; - // Default WLED-to-WLED Art-Net output - // - // const size_t hardware_outputs[1] = { length }; // specified in LED counts. "length" = all LEDs - // const size_t hardware_outputs_universe_start[1] = { 0 }; // universe start # per output - - // Example of more than 1 output, currently you can only hard-code this kind of setup here. - // You get 170 RGB LEDs per universe (128 RGBW) so the receiving hardware needs to be configured correctly. - // The H807SA, for example, only allows one global setting of Art-Net universes-per-output. - // - const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts - const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output - + uint32_t channel = 0; size_t bufferOffset = 0; - size_t hardware_output_universe = 0; - - sequenceNumber++; - if (sequenceNumber == 0) sequenceNumber = 1; // just in case, as 0 is considered "Sequence not in use" - if (sequenceNumber > 255) sequenceNumber = 1; + sequenceNumber++; - for (size_t hardware_output = 0; hardware_output < sizeof(hardware_outputs)/sizeof(size_t); hardware_output++) { - - if (bufferOffset > length * (isRGBW?4:3)) return 1; // stop when we hit end of LEDs + for (size_t currentPacket = 0; currentPacket < packetCount; currentPacket++) { - hardware_output_universe = hardware_outputs_universe_start[hardware_output]; + if (sequenceNumber > 255) sequenceNumber = 0; - size_t channels_remaining = hardware_outputs[hardware_output] * (isRGBW?4:3); + if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { + DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); + return 1; // borked + } - while (channels_remaining > 0) { + size_t packetSize = ARTNET_CHANNELS_PER_PACKET; - if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { - DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); - return 1; // borked + if (currentPacket == (packetCount - 1U)) { + // last packet + if (channelCount % ARTNET_CHANNELS_PER_PACKET) { + packetSize = channelCount % ARTNET_CHANNELS_PER_PACKET; } + } - size_t packetSize = ARTNET_CHANNELS_PER_PACKET; - - if (channels_remaining < ARTNET_CHANNELS_PER_PACKET) { - packetSize = channels_remaining; - channels_remaining = 0; - } else { - channels_remaining -= packetSize; - } + byte header_buffer[ART_NET_HEADER_SIZE]; + memcpy_P(header_buffer, ART_NET_HEADER, ART_NET_HEADER_SIZE); + ddpUdp.write(header_buffer, ART_NET_HEADER_SIZE); // This doesn't change. Hard coded ID, OpCode, and protocol version. + ddpUdp.write(sequenceNumber & 0xFF); // sequence number. 1..255 + ddpUdp.write(0x00); // physical - more an FYI, not really used for anything. 0..3 + ddpUdp.write((currentPacket) & 0xFF); // Universe LSB. 1 full packet == 1 full universe, so just use current packet number. + ddpUdp.write(0x00); // Universe MSB, unused. + ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB + ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB - byte header_buffer[ART_NET_HEADER_SIZE]; - memcpy_P(header_buffer, ART_NET_HEADER, ART_NET_HEADER_SIZE); - ddpUdp.write(header_buffer, ART_NET_HEADER_SIZE); // This doesn't change. Hard coded ID, OpCode, and protocol version. - ddpUdp.write(sequenceNumber & 0xFF); // sequence number. 1..255 - ddpUdp.write(0x00); // physical - more an FYI, not really used for anything. 0..3 - ddpUdp.write(hardware_output_universe & 0xFF); // Universe LSB. 1 full packet == 1 full universe. - ddpUdp.write(0x00); // Universe MSB, unused. - ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB - ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB - - for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { - // "Color Order Override" works on top of this if you need to change the color order before sending. - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B - if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // W - } + for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B + if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // W + } - if (!ddpUdp.endPacket()) { - DEBUG_PRINTLN(F("Art-Net WiFiUDP.endPacket returned an error")); - return 1; // borked - } - hardware_output_universe++; + if (!ddpUdp.endPacket()) { + DEBUG_PRINTLN(F("Art-Net WiFiUDP.endPacket returned an error")); + return 1; // borked } - } break; - } + channel += packetSize; + } + } break; } return 0; } From 67f7b0cc510ecd2515ee7cc9a4bfeabcf79ccc06 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:49:05 -0400 Subject: [PATCH 029/193] Don't use ETHClass2 on S3 unless WLED_USE_ETHERNET --- wled00/src/dependencies/network/Network.h | 2 +- wled00/wled.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/src/dependencies/network/Network.h b/wled00/src/dependencies/network/Network.h index dac3c8706b..c9f3b415e2 100644 --- a/wled00/src/dependencies/network/Network.h +++ b/wled00/src/dependencies/network/Network.h @@ -1,6 +1,6 @@ #ifdef ESP8266 #include -#elif CONFIG_IDF_TARGET_ESP32S3 +#elif defined (CONFIG_IDF_TARGET_ESP32S3) && defined (WLED_USE_ETHERNET) #include #include #define ETH ETH2 diff --git a/wled00/wled.h b/wled00/wled.h index 171ccc45be..687ea1b0bb 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -106,7 +106,7 @@ #else // ESP32 #include // ensure we have the correct "Serial" on new MCUs (depends on ARDUINO_USB_MODE and ARDUINO_USB_CDC_ON_BOOT) #include - #ifdef CONFIG_IDF_TARGET_ESP32S3 + #if defined (CONFIG_IDF_TARGET_ESP32S3) && defined (WLED_USE_ETHERNET) #include #else // ESP32 #include From 1c835b0e5f49713af0a9023489eae8461e1f682b Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:57:54 -0400 Subject: [PATCH 030/193] Don't use TroyHacksAsyncUDP on S3 unless WLED_USE_ETHERNET --- wled00/src/dependencies/e131/ESPAsyncE131.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/src/dependencies/e131/ESPAsyncE131.h b/wled00/src/dependencies/e131/ESPAsyncE131.h index 204395ef4e..ed9b6e381a 100644 --- a/wled00/src/dependencies/e131/ESPAsyncE131.h +++ b/wled00/src/dependencies/e131/ESPAsyncE131.h @@ -28,7 +28,7 @@ #ifdef ESP32 #include -#ifdef ARDUINO_ARCH_ESP32S3 +#if defined (ARDUINO_ARCH_ESP32S3) && defined (WLED_USE_ETHERNET) #include // backport some fixes from 5.1 to 4.4 #else #include From e4fa27a4a2dbba911a06207965e48b903445d80e Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 23:07:38 -0400 Subject: [PATCH 031/193] Squashed commit of the following: commit 1c835b0e5f49713af0a9023489eae8461e1f682b Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:57:54 2024 -0400 Don't use TroyHacksAsyncUDP on S3 unless WLED_USE_ETHERNET commit 67f7b0cc510ecd2515ee7cc9a4bfeabcf79ccc06 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:49:05 2024 -0400 Don't use ETHClass2 on S3 unless WLED_USE_ETHERNET commit df2d327e0e09fd14eb5a628f99293b662b599c9e Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:40:55 2024 -0400 Revert "Merge branch 'W5500+Art-Net_Improvements' into W5500_Support" This reverts commit b7acc6a687e3f89863f4a0cc636fdfe278c76136, reversing changes made to f51290c0d97fb395265405572083ba9c491c0a7d. commit b7acc6a687e3f89863f4a0cc636fdfe278c76136 Merge: f51290c0 b000c6df Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:36:39 2024 -0400 Merge branch 'W5500+Art-Net_Improvements' into W5500_Support commit b000c6dff0da62c4e07600ce945d515eb570b56e Merge: d1da2082 34f4905e Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:32:19 2024 -0400 Merge branch 'MoonModules:mdev' into W5500+Art-Net_Improvements commit f51290c0d97fb395265405572083ba9c491c0a7d Merge: 16c782c0 34f4905e Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:32:10 2024 -0400 Merge branch 'MoonModules:mdev' into W5500_Support commit 16c782c0769870c61f0a4877c7eacce6465b9d89 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:30:50 2024 -0400 Testing build fixes commit 8d54d6a437f96def3d3e0eb9c70b89882c26fc3c Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:25:57 2024 -0400 Testing build fixes commit 2d2d300e0f6c2f22267643aa29880dfd03cbea53 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:21:20 2024 -0400 Testing build fixes for IDF below 4.0.0 commit bbb82e22aa73dc3608d56b3466e3c31414a07137 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 11:17:00 2024 -0400 Testing a build fix commit 494a0f67e1f890888205d01ab3c121958120bd85 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 09:12:06 2024 -0400 Confirm we have an event list included in build commit 5d36aa8710ba2568dc382670410a05688d4fd7c6 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 09:07:07 2024 -0400 Check for ethernet support commit 8d3af36aa89201f9682cedd7d2a6fe94ce761f8a Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 08:58:54 2024 -0400 Network Event fixes commit d1da20829416ce747c68bbc1d60f3c7fc46c33d1 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 08:58:54 2024 -0400 Network Event fixes commit c8cfa9df4f63ae53b81a731041c7b3dafe5a4868 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 10:42:53 2024 -0400 DDP port fix commit fe2958adf68a98d1a7cea5c59291020eb0fb696f Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 09:25:19 2024 -0400 For my test setup commit 09da8cb46cb3dcff0eee084d61edc68ce48047c1 Merge: e6d127de 3987960f Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 09:20:29 2024 -0400 Merge pull request #1 from troyhacks/Art-Net_Improvements Art net improvements commit 3987960f272a34e7c742ff9f97aa87c2911f000d Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 09:10:53 2024 -0400 Make sure "0" is never a sequence number commit 42926f629ec3d670680ab108d8fadf20a98fe0d5 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 09:09:30 2024 -0400 Revert. Art-Net compliance app complained about missing packets due to sequence numbers. commit e72a77977757cd00cc99b4ad2b6c6da7d57925f6 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 08:59:30 2024 -0400 Packet sequence numbering to Art-Net spec commit e6d127de0a24f0a4801228eedf37c717e395a38f Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 08:33:32 2024 -0400 Updated to ETHClass2 commit 16ee90bfba5d9fcbfbf77f5ce4d944eac362ca99 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed Apr 17 14:17:38 2024 -0400 Comments commit 5dde1f9840f3327e5d7591635a5084338a5ecf1b Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed Apr 17 14:16:24 2024 -0400 Bring in a fixed version of AsyncUDP commit 483daa945226cf444f8102a298e78696eb68d7f4 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed Apr 17 10:43:24 2024 -0400 Logic for new ethernet board commit 6b600135973c2d99263944b2d7128923b92cb0f4 Merge: 1c178866 0f79e9b7 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed Apr 17 10:05:06 2024 -0400 Merge branch 'MoonModules:mdev' into W5500_Support commit 2641dd57f3e0ff05af65f3699068c683f412981d Merge: f5b97f27 0f79e9b7 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed Apr 17 10:03:46 2024 -0400 Merge branch 'MoonModules:mdev' into Art-Net_Improvements commit f5b97f27b5a3b4548aaf89a667c7ab4408895743 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Apr 15 10:18:20 2024 -0400 Force routing only on non-ESP8266 commit 3f574a9d7677eff5e31290cbd53789c78e0f4f44 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 4 10:33:34 2024 -0400 Force use of Ethernet if configured. commit 549f0141f85b45672fa95601bc053704a3b81dad Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 4 09:42:24 2024 -0400 Start of custom mapping ability commit 334884a0b24984e012d80c24fec255bb9c209bc2 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Sat Mar 30 08:45:00 2024 -0400 Forgot BGR and default RGB order commit b1a099c158c2e47d48b1ec2e33cfd88800992a11 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 20:32:32 2024 -0400 Minor tidy. commit d398a4d62b20c34969322bbcdb7b10171736062b Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 20:16:17 2024 -0400 Comments fixed, minor code tidy/revert. commit 1a90b73a3a7e28376549ce967f9c0869d4425e83 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 19:57:56 2024 -0400 hardware_outputs back to 1 to not break defaults commit ddfa90a12b4623c765864e72ac2c7ce0026796cd Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 19:49:32 2024 -0400 Overhaul Art-Net to be more "professionally" good commit 1c178866555c76b47e58be7b58f72ef55dd2729d Merge: 9f3e4919 01c187f8 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Tue Jan 2 10:19:12 2024 -0600 Merge branch 'MoonModules:mdev' into W5500_Support commit 9f3e491960ed6256ccf120e6906f607dd928c24c Merge: cca00556 cdc8a485 Author: TroyHacks <5659019+troyhacks@users.noreply.github.com> Date: Mon Dec 11 09:29:47 2023 -0500 Merge branch 'W5500_Support' of https://github.com/troyhacks/WLED into W5500_Support commit cca0055611e9acc0b50f838fc94fe3ab916a3224 Author: TroyHacks <5659019+troyhacks@users.noreply.github.com> Date: Mon Dec 11 09:29:22 2023 -0500 Added WLED_DISABLE_MDNS for no really great reason commit cdc8a48572af654a5027785ee0377811142a3f98 Merge: c0a115ad 6cd9d80d Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Dec 7 00:03:42 2023 -0500 Merge branch 'MoonModules:mdev' into W5500_Support commit c0a115ada3ea79e47ac68a1ef45649e9075897be Author: TroyHacks <5659019+troyhacks@users.noreply.github.com> Date: Wed Dec 6 23:51:43 2023 -0500 Pin reservation and better include logic for S3 --- wled00/cfg.cpp | 2 + wled00/const.h | 3 +- wled00/data/settings_wifi.htm | 3 +- wled00/network.cpp | 99 +++++++++++++++++---- wled00/src/dependencies/e131/ESPAsyncE131.h | 4 + wled00/src/dependencies/network/Network.cpp | 10 +-- wled00/src/dependencies/network/Network.h | 4 + wled00/wled.cpp | 54 +++++++++-- wled00/wled.h | 12 ++- wled00/wled_ethernet.h | 2 + wled00/xml.cpp | 2 + 11 files changed, 163 insertions(+), 32 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 54c32f9c07..2474ad3401 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -746,6 +746,7 @@ void serializeConfig() { if (ethernetBoards[ethernetType].eth_power>=0) pins.add(ethernetBoards[ethernetType].eth_power); if (ethernetBoards[ethernetType].eth_mdc>=0) pins.add(ethernetBoards[ethernetType].eth_mdc); if (ethernetBoards[ethernetType].eth_mdio>=0) pins.add(ethernetBoards[ethernetType].eth_mdio); + #ifndef CONFIG_IDF_TARGET_ESP32S3 switch (ethernetBoards[ethernetType].eth_clk_mode) { case ETH_CLOCK_GPIO0_IN: case ETH_CLOCK_GPIO0_OUT: @@ -758,6 +759,7 @@ void serializeConfig() { pins.add(17); break; } + #endif } #endif diff --git a/wled00/const.h b/wled00/const.h index 14f419c224..628f8d2cea 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -280,7 +280,7 @@ #define BTN_TYPE_ANALOG_INVERTED 8 //Ethernet board types -#define WLED_NUM_ETH_TYPES 12 //WLEDMM +1 for Olimex ESP32-Gateway +#define WLED_NUM_ETH_TYPES 13 //WLEDMM +1 for Olimex ESP32-Gateway +1 for W5500 #define WLED_ETH_NONE 0 #define WLED_ETH_WT32_ETH01 1 @@ -294,6 +294,7 @@ #define WLED_ETH_ABCWLEDV43ETH 9 #define WLED_ETH_SERG74 10 #define WLED_ETH_OLIMEX_GTW 11 +#define WLED_ETH_W5500 12 //Hue error codes #define HUE_ERROR_INACTIVE 0 diff --git a/wled00/data/settings_wifi.htm b/wled00/data/settings_wifi.htm index 8b40c3c109..356cf16247 100644 --- a/wled00/data/settings_wifi.htm +++ b/wled00/data/settings_wifi.htm @@ -201,10 +201,11 @@

Ethernet Type

- + + diff --git a/wled00/network.cpp b/wled00/network.cpp index 6c94c4472c..45827757be 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -20,7 +20,7 @@ const ethernet_settings ethernetBoards[] = { // None { }, - + #ifndef CONFIG_IDF_TARGET_ESP32S3 // WT32-EHT01 // Please note, from my testing only these pins work for LED outputs: // IO2, IO4, IO12, IO14, IO15 @@ -134,7 +134,7 @@ const ethernet_settings ethernetBoards[] = { ETH_PHY_LAN8720, // eth_type, ETH_CLOCK_GPIO17_OUT // eth_clk_mode } - + #endif }; #endif @@ -159,21 +159,85 @@ int getSignalQuality(int rssi) return quality; } +const String ARDUINO_EVENT_LIST[41] = { + "ARDUINO_EVENT_WIFI_READY", + "ARDUINO_EVENT_WIFI_SCAN_DONE", + "ARDUINO_EVENT_WIFI_STA_START", + "ARDUINO_EVENT_WIFI_STA_STOP", + "ARDUINO_EVENT_WIFI_STA_CONNECTED", + "ARDUINO_EVENT_WIFI_STA_DISCONNECTED", + "ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE", + "ARDUINO_EVENT_WIFI_STA_GOT_IP", + "ARDUINO_EVENT_WIFI_STA_GOT_IP6", + "ARDUINO_EVENT_WIFI_STA_LOST_IP", + "ARDUINO_EVENT_WIFI_AP_START", + "ARDUINO_EVENT_WIFI_AP_STOP", + "ARDUINO_EVENT_WIFI_AP_STACONNECTED", + "ARDUINO_EVENT_WIFI_AP_STADISCONNECTED", + "ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED", + "ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED", + "ARDUINO_EVENT_WIFI_AP_GOT_IP6", + "ARDUINO_EVENT_WIFI_FTM_REPORT", + "ARDUINO_EVENT_ETH_START", + "ARDUINO_EVENT_ETH_STOP", + "ARDUINO_EVENT_ETH_CONNECTED", + "ARDUINO_EVENT_ETH_DISCONNECTED", + "ARDUINO_EVENT_ETH_GOT_IP", + "ARDUINO_EVENT_ETH_GOT_IP6", + "ARDUINO_EVENT_WPS_ER_SUCCESS", + "ARDUINO_EVENT_WPS_ER_FAILED", + "ARDUINO_EVENT_WPS_ER_TIMEOUT", + "ARDUINO_EVENT_WPS_ER_PIN", + "ARDUINO_EVENT_WPS_ER_PBC_OVERLAP", + "ARDUINO_EVENT_SC_SCAN_DONE", + "ARDUINO_EVENT_SC_FOUND_CHANNEL", + "ARDUINO_EVENT_SC_GOT_SSID_PSWD", + "ARDUINO_EVENT_SC_SEND_ACK_DONE", + "ARDUINO_EVENT_PROV_INIT", + "ARDUINO_EVENT_PROV_DEINIT", + "ARDUINO_EVENT_PROV_START", + "ARDUINO_EVENT_PROV_END", + "ARDUINO_EVENT_PROV_CRED_RECV", + "ARDUINO_EVENT_PROV_CRED_FAIL", + "ARDUINO_EVENT_PROV_CRED_SUCCESS", + "ARDUINO_EVENT_MAX" +}; + +// Handle network events +void WiFiEvent(WiFiEvent_t event) { + + DEBUG_PRINT(F("Network Event: ")); + DEBUG_PRINT(ARDUINO_EVENT_LIST[event]); + DEBUG_PRINT(F(" = ")); -//handle Ethernet connection event -void WiFiEvent(WiFiEvent_t event) -{ switch (event) { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - case SYSTEM_EVENT_ETH_START: - DEBUG_PRINTLN(F("ETH Started")); + #ifndef ESP8266 + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) + case ARDUINO_EVENT_WIFI_STA_GOT_IP: + if (Network.isEthernet()) { + if (!apActive) { + DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Disabling WIFi")); + WiFi.disconnect(true); + } else { + DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Leaving AP WiFi active")); + } + } else { + DEBUG_PRINTLN(F("WiFi Connected. No ETH")); + } break; - case SYSTEM_EVENT_ETH_CONNECTED: - { - DEBUG_PRINTLN(F("ETH Connected")); + + #ifdef WLED_USE_ETHERNET + case ARDUINO_EVENT_ETH_GOT_IP: if (!apActive) { + DEBUG_PRINTLN(F("ETH is up. Disabling WIFi")); WiFi.disconnect(true); + } else { + DEBUG_PRINTLN(F("ETH is up. Leaving AP WiFi Active")); } + break; + + case ARDUINO_EVENT_ETH_CONNECTED: // was SYSTEM_EVENT_ETH_CONNECTED: + DEBUG_PRINTLN(F("ETH connected. Setting up ETH")); if (staticIP != (uint32_t)0x00000000 && staticGateway != (uint32_t)0x00000000) { ETH.config(staticIP, staticGateway, staticSubnet, IPAddress(8, 8, 8, 8)); } else { @@ -185,9 +249,9 @@ void WiFiEvent(WiFiEvent_t event) ETH.setHostname(hostname); showWelcomePage = false; break; - } - case SYSTEM_EVENT_ETH_DISCONNECTED: - DEBUG_PRINTLN(F("ETH Disconnected")); + + case ARDUINO_EVENT_ETH_DISCONNECTED: // was SYSTEM_EVENT_ETH_DISCONNECTED: + DEBUG_PRINTLN(F("ETH Disconnected. Forcing reconnect")); // This doesn't really affect ethernet per se, // as it's only configured once. Rather, it // may be necessary to reconnect the WiFi when @@ -195,9 +259,14 @@ void WiFiEvent(WiFiEvent_t event) // alternative access to the device. forceReconnect = true; break; -#endif + #endif + #endif + #endif default: + DEBUG_PRINTLN(F("No action")); break; + } + } diff --git a/wled00/src/dependencies/e131/ESPAsyncE131.h b/wled00/src/dependencies/e131/ESPAsyncE131.h index 40d7154e28..ed9b6e381a 100644 --- a/wled00/src/dependencies/e131/ESPAsyncE131.h +++ b/wled00/src/dependencies/e131/ESPAsyncE131.h @@ -28,7 +28,11 @@ #ifdef ESP32 #include +#if defined (ARDUINO_ARCH_ESP32S3) && defined (WLED_USE_ETHERNET) +#include // backport some fixes from 5.1 to 4.4 +#else #include +#endif #elif defined (ESP8266) #include #include diff --git a/wled00/src/dependencies/network/Network.cpp b/wled00/src/dependencies/network/Network.cpp index d86bf127fd..40dbf8edf4 100644 --- a/wled00/src/dependencies/network/Network.cpp +++ b/wled00/src/dependencies/network/Network.cpp @@ -3,7 +3,7 @@ IPAddress NetworkClass::localIP() { IPAddress localIP; -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) localIP = ETH.localIP(); if (localIP[0] != 0) { return localIP; @@ -19,7 +19,7 @@ IPAddress NetworkClass::localIP() IPAddress NetworkClass::subnetMask() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { return ETH.subnetMask(); } @@ -32,7 +32,7 @@ IPAddress NetworkClass::subnetMask() IPAddress NetworkClass::gatewayIP() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { return ETH.gatewayIP(); } @@ -45,7 +45,7 @@ IPAddress NetworkClass::gatewayIP() void NetworkClass::localMAC(uint8_t* MAC) { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) // ETH.macAddress(MAC); // Does not work because of missing ETHClass:: in ETH.ccp // Start work around @@ -73,7 +73,7 @@ void NetworkClass::localMAC(uint8_t* MAC) bool NetworkClass::isConnected() { -#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) +#if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP32S3)) && defined(WLED_USE_ETHERNET) return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || ETH.localIP()[0] != 0; #else return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED); diff --git a/wled00/src/dependencies/network/Network.h b/wled00/src/dependencies/network/Network.h index 9201d514ea..c9f3b415e2 100644 --- a/wled00/src/dependencies/network/Network.h +++ b/wled00/src/dependencies/network/Network.h @@ -1,5 +1,9 @@ #ifdef ESP8266 #include +#elif defined (CONFIG_IDF_TARGET_ESP32S3) && defined (WLED_USE_ETHERNET) + #include + #include + #define ETH ETH2 #else // ESP32 #include #include diff --git a/wled00/wled.cpp b/wled00/wled.cpp index e8e9eeccf6..b08c1f51b1 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -926,14 +926,14 @@ void WLED::initAP(bool resetAP) apActive = true; } +static bool successfullyConfiguredEthernet = false; + bool WLED::initEthernet() { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - static bool successfullyConfiguredEthernet = false; - if (successfullyConfiguredEthernet) { - // DEBUG_PRINTLN(F("initE: ETH already successfully configured, ignoring")); + DEBUG_PRINTLN(F("initE: ETH already successfully configured, ignoring")); return false; } if (ethernetType == WLED_ETH_NONE) { @@ -946,6 +946,7 @@ bool WLED::initEthernet() DEBUG_PRINT(F("initE: Attempting ETH config: ")); DEBUG_PRINTLN(ethernetType); + #ifndef ARDUINO_ARCH_ESP32S3 // Ethernet initialization should only succeed once -- else reboot required ethernet_settings es = ethernetBoards[ethernetType]; managed_pin_type pinsToAllocate[10] = { @@ -1002,7 +1003,6 @@ bool WLED::initEthernet() digitalWrite(es.eth_power, 1); delayMicroseconds(10); } - #endif if (!ETH.begin( (uint8_t) es.eth_address, @@ -1020,6 +1020,38 @@ bool WLED::initEthernet() return false; } + #endif + + #elif defined (ARDUINO_ARCH_ESP32S3) + + #define ETH_MISO_PIN 11 + #define ETH_MOSI_PIN 12 + #define ETH_SCLK_PIN 10 + #define ETH_CS_PIN 9 + #define ETH_INT_PIN 13 + #define ETH_RST_PIN 14 + #define ETH_ADDR 1 + + managed_pin_type pinsToAllocate[12] = { ETH_MISO_PIN,true,ETH_MOSI_PIN,true,ETH_SCLK_PIN,true,ETH_CS_PIN,true,ETH_INT_PIN,true,ETH_RST_PIN,true }; + + if (!pinManager.allocateMultiplePins(pinsToAllocate, 6, PinOwner::Ethernet)) { + DEBUG_PRINTLN(F("initE: Failed to allocate ethernet pins")); + return false; + } + + if (!ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN)) { + DEBUG_PRINTLN(F("initC: ETH.begin() [SPI Ethernet] failed")); + // de-allocate the allocated pins + for (managed_pin_type mpt : pinsToAllocate) { + pinManager.deallocatePin(mpt.pin, PinOwner::Ethernet); + } + return false; + } else { + Serial.println("ETH initialized W5500!"); + } + + #endif + successfullyConfiguredEthernet = true; USER_PRINTLN(F("initC: *** Ethernet successfully configured! ***")); // WLEDMM return true; @@ -1116,7 +1148,7 @@ void WLED::initInterfaces() WiFi.hostByName(WLED_DEBUG_HOST, netDebugPrintIP, 750); #else #ifdef WLED_USE_ETHERNET - // ETH.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); WLEDMM: ETH.hostByName does not exist, WiFi.hostByName seems to do the same, but must be tested. + // ETH.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); // WLEDMM: ETH.hostByName does not exist, WiFi.hostByName seems to do the same, but must be tested. WiFi.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); #else WiFi.hostByName(WLED_DEBUG_HOST, netDebugPrintIP); @@ -1155,6 +1187,7 @@ void WLED::initInterfaces() } #endif // WLEDMM end + #ifndef WLED_DISABLE_MDNS // WLEDMM // Set up mDNS responder: if (strlen(cmDNS) > 0) { // "end" must be called before "begin" is called a 2nd time @@ -1167,6 +1200,8 @@ void WLED::initInterfaces() MDNS.addService("wled", "tcp", 80); MDNS.addServiceTxt("wled", "tcp", "mac", escapedMac.c_str()); } + #endif // WLEDMM end + server.begin(); if (udpPort > 0 && udpPort != ntpLocalPort) { @@ -1290,10 +1325,10 @@ void WLED::handleConnection() } if (forceReconnect) { USER_PRINTLN(F("Forcing reconnect.")); - initConnection(); interfacesInited = false; forceReconnect = false; wasConnected = false; + initConnection(); return; } if (!Network.isConnected()) { @@ -1319,7 +1354,12 @@ void WLED::handleConnection() } else if (!interfacesInited) { //newly connected DEBUG_PRINTLN(""); USER_PRINT(F("Connected! IP address: ")); - USER_PRINTLN(Network.localIP()); + USER_PRINT(Network.localIP()); + if (Network.isEthernet()) { + USER_PRINTLN(" via Ethernet"); + } else { + USER_PRINTLN(" via WiFi"); + } if (improvActive) { if (improvError == 3) sendImprovStateResponse(0x00, true); sendImprovStateResponse(0x04); diff --git a/wled00/wled.h b/wled00/wled.h index 647bfb9c21..687ea1b0bb 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -106,9 +106,15 @@ #else // ESP32 #include // ensure we have the correct "Serial" on new MCUs (depends on ARDUINO_USB_MODE and ARDUINO_USB_CDC_ON_BOOT) #include - #include + #if defined (CONFIG_IDF_TARGET_ESP32S3) && defined (WLED_USE_ETHERNET) + #include + #else // ESP32 + #include + #endif #include "esp_wifi.h" - #include + #ifndef WLED_DISABLE_MDNS + #include + #endif // WLEDMM end #include #if LOROL_LITTLEFS #ifndef CONFIG_LITTLEFS_FOR_IDF_3_2 @@ -871,7 +877,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); WLED_GLOBAL unsigned long loops _INIT(0); #endif -#ifdef ARDUINO_ARCH_ESP32 +#if defined ARDUINO_ARCH_ESP32 || defined ARDUINO_ARCH_ESP32S3 #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED || ETH.localIP()[0] != 0) #else #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) diff --git a/wled00/wled_ethernet.h b/wled00/wled_ethernet.h index 6b8f0ba56f..db6f989cdf 100644 --- a/wled00/wled_ethernet.h +++ b/wled00/wled_ethernet.h @@ -23,7 +23,9 @@ typedef struct EthernetSettings { int eth_mdc; int eth_mdio; eth_phy_type_t eth_type; + #ifndef CONFIG_IDF_TARGET_ESP32S3 eth_clock_mode_t eth_clk_mode; + #endif } ethernet_settings; extern const ethernet_settings ethernetBoards[]; diff --git a/wled00/xml.cpp b/wled00/xml.cpp index ee647217c1..0da829b180 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -241,6 +241,7 @@ void appendGPIOinfo() { 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)); } + #ifndef CONFIG_IDF_TARGET_ESP32S3 switch (ethernetBoards[ethernetType].eth_clk_mode) { case ETH_CLOCK_GPIO0_IN: case ETH_CLOCK_GPIO0_OUT: @@ -253,6 +254,7 @@ void appendGPIOinfo() { oappend(SET_F(",17")); break; } + #endif } #endif From 8b55557ef84b41ef31b67ca3ac0783e836d3fce6 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 23:07:48 -0400 Subject: [PATCH 032/193] Squashed commit of the following: commit fd857943701f255e318a8a74555d60ff4b6981a0 Merge: 3987960f 34f4905e Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri Apr 19 12:09:30 2024 -0400 Merge branch 'MoonModules:mdev' into Art-Net_Improvements commit 3987960f272a34e7c742ff9f97aa87c2911f000d Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 09:10:53 2024 -0400 Make sure "0" is never a sequence number commit 42926f629ec3d670680ab108d8fadf20a98fe0d5 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 09:09:30 2024 -0400 Revert. Art-Net compliance app complained about missing packets due to sequence numbers. commit e72a77977757cd00cc99b4ad2b6c6da7d57925f6 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 18 08:59:30 2024 -0400 Packet sequence numbering to Art-Net spec commit 2641dd57f3e0ff05af65f3699068c683f412981d Merge: f5b97f27 0f79e9b7 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed Apr 17 10:03:46 2024 -0400 Merge branch 'MoonModules:mdev' into Art-Net_Improvements commit f5b97f27b5a3b4548aaf89a667c7ab4408895743 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Apr 15 10:18:20 2024 -0400 Force routing only on non-ESP8266 commit 3f574a9d7677eff5e31290cbd53789c78e0f4f44 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 4 10:33:34 2024 -0400 Force use of Ethernet if configured. commit 549f0141f85b45672fa95601bc053704a3b81dad Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Thu Apr 4 09:42:24 2024 -0400 Start of custom mapping ability commit 334884a0b24984e012d80c24fec255bb9c209bc2 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Sat Mar 30 08:45:00 2024 -0400 Forgot BGR and default RGB order commit b1a099c158c2e47d48b1ec2e33cfd88800992a11 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 20:32:32 2024 -0400 Minor tidy. commit d398a4d62b20c34969322bbcdb7b10171736062b Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 20:16:17 2024 -0400 Comments fixed, minor code tidy/revert. commit 1a90b73a3a7e28376549ce967f9c0869d4425e83 Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 19:57:56 2024 -0400 hardware_outputs back to 1 to not break defaults commit ddfa90a12b4623c765864e72ac2c7ce0026796cd Author: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon Mar 18 19:49:32 2024 -0400 Overhaul Art-Net to be more "professionally" good --- wled00/bus_manager.cpp | 61 ++++++++++++++++++--- wled00/bus_manager.h | 8 ++- wled00/udp.cpp | 117 ++++++++++++++++++++++++++++------------- 3 files changed, 139 insertions(+), 47 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 3801c534de..f3604b41d3 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -393,8 +393,7 @@ uint8_t BusOnOff::getPins(uint8_t* pinArray) { return 1; } - -BusNetwork::BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { +BusNetwork::BusNetwork(BusConfig &bc, const ColorOrderMap &com) : Bus(bc.type, bc.start, bc.autoWhite), _colorOrderMap(com) { _valid = false; switch (bc.type) { case TYPE_NET_ARTNET_RGB: @@ -425,16 +424,62 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { if (hasWhite()) c = autoWhiteCalc(c); if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT uint16_t offset = pix * _UDPchannels; - _data[offset] = R(c); - _data[offset+1] = G(c); - _data[offset+2] = B(c); - if (_rgbw) _data[offset+3] = W(c); + uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder); + if (_colorOrder != co) { + if (co == COL_ORDER_GRB) { + _data[offset] = G(c); + _data[offset+1] = R(c); + _data[offset+2] = B(c); + } else if (co == COL_ORDER_RGB) { + _data[offset] = R(c); + _data[offset+1] = G(c); + _data[offset+2] = B(c); + } else if (co == COL_ORDER_BRG) { + _data[offset] = B(c); + _data[offset+1] = R(c); + _data[offset+2] = G(c); + } else if (co == COL_ORDER_RBG) { + _data[offset] = R(c); + _data[offset+1] = B(c); + _data[offset+2] = G(c); + } else if (co == COL_ORDER_GBR) { + _data[offset] = G(c); + _data[offset+1] = B(c); + _data[offset+2] = R(c); + } else if (co == COL_ORDER_BGR) { + _data[offset] = B(c); + _data[offset+1] = G(c); + _data[offset+2] = R(c); + } + if (_rgbw) _data[offset+3] = W(c); + } else { + _data[offset] = R(c); + _data[offset+1] = G(c); + _data[offset+2] = B(c); + if (_rgbw) _data[offset+3] = W(c); + } } uint32_t BusNetwork::getPixelColor(uint16_t pix) { if (!_valid || pix >= _len) return 0; uint16_t offset = pix * _UDPchannels; - return RGBW32(_data[offset], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder); + if (_colorOrder != co) { + if (co == COL_ORDER_GRB) { + return RGBW32(_data[offset+1], _data[offset+0], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_RGB) { + return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_BRG) { + return RGBW32(_data[offset+2], _data[offset+0], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_RBG) { + return RGBW32(_data[offset+0], _data[offset+2], _data[offset+1], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_GBR) { + return RGBW32(_data[offset+1], _data[offset+2], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); + } else if (co == COL_ORDER_BGR) { + return RGBW32(_data[offset+2], _data[offset+1], _data[offset+0], _rgbw ? (_data[offset+3] << 24) : 0); + } + } + return RGBW32(_data[offset+0], _data[offset+1], _data[offset+2], _rgbw ? (_data[offset+3] << 24) : 0); } void BusNetwork::show() { @@ -711,7 +756,7 @@ int BusManager::add(BusConfig &bc) { if (getNumBusses() - getNumVirtualBusses() >= WLED_MAX_BUSSES) return -1; USER_PRINTF("BusManager::add(bc.type=%u)\n", bc.type); if (bc.type >= TYPE_NET_DDP_RGB && bc.type < 96) { - busses[numBusses] = new BusNetwork(bc); + busses[numBusses] = new BusNetwork(bc,colorOrderMap); #ifdef WLED_ENABLE_HUB75MATRIX } else if (bc.type >= TYPE_HUB75MATRIX && bc.type <= (TYPE_HUB75MATRIX + 10)) { USER_PRINTLN("BusManager::add - Adding BusHub75Matrix"); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index f089b52985..5c7374f807 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -295,7 +295,7 @@ class BusOnOff : public Bus { class BusNetwork : public Bus { public: - BusNetwork(BusConfig &bc); + BusNetwork(BusConfig &bc, const ColorOrderMap &com); uint16_t getMaxPixels() override { return 4096; }; bool hasRGB() { return true; } @@ -318,6 +318,10 @@ class BusNetwork : public Bus { return _len; } + uint8_t getColorOrder() { + return _colorOrder; + } + void cleanup(); ~BusNetwork() { @@ -331,6 +335,8 @@ class BusNetwork : public Bus { bool _rgbw; bool _broadcastLock; byte *_data; + uint8_t _colorOrder = COL_ORDER_RGB; + const ColorOrderMap &_colorOrderMap; }; #ifdef WLED_ENABLE_HUB75MATRIX diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 0a2d53324b..4552d6249b 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -770,6 +770,10 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 switch (type) { case 0: // DDP { + #if defined WLED_USE_ETHERNET && !defined ESP8266 + ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + #endif + // calculate the number of UDP packets we need to send size_t channelCount = length * (isRGBW? 4:3); // 1 channel for every R,G,B value size_t packetCount = ((channelCount-1) / DDP_CHANNELS_PER_PACKET) +1; @@ -838,58 +842,95 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 2: //ArtNet { - // calculate the number of UDP packets we need to send - const size_t channelCount = length * (isRGBW?4:3); // 1 channel for every R,G,B,(W?) value + #if defined WLED_USE_ETHERNET && !defined ESP8266 + ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + #endif + /* + We don't really care about the number of universes - just how many hardware outputs we have. + + WLED rendering Art-Net data considers itself to be 1 hardware output with many universes - but + many Art-Net controllers like the H807SA can be manually set to "X universes per output." + + We need to know the channels per output so we can break the pixel data across physically attached universes. + + The H807SA obeys the "510 channels for RGB" rule like WLED and xLights - some other controllers do not care, + but we're not supporting those here. If you run into one of these, override ARTNET_CHANNELS_PER_PACKET to 512. + + We're expecting equal numbers of channels per output, common for controllers like the H807SA - at some point + we could consider an Art-Net mapping system to adjust universe starts for weird wiring situations. + */ const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs - const size_t packetCount = ((channelCount-1)/ARTNET_CHANNELS_PER_PACKET)+1; - uint32_t channel = 0; - size_t bufferOffset = 0; + // Default WLED-to-WLED Art-Net output + // + const size_t hardware_outputs[1] = { length }; // specified in LED counts. "length" = all LEDs + const size_t hardware_outputs_universe_start[1] = { 0 }; // universe start # per output + + // Example of more than 1 output, currently you can only hard-code this kind of setup here. + // You get 170 RGB LEDs per universe (128 RGBW) so the receiving hardware needs to be configured correctly. + // The H807SA, for example, only allows one global setting of Art-Net universes-per-output. + // + // const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts + // const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output + size_t bufferOffset = 0; + size_t hardware_output_universe = 0; + sequenceNumber++; - for (size_t currentPacket = 0; currentPacket < packetCount; currentPacket++) { + if (sequenceNumber == 0) sequenceNumber = 1; // just in case, as 0 is considered "Sequence not in use" + if (sequenceNumber > 255) sequenceNumber = 1; - if (sequenceNumber > 255) sequenceNumber = 0; + for (size_t hardware_output = 0; hardware_output < sizeof(hardware_outputs)/sizeof(size_t); hardware_output++) { + + if (bufferOffset > length * (isRGBW?4:3)) return 1; // stop when we hit end of LEDs - if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { - DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); - return 1; // borked - } + hardware_output_universe = hardware_outputs_universe_start[hardware_output]; - size_t packetSize = ARTNET_CHANNELS_PER_PACKET; + size_t channels_remaining = hardware_outputs[hardware_output] * (isRGBW?4:3); - if (currentPacket == (packetCount - 1U)) { - // last packet - if (channelCount % ARTNET_CHANNELS_PER_PACKET) { - packetSize = channelCount % ARTNET_CHANNELS_PER_PACKET; + while (channels_remaining > 0) { + + if (!ddpUdp.beginPacket(client, ARTNET_DEFAULT_PORT)) { + DEBUG_PRINTLN(F("Art-Net WiFiUDP.beginPacket returned an error")); + return 1; // borked } - } - byte header_buffer[ART_NET_HEADER_SIZE]; - memcpy_P(header_buffer, ART_NET_HEADER, ART_NET_HEADER_SIZE); - ddpUdp.write(header_buffer, ART_NET_HEADER_SIZE); // This doesn't change. Hard coded ID, OpCode, and protocol version. - ddpUdp.write(sequenceNumber & 0xFF); // sequence number. 1..255 - ddpUdp.write(0x00); // physical - more an FYI, not really used for anything. 0..3 - ddpUdp.write((currentPacket) & 0xFF); // Universe LSB. 1 full packet == 1 full universe, so just use current packet number. - ddpUdp.write(0x00); // Universe MSB, unused. - ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB - ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB + size_t packetSize = ARTNET_CHANNELS_PER_PACKET; - for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G - ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B - if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // W - } + if (channels_remaining < ARTNET_CHANNELS_PER_PACKET) { + packetSize = channels_remaining; + channels_remaining = 0; + } else { + channels_remaining -= packetSize; + } - if (!ddpUdp.endPacket()) { - DEBUG_PRINTLN(F("Art-Net WiFiUDP.endPacket returned an error")); - return 1; // borked + byte header_buffer[ART_NET_HEADER_SIZE]; + memcpy_P(header_buffer, ART_NET_HEADER, ART_NET_HEADER_SIZE); + ddpUdp.write(header_buffer, ART_NET_HEADER_SIZE); // This doesn't change. Hard coded ID, OpCode, and protocol version. + ddpUdp.write(sequenceNumber & 0xFF); // sequence number. 1..255 + ddpUdp.write(0x00); // physical - more an FYI, not really used for anything. 0..3 + ddpUdp.write(hardware_output_universe & 0xFF); // Universe LSB. 1 full packet == 1 full universe. + ddpUdp.write(0x00); // Universe MSB, unused. + ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB + ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB + + for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) { + // "Color Order Override" works on top of this if you need to change the color order before sending. + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G + ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B + if (isRGBW) ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // W + } + + if (!ddpUdp.endPacket()) { + DEBUG_PRINTLN(F("Art-Net WiFiUDP.endPacket returned an error")); + return 1; // borked + } + hardware_output_universe++; } - channel += packetSize; - } - } break; + } break; + } } return 0; } From 1aa2ea16a3169295d30014af27ef50b6250929fb Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Fri, 19 Apr 2024 23:12:40 -0400 Subject: [PATCH 033/193] Conditional Art-Net Universe Remapping --- wled00/udp.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 4552d6249b..bf50cd3e38 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -861,18 +861,20 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 */ const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs + #ifndef ARTNET_TROYHACKS // Default WLED-to-WLED Art-Net output // const size_t hardware_outputs[1] = { length }; // specified in LED counts. "length" = all LEDs const size_t hardware_outputs_universe_start[1] = { 0 }; // universe start # per output - + #else // Example of more than 1 output, currently you can only hard-code this kind of setup here. // You get 170 RGB LEDs per universe (128 RGBW) so the receiving hardware needs to be configured correctly. // The H807SA, for example, only allows one global setting of Art-Net universes-per-output. // - // const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts - // const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output - + const size_t hardware_outputs[4] = { 256,256,256,256 }; // specified in LED counts + const size_t hardware_outputs_universe_start[4] = { 0,2,4,6 }; // universe start # per output + #endif + size_t bufferOffset = 0; size_t hardware_output_universe = 0; From e0f611e679dbbe45a37e0fe7b149adeda899c10d Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:20:25 -0400 Subject: [PATCH 034/193] Source address doesn't work on ETHClass2 --- wled00/udp.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wled00/udp.cpp b/wled00/udp.cpp index bf50cd3e38..8c42d99c71 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -770,9 +770,9 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 switch (type) { case 0: // DDP { - #if defined WLED_USE_ETHERNET && !defined ESP8266 - ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. - #endif + // #if defined WLED_USE_ETHERNET && !defined ESP8266 + // ddpUdp.begin(Network.localIP(),DDP_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + // #endif // calculate the number of UDP packets we need to send size_t channelCount = length * (isRGBW? 4:3); // 1 channel for every R,G,B value @@ -842,9 +842,9 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8 case 2: //ArtNet { - #if defined WLED_USE_ETHERNET && !defined ESP8266 - ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. - #endif + // #if defined WLED_USE_ETHERNET && !defined ESP8266 + // ddpUdp.begin(Network.localIP(),ARTNET_DEFAULT_PORT); // in case we have Ethernet on ESP32, this forces that source IP/routing. + // #endif /* We don't really care about the number of universes - just how many hardware outputs we have. From 193b346f51e3189f53a4ff4dfabb51378fd69b89 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:28:42 -0400 Subject: [PATCH 035/193] MAX_LEDS_PER_BUS for BusNetwork follows setting --- wled00/bus_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 8b47db794b..466e257814 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -297,7 +297,7 @@ class BusNetwork : public Bus { public: BusNetwork(BusConfig &bc, const ColorOrderMap &com); - uint16_t getMaxPixels() override { return 4096; }; + uint16_t getMaxPixels() override { return MAX_LEDS_PER_BUS; }; bool hasRGB() { return true; } bool hasWhite() { return _rgbw; } From 8b4db8356008d438e15e1fb509c9fa0f747dc9d0 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:57:54 -0400 Subject: [PATCH 036/193] Settings for larger Art-Net displays --- wled00/const.h | 2 +- wled00/data/settings_leds.htm | 2 +- wled00/udp.cpp | 4 ++-- wled00/ws.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wled00/const.h b/wled00/const.h index 628f8d2cea..e246f10399 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -412,7 +412,7 @@ #if !defined(USERMOD_AUDIOREACTIVE) #define SETTINGS_STACK_BUF_SIZE 3834 // WLEDMM added 696+32 bytes of margin (was 3096) #else - #define SETTINGS_STACK_BUF_SIZE 4000 // WLEDMM more buffer for audioreactive UI (add '-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9216' to your build_flags) + #define SETTINGS_STACK_BUF_SIZE 4100 // WLEDMM more buffer for audioreactive UI (add '-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9216' to your build_flags) #endif #endif diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index e1979fdcaf..c32bf41498 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -5,7 +5,7 @@ LED Settings