From 2ec9d24d7bf63035125b722af7738cdff86e3d1e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 17 Apr 2024 19:57:14 +0100 Subject: [PATCH 01/23] AutoPlaylist - prevent swapping playlist after silence ended when Suspended --- usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h b/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h index d08f295f8a..5668288533 100644 --- a/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h +++ b/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h @@ -302,6 +302,8 @@ class AutoPlaylistUsermod : public Usermod { if (bri == 0) return; + if(!functionality_enabled) return; + um_data_t *um_data; if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) { From c3503f7fc6d5aca6a322c179c1cf30ec072dcdcc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 May 2024 19:52:01 +0100 Subject: [PATCH 02/23] Start adding FastLED output --- wled00/bus_manager.cpp | 16 ++++++++++++++++ wled00/bus_manager.h | 2 ++ wled00/const.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index af4e16efe8..91b1ebbbc5 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -477,6 +477,20 @@ void BusNetwork::cleanup() { if (_data != nullptr) free(_data); _data = nullptr; } +// *************************************************************************** +void BusFastLED::setPixelColor(uint16_t pix, uint32_t c) { + this->leds[pix].r = R(c); + this->leds[pix].g = G(c); + this->leds[pix].b = B(c); +} + +void BusFastLED::show() { + FastLED.show(); +} + +void BusFastLED::setBrightness(uint8_t b, bool immediate) { + FastLED.setBrightness(b); +} // *************************************************************************** @@ -738,6 +752,8 @@ int BusManager::add(BusConfig &bc) { DEBUG_PRINTLN("BusManager::add - Adding BusHub75Matrix"); busses[numBusses] = new BusHub75Matrix(bc); #endif + } else if (bc.type = TYPE_FASTLED) { + busses[numBusses] = new BusFastLED(bc); } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap); } else if (bc.type == TYPE_ONOFF) { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 0bfd3e04de..a1082fc0c9 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -1,6 +1,8 @@ #ifndef BusManager_h #define BusManager_h +#include + #ifdef WLED_ENABLE_HUB75MATRIX #include #include diff --git a/wled00/const.h b/wled00/const.h index 8f690ac955..6078661947 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -245,6 +245,8 @@ #define TYPE_P9813 53 #define TYPE_LPD6803 54 +#define TYPE_FASTLED 60 + #define TYPE_HUB75MATRIX 100 // 100 - 110 //Network types (master broadcast) (80-95) From 86acbeccc9df11a94918f370f95ce095c4535cd9 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 8 May 2024 20:13:12 +0100 Subject: [PATCH 03/23] Start adding FastLED output --- wled00/bus_manager.cpp | 4 ++++ wled00/bus_manager.h | 29 +++++++++++++++++++++++++++++ wled00/data/settings_leds.htm | 1 + 3 files changed, 34 insertions(+) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 91b1ebbbc5..905f924690 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -478,6 +478,10 @@ void BusNetwork::cleanup() { _data = nullptr; } // *************************************************************************** + +BusFastLED::BusFastLED(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { +} + void BusFastLED::setPixelColor(uint16_t pix, uint32_t c) { this->leds[pix].r = R(c); this->leds[pix].g = G(c); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index a1082fc0c9..6fc1121118 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -335,6 +335,35 @@ class BusNetwork : public Bus { byte *_data; }; + +class BusFastLED : public Bus { + public: + BusFastLED(BusConfig &bc); + + uint16_t getMaxPixels() override { return 1024; }; + bool hasRGB() { return true; } + bool hasWhite() { return false; } + + void setPixelColor(uint16_t pix, uint32_t c); + void setBrightness(uint8_t b, bool immediate); + + void show(); + + void cleanup() { + // TODO + } + + // uint8_t getPins(uint8_t* pinArray); + + uint16_t getLength() { + return _len; + } + + private: + CRGB leds[1024]; + +}; + #ifdef WLED_ENABLE_HUB75MATRIX class BusHub75Matrix : public Bus { public: diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index e1979fdcaf..16e1e66d9b 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -375,6 +375,7 @@ \ \ \ +\ '} From fe86b60ce4b32faccd66a6400da952b3b6f19438 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 8 May 2024 20:20:49 +0100 Subject: [PATCH 04/23] Start adding FastLED output --- wled00/bus_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 905f924690..4ffcdc9bf4 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -480,6 +480,7 @@ void BusNetwork::cleanup() { // *************************************************************************** BusFastLED::BusFastLED(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { + FastLED.addLeds(this->data, bc.count, bc.start); } void BusFastLED::setPixelColor(uint16_t pix, uint32_t c) { From 57cf84e05b7975ebaa8c7b17e0585dd30e0541c2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 26 May 2024 14:59:24 +0100 Subject: [PATCH 05/23] Initial code for I2SClocklessLedDriver --- wled00/bus_manager.cpp | 10 +++++----- wled00/bus_manager.h | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 4ffcdc9bf4..fb44010bb7 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -479,21 +479,21 @@ void BusNetwork::cleanup() { } // *************************************************************************** -BusFastLED::BusFastLED(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { +BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { FastLED.addLeds(this->data, bc.count, bc.start); } -void BusFastLED::setPixelColor(uint16_t pix, uint32_t c) { +void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { this->leds[pix].r = R(c); this->leds[pix].g = G(c); this->leds[pix].b = B(c); } -void BusFastLED::show() { +void BusI2SClocklessLedDriver::show() { FastLED.show(); } -void BusFastLED::setBrightness(uint8_t b, bool immediate) { +void BusI2SClocklessLedDriver::setBrightness(uint8_t b, bool immediate) { FastLED.setBrightness(b); } @@ -758,7 +758,7 @@ int BusManager::add(BusConfig &bc) { busses[numBusses] = new BusHub75Matrix(bc); #endif } else if (bc.type = TYPE_FASTLED) { - busses[numBusses] = new BusFastLED(bc); + busses[numBusses] = new BusI2SClocklessLedDriver(bc); } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap); } else if (bc.type == TYPE_ONOFF) { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 6fc1121118..da2513e717 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -7,6 +7,9 @@ #include #include #endif + +#include "I2SClocklessLedDriver.h" + /* * Class for addressing various light types */ @@ -336,11 +339,11 @@ class BusNetwork : public Bus { }; -class BusFastLED : public Bus { +class BusI2SClocklessLedDriver : public Bus { public: - BusFastLED(BusConfig &bc); + BusI2SClocklessLedDriver(BusConfig &bc); - uint16_t getMaxPixels() override { return 1024; }; + uint16_t getMaxPixels() override { return 1024; }; // TODO: dynamic bool hasRGB() { return true; } bool hasWhite() { return false; } @@ -360,8 +363,7 @@ class BusFastLED : public Bus { } private: - CRGB leds[1024]; - + I2SClocklessLedDriver driver; }; #ifdef WLED_ENABLE_HUB75MATRIX From 51f2774fdcac2b8f4555a515d2d1e26ae0a176f8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 26 May 2024 14:59:49 +0100 Subject: [PATCH 06/23] Initial code for I2SClocklessLedDriver --- wled00/bus_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index fb44010bb7..950b09425e 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -481,6 +481,8 @@ void BusNetwork::cleanup() { BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { FastLED.addLeds(this->data, bc.count, bc.start); + driver.initled((uint8_t*)leds,pins,NUMSTRIPS,NUM_LEDS_PER_STRIP,ORDER_GRB); + driver.setBrightness(10); } void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { From 0a08d4c15e8dcf8aab8227bc67b9230b261a6b72 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 26 May 2024 15:28:50 +0100 Subject: [PATCH 07/23] WiP on I2SClocklessLedDriver --- platformio.ini | 1 + wled00/bus_manager.cpp | 14 +++++--------- wled00/bus_manager.h | 3 ++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/platformio.ini b/platformio.ini index c0c90a6d58..22d94c1ecd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -257,6 +257,7 @@ lib_deps = #For ADS1115 sensor uncomment following ; adafruit/Adafruit BusIO @ 1.13.2 ; adafruit/Adafruit ADS1X15 @ 2.4.0 + https://github.com/hpwit/I2SClocklessLedDriver.git#ef99706 extra_scripts = ${scripts_defaults.extra_scripts} diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 950b09425e..d06de3b6f0 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -480,23 +480,19 @@ void BusNetwork::cleanup() { // *************************************************************************** BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { - FastLED.addLeds(this->data, bc.count, bc.start); - driver.initled((uint8_t*)leds,pins,NUMSTRIPS,NUM_LEDS_PER_STRIP,ORDER_GRB); - driver.setBrightness(10); -} + driver.initled((uint8_t*)leds, bc.pins, 1, bc.count, ORDER_GRB); + } void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { - this->leds[pix].r = R(c); - this->leds[pix].g = G(c); - this->leds[pix].b = B(c); + this->driver.setPixel(pix, R(c), G(c), B(c)); } void BusI2SClocklessLedDriver::show() { - FastLED.show(); + driver.showPixels(); } void BusI2SClocklessLedDriver::setBrightness(uint8_t b, bool immediate) { - FastLED.setBrightness(b); + driver.setBrightness(b); } // *************************************************************************** diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index da2513e717..0cb51879b1 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -362,7 +362,8 @@ class BusI2SClocklessLedDriver : public Bus { return _len; } - private: + private: + uint8_t leds[1024*3]; // TODO: dynamic I2SClocklessLedDriver driver; }; From 31202edd5bd5cd6c7285a73ed1181650e5f9a5af Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 11:44:47 +0100 Subject: [PATCH 08/23] Cleanup FastLED references --- wled00/bus_manager.h | 2 -- wled00/const.h | 2 +- wled00/data/settings_leds.htm | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 0cb51879b1..1112249556 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -1,8 +1,6 @@ #ifndef BusManager_h #define BusManager_h -#include - #ifdef WLED_ENABLE_HUB75MATRIX #include #include diff --git a/wled00/const.h b/wled00/const.h index 6078661947..fb48922be7 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -245,7 +245,7 @@ #define TYPE_P9813 53 #define TYPE_LPD6803 54 -#define TYPE_FASTLED 60 +#define TYPE_I2SCL 61 #define TYPE_HUB75MATRIX 100 // 100 - 110 diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 16e1e66d9b..090d76fb04 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -375,7 +375,7 @@ \ \ \ -\ +\ '} From a2c4489d5302b1f2e47cf650da6351b17dc59951 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 11:58:55 +0100 Subject: [PATCH 09/23] Fix driver init --- wled00/bus_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index b0c2b649ea..e40af30342 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -485,7 +485,7 @@ void BusNetwork::cleanup() { // *************************************************************************** BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { - driver.initled((uint8_t*)leds, bc.pins, 1, bc.count, ORDER_GRB); + driver.initled((uint8_t*)leds, (int*) bc.pins, 1, bc.count, ORDER_GRB); } void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { @@ -760,7 +760,7 @@ int BusManager::add(BusConfig &bc) { DEBUG_PRINTLN("BusManager::add - Adding BusHub75Matrix"); busses[numBusses] = new BusHub75Matrix(bc); #endif - } else if (bc.type = TYPE_FASTLED) { + } else if (bc.type = TYPE_I2SCL) { busses[numBusses] = new BusI2SClocklessLedDriver(bc); } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap); From 1ad4c95186adfff92e704c636bf6c87f2557cc1c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 12:14:09 +0100 Subject: [PATCH 10/23] Use patched version of I2SClocklessLedDriver --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index c06716c831..1d5c6d921c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -258,7 +258,7 @@ lib_deps = #For ADS1115 sensor uncomment following ; adafruit/Adafruit BusIO @ 1.13.2 ; adafruit/Adafruit ADS1X15 @ 2.4.0 - https://github.com/hpwit/I2SClocklessLedDriver.git#ef99706 + https://github.com/netmindz/I2SClocklessLedDriver.git#WLED-compat extra_scripts = ${scripts_defaults.extra_scripts} From 69bf4f02212bcec5ef347d86b0a98728e8b34144 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 13:09:49 +0100 Subject: [PATCH 11/23] WiP on I2SClockless --- wled00/bus_manager.cpp | 28 +++++++++++++++++++++++----- wled00/bus_manager.h | 7 +++---- wled00/data/settings_leds.htm | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index e40af30342..2eea3659d2 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -485,21 +485,39 @@ void BusNetwork::cleanup() { // *************************************************************************** BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { - driver.initled((uint8_t*)leds, (int*) bc.pins, 1, bc.count, ORDER_GRB); + USER_PRINTF("Construct BusI2SClocklessLedDriver\n"); + _valid = false; + if (!pinManager.allocatePin(bc.pins[0], true, PinOwner::BusDigital)) return; + _pins[0] = bc.pins[0]; + USER_PRINTF("initled using pin %d for %d LEDs\n", _pins[0], bc.count); + colorarrangment color; + switch(bc.colorOrder) { + case 0: color = ORDER_RGB; break; + case 1: color = ORDER_GRB; break; + case 2: color = ORDER_BGR; break; + } + + driver.initled((uint8_t*)leds, _pins, 1, bc.count, color); + _valid = true; } void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { - this->driver.setPixel(pix, R(c), G(c), B(c)); + if(_valid) this->driver.setPixel(pix, R(c), G(c), B(c)); } void BusI2SClocklessLedDriver::show() { - driver.showPixels(); + if(_valid) driver.showPixels(); } void BusI2SClocklessLedDriver::setBrightness(uint8_t b, bool immediate) { - driver.setBrightness(b); + if(_valid) driver.setBrightness(b); } +void BusI2SClocklessLedDriver::cleanup() { + pinManager.deallocatePin(_pins[0], PinOwner::BusDigital); +} + + // *************************************************************************** #ifdef WLED_ENABLE_HUB75MATRIX @@ -760,7 +778,7 @@ int BusManager::add(BusConfig &bc) { DEBUG_PRINTLN("BusManager::add - Adding BusHub75Matrix"); busses[numBusses] = new BusHub75Matrix(bc); #endif - } else if (bc.type = TYPE_I2SCL) { + } else if (bc.type == TYPE_I2SCL) { busses[numBusses] = new BusI2SClocklessLedDriver(bc); } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 1112249556..722bd4eca1 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -350,9 +350,7 @@ class BusI2SClocklessLedDriver : public Bus { void show(); - void cleanup() { - // TODO - } + void cleanup(); // uint8_t getPins(uint8_t* pinArray); @@ -362,7 +360,8 @@ class BusI2SClocklessLedDriver : public Bus { private: uint8_t leds[1024*3]; // TODO: dynamic - I2SClocklessLedDriver driver; + I2SClocklessLedDriver driver; + int _pins[1] = {255}; }; #ifdef WLED_ENABLE_HUB75MATRIX diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 090d76fb04..bef5b08e60 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -375,7 +375,7 @@ \ \ \ -\ +\ '} From 1a8bfbef1c6b74e3b126ce55847bd4a308df1cad Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 14:40:21 +0100 Subject: [PATCH 12/23] Fix cleanup and colororder for I2SClocklessLedDriver --- wled00/bus_manager.cpp | 5 +++-- wled00/bus_manager.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 2eea3659d2..20eee797ab 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -492,12 +492,13 @@ BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, USER_PRINTF("initled using pin %d for %d LEDs\n", _pins[0], bc.count); colorarrangment color; switch(bc.colorOrder) { - case 0: color = ORDER_RGB; break; - case 1: color = ORDER_GRB; break; + case 0: color = ORDER_GRB; break; + case 1: color = ORDER_RGB; break; case 2: color = ORDER_BGR; break; } driver.initled((uint8_t*)leds, _pins, 1, bc.count, color); + _len = bc.count; _valid = true; } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 722bd4eca1..9aab320b8e 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -357,6 +357,10 @@ class BusI2SClocklessLedDriver : public Bus { uint16_t getLength() { return _len; } + + ~BusI2SClocklessLedDriver() { + cleanup(); + } private: uint8_t leds[1024*3]; // TODO: dynamic From 95f8b9e27c4fd65d3b3ebe82c46cceb8e7ae9036 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 14:54:01 +0100 Subject: [PATCH 13/23] Disable conflicting use of I2S for now --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 1d5c6d921c..ae08df3414 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1018,7 +1018,7 @@ build_disable_sync_interfaces = -D WLED_DISABLE_ADALIGHT ;; WLEDMM this board does not have a serial-to-USB chip. Better to disable serial protocols, to avoid crashes (see upstream #3128) -D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only -AR_build_flags = -D USERMOD_AUDIOREACTIVE -D UM_AUDIOREACTIVE_USE_NEW_FFT ;; WLEDMM audioreactive usermod, licensed under GPLv3 +AR_build_flags = ;; -D USERMOD_AUDIOREACTIVE -D UM_AUDIOREACTIVE_USE_NEW_FFT ;; WLEDMM audioreactive usermod, licensed under GPLv3 AR_lib_deps = https://github.com/softhack007/arduinoFFT.git#develop @ 1.9.2 ;; used for USERMOD_AUDIOREACTIVE - optimized version, 10% faster on -S2/-C3 animartrix_build_flags = -D USERMOD_ANIMARTRIX ;; WLEDMM usermod: CC BY-NC 3.0 licensed effects by Stefan Petrick @@ -1049,7 +1049,7 @@ build_flags_S = ; -D WLED_DISABLE_2D ;; un-comment to build a firmware without 2D matrix support ; -D WLED_USE_CIE_BRIGHTNESS_TABLE ;; experimental: use different color / brightness lookup table ${common_mm.AR_build_flags} ; use latest (upstream) FFTLib, instead of older library modified by blazoncek. Slightly faster, more accurate, needs 2KB RAM extra - -D USERMOD_AUTO_PLAYLIST + ; -D USERMOD_AUTO_PLAYLIST ; -D USERMOD_ARTIFX ;; WLEDMM usermod - temporarily moved into "_M", due to problems in "_S" when compiling with -O2 -D WLEDMM_FASTPATH ;; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions. ; -D WLED_DEBUG_HEAP ;; WLEDMM enable heap debugging From 6b56f4d9e48e1eb13dab71deb160cb9491007836 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 27 May 2024 16:14:02 +0100 Subject: [PATCH 14/23] implement BusI2SClocklessLedDriver::getPins --- wled00/bus_manager.cpp | 5 +++++ wled00/bus_manager.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 20eee797ab..b4caa3722f 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -514,6 +514,11 @@ void BusI2SClocklessLedDriver::setBrightness(uint8_t b, bool immediate) { if(_valid) driver.setBrightness(b); } +uint8_t BusI2SClocklessLedDriver::getPins(uint8_t* pinArray) { + pinArray[0] = _pins[0]; + return 1; +} + void BusI2SClocklessLedDriver::cleanup() { pinManager.deallocatePin(_pins[0], PinOwner::BusDigital); } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 9aab320b8e..7c2f4e83ae 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -352,7 +352,7 @@ class BusI2SClocklessLedDriver : public Bus { void cleanup(); - // uint8_t getPins(uint8_t* pinArray); + uint8_t getPins(uint8_t* pinArray); uint16_t getLength() { return _len; From c62d18f3f23cd866904164a809235c23545295b6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 29 May 2024 19:52:33 +0100 Subject: [PATCH 15/23] Fix saving of pin config for BusI2SClocklessLedDriver --- wled00/bus_manager.cpp | 4 +++- wled00/bus_manager.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index b4caa3722f..846c287dd5 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -489,6 +489,7 @@ BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, _valid = false; if (!pinManager.allocatePin(bc.pins[0], true, PinOwner::BusDigital)) return; _pins[0] = bc.pins[0]; + _pins[1] = bc.pins[1]; // TODO: remove once the UI knows we don't need clock pin USER_PRINTF("initled using pin %d for %d LEDs\n", _pins[0], bc.count); colorarrangment color; switch(bc.colorOrder) { @@ -516,7 +517,8 @@ void BusI2SClocklessLedDriver::setBrightness(uint8_t b, bool immediate) { uint8_t BusI2SClocklessLedDriver::getPins(uint8_t* pinArray) { pinArray[0] = _pins[0]; - return 1; + pinArray[1] = _pins[1]; + return 2; } void BusI2SClocklessLedDriver::cleanup() { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 7c2f4e83ae..4cd1c231d8 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -365,7 +365,7 @@ class BusI2SClocklessLedDriver : public Bus { private: uint8_t leds[1024*3]; // TODO: dynamic I2SClocklessLedDriver driver; - int _pins[1] = {255}; + int _pins[2] = {0,0}; }; #ifdef WLED_ENABLE_HUB75MATRIX From 1f0ed26f88ae248a0549edf9be21b655b17c43bc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:16:05 +0100 Subject: [PATCH 16/23] Initial work on using I2SClocklessLedDriveresp32S3 for S3 BusI2SClocklessLedDriver --- platformio.ini | 3 ++- wled00/bus_manager.cpp | 14 +++++++++++++- wled00/bus_manager.h | 10 ++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index fec7fef86a..e3910738f0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -259,7 +259,7 @@ lib_deps = #For ADS1115 sensor uncomment following ; adafruit/Adafruit BusIO @ 1.13.2 ; adafruit/Adafruit ADS1X15 @ 2.4.0 - https://github.com/netmindz/I2SClocklessLedDriver.git#WLED-compat + https://github.com/hpwit/I2SClocklessLedDriver#333754b extra_scripts = ${scripts_defaults.extra_scripts} @@ -463,6 +463,7 @@ lib_deps = https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 makuna/NeoPixelBus @ 2.7.5 ;; makuna/NeoPixelBus @ 2.7.9 ;; experimental + https://github.com/netmindz/I2SClockLessLedDriveresp32s3#67341fc ;; WLED-compat ${env.lib_deps} diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 846c287dd5..43df49f746 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -498,13 +498,25 @@ BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, case 2: color = ORDER_BGR; break; } + #ifdef CONFIG_IDF_TARGET_ESP32S3 + USER_PRINTLN("no color order support for I2SClockLessLedDriveresp32s3"); + driver.initled((uint8_t*)leds, _pins, 1, bc.count); + #else driver.initled((uint8_t*)leds, _pins, 1, bc.count, color); + #endif + _len = bc.count; _valid = true; } void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { - if(_valid) this->driver.setPixel(pix, R(c), G(c), B(c)); + if(_valid) { + #ifdef CONFIG_IDF_TARGET_ESP32S3 + this->leds[pix] = CRGB(R(c), G(c), B(c)); + #else + this->driver.setPixel(pix, R(c), G(c), B(c)); + #endif + } } void BusI2SClocklessLedDriver::show() { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 4cd1c231d8..59a570c0c4 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -6,7 +6,12 @@ #include #endif +#ifdef CONFIG_IDF_TARGET_ESP32S3 +#include "I2SClockLessLedDriveresp32s3.h" +#include +#else #include "I2SClocklessLedDriver.h" +#endif /* * Class for addressing various light types @@ -363,8 +368,13 @@ class BusI2SClocklessLedDriver : public Bus { } private: + #ifdef CONFIG_IDF_TARGET_ESP32S3 + CRGB leds[1024]; // TODO: dynamic + I2SClocklessLedDriveresp32S3 driver; + #else uint8_t leds[1024*3]; // TODO: dynamic I2SClocklessLedDriver driver; + #endif int _pins[2] = {0,0}; }; From 4eb37b7b958409d6b59c1962fe6617bfbdf24f31 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:25:34 +0100 Subject: [PATCH 17/23] Initial work on using I2SClocklessLedDriveresp32S3 for S3 BusI2SClocklessLedDriver --- platformio.ini | 2 +- wled00/bus_manager.cpp | 2 +- wled00/bus_manager.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index e3910738f0..67d276b242 100644 --- a/platformio.ini +++ b/platformio.ini @@ -259,7 +259,6 @@ lib_deps = #For ADS1115 sensor uncomment following ; adafruit/Adafruit BusIO @ 1.13.2 ; adafruit/Adafruit ADS1X15 @ 2.4.0 - https://github.com/hpwit/I2SClocklessLedDriver#333754b extra_scripts = ${scripts_defaults.extra_scripts} @@ -327,6 +326,7 @@ lib_deps = https://github.com/softhack007/LITTLEFS-threadsafe.git#master makuna/NeoPixelBus @ 2.7.5 ;; makuna/NeoPixelBus @ 2.7.9 ;; experimental + https://github.com/hpwit/I2SClocklessLedDriver#333754b ${env.lib_deps} ;; Compatibility with upstream --> you should prefer using ${common_mm.build_flags_S} and ${common_mm.lib_deps_S} diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 43df49f746..07928d060d 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -491,7 +491,6 @@ BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, _pins[0] = bc.pins[0]; _pins[1] = bc.pins[1]; // TODO: remove once the UI knows we don't need clock pin USER_PRINTF("initled using pin %d for %d LEDs\n", _pins[0], bc.count); - colorarrangment color; switch(bc.colorOrder) { case 0: color = ORDER_GRB; break; case 1: color = ORDER_RGB; break; @@ -512,6 +511,7 @@ BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, void BusI2SClocklessLedDriver::setPixelColor(uint16_t pix, uint32_t c) { if(_valid) { #ifdef CONFIG_IDF_TARGET_ESP32S3 + // TODO - use this.color to use the right ordering this->leds[pix] = CRGB(R(c), G(c), B(c)); #else this->driver.setPixel(pix, R(c), G(c), B(c)); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 59a570c0c4..b347a47eb0 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -375,6 +375,7 @@ class BusI2SClocklessLedDriver : public Bus { uint8_t leds[1024*3]; // TODO: dynamic I2SClocklessLedDriver driver; #endif + colorarrangment color; int _pins[2] = {0,0}; }; From 552aae571006965fc0499bebdad204f8f2d72ea8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:28:35 +0100 Subject: [PATCH 18/23] Initial work on using I2SClocklessLedDriveresp32S3 for S3 BusI2SClocklessLedDriver --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 67d276b242..383a855782 100644 --- a/platformio.ini +++ b/platformio.ini @@ -364,6 +364,7 @@ lib_depsV4 = makuna/NeoPixelBus @ 2.7.5 ;; makuna/NeoPixelBus @ 2.7.9 ;; experimental ${common_mm.HUB75_lib_deps} + https://github.com/hpwit/I2SClocklessLedDriver#333754b ${env.lib_deps} From 438ea41c355ff7374415345bd8870f78e546a299 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:34:37 +0100 Subject: [PATCH 19/23] Add WLED_ENABLE_I2SCLOCKLESS --- platformio.ini | 2 ++ wled00/bus_manager.cpp | 3 ++- wled00/bus_manager.h | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 383a855782..4499840721 100644 --- a/platformio.ini +++ b/platformio.ini @@ -309,6 +309,7 @@ build_flags = -g ; -D WLEDMM_TWOPATH ;; use I2S1 as the second bus --> ~15% faster on "V3" builds - may flicker a bit more ; -D WLEDMM_SLOWPATH ;; don't use I2S for LED bus ; -DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3 + -D WLED_ENABLE_I2SCLOCKLESS default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv ;; WLED standard for 4MB flash: 1.4MB firmware, 1MB filesystem ;default_partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; WLEDMM alternative for 4MB flash: 1.8MB firmware, 256KB filesystem (esptool erase_flash needed before changing) @@ -437,6 +438,7 @@ build_flags = -g -DARDUINO_USB_MODE=1 ;; this flag is mandatory for ESP32-C3 ;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry: ;; ARDUINO_USB_CDC_ON_BOOT + -D WLED_ENABLE_I2SCLOCKLESS lib_deps = https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 07928d060d..1bec50ee75 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -483,6 +483,7 @@ void BusNetwork::cleanup() { _data = nullptr; } // *************************************************************************** +#ifdef WLED_ENABLE_I2SCLOCKLESS BusI2SClocklessLedDriver::BusI2SClocklessLedDriver(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { USER_PRINTF("Construct BusI2SClocklessLedDriver\n"); @@ -537,7 +538,7 @@ void BusI2SClocklessLedDriver::cleanup() { pinManager.deallocatePin(_pins[0], PinOwner::BusDigital); } - +#endif // *************************************************************************** #ifdef WLED_ENABLE_HUB75MATRIX diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index b347a47eb0..0e92e0058f 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -6,12 +6,14 @@ #include #endif +#ifdef WLED_ENABLE_I2SCLOCKLESS #ifdef CONFIG_IDF_TARGET_ESP32S3 #include "I2SClockLessLedDriveresp32s3.h" #include #else #include "I2SClocklessLedDriver.h" #endif +#endif /* * Class for addressing various light types @@ -341,6 +343,7 @@ class BusNetwork : public Bus { byte *_data; }; +#ifdef WLED_ENABLE_I2SCLOCKLESS class BusI2SClocklessLedDriver : public Bus { public: From 44246b3ae96c7e02e6beadd45e50126c4884c860 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:38:42 +0100 Subject: [PATCH 20/23] Add WLED_ENABLE_I2SCLOCKLESS --- wled00/bus_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 1bec50ee75..38fbdc624a 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -799,8 +799,10 @@ int BusManager::add(BusConfig &bc) { DEBUG_PRINTLN("BusManager::add - Adding BusHub75Matrix"); busses[numBusses] = new BusHub75Matrix(bc); #endif +#ifdef WLED_ENABLE_I2SCLOCKLESS } else if (bc.type == TYPE_I2SCL) { busses[numBusses] = new BusI2SClocklessLedDriver(bc); +#endif } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap); } else if (bc.type == TYPE_ONOFF) { From 611f401ee145b503ba70cfe34841ffaed07d5c88 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:45:51 +0100 Subject: [PATCH 21/23] Add WLED_ENABLE_I2SCLOCKLESS --- platformio.ini | 8 ++++++-- wled00/bus_manager.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 4499840721..7246d34a2c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -327,7 +327,7 @@ lib_deps = https://github.com/softhack007/LITTLEFS-threadsafe.git#master makuna/NeoPixelBus @ 2.7.5 ;; makuna/NeoPixelBus @ 2.7.9 ;; experimental - https://github.com/hpwit/I2SClocklessLedDriver#333754b + ${common_mm.I2SClockless_libs} ${env.lib_deps} ;; Compatibility with upstream --> you should prefer using ${common_mm.build_flags_S} and ${common_mm.lib_deps_S} @@ -365,7 +365,7 @@ lib_depsV4 = makuna/NeoPixelBus @ 2.7.5 ;; makuna/NeoPixelBus @ 2.7.9 ;; experimental ${common_mm.HUB75_lib_deps} - https://github.com/hpwit/I2SClocklessLedDriver#333754b + ${common_mm.I2SClockless_libs} ${env.lib_deps} @@ -1040,6 +1040,8 @@ HUB75_build_flags = HUB75_lib_deps = https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.10 HUB75_lib_ignore = ESP32 HUB75 LED MATRIX PANEL DMA Display ;; to remove the HUB75 lib dependancy (saves a few bytes) +I2SClockless_libs = https://github.com/hpwit/I2SClocklessLedDriver#333754b + NetDebug_build_flags = ;; WLEDMM: only setting WLED_DEBUG_HOST is enough, ip and port can be defined in sync settings as well -D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible @@ -1168,6 +1170,8 @@ build_flags = ${common.build_flags} ${common_mm.build_flags_S} ${common_mm.build ;-Wstack-usage=2732 ;; warn if a function needs more that 30% of availeable stack ("stack usage might be unbounded", "stack usage is 2824 bytes") ;-Wsuggest-attribute=const -Wsuggest-attribute=pure ;; ask compiler for hints on attributes ${common_mm.DMXin_build_flags} + -D WLED_ENABLE_I2SCLOCKLESS + lib_deps = ${common_mm.lib_deps_S} ;; do not include ${esp32.lib_depsV4} here !!!! ${common_mm.DMXin_lib_deps} esp32_build_flags = ${esp32.build_flagsV4} ${esp32_4MB_V4_S_base.build_flags} ;; this is for esp32 only, including specific "V4" flags diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 0e92e0058f..a9ebb2ca39 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -382,6 +382,8 @@ class BusI2SClocklessLedDriver : public Bus { int _pins[2] = {0,0}; }; +#endif + #ifdef WLED_ENABLE_HUB75MATRIX class BusHub75Matrix : public Bus { public: From 23194bd19397499ffd07fa4a1c402b0f73ec4633 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:52:01 +0100 Subject: [PATCH 22/23] S3 only, not all V4 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 7246d34a2c..e809045d52 100644 --- a/platformio.ini +++ b/platformio.ini @@ -460,6 +460,7 @@ build_flags = -g -D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_DFU_ON_BOOT=0 -DCO + -D WLED_ENABLE_I2SCLOCKLESS ;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry: ;; ARDUINO_USB_MODE, ARDUINO_USB_CDC_ON_BOOT lib_deps = @@ -1170,7 +1171,6 @@ build_flags = ${common.build_flags} ${common_mm.build_flags_S} ${common_mm.build ;-Wstack-usage=2732 ;; warn if a function needs more that 30% of availeable stack ("stack usage might be unbounded", "stack usage is 2824 bytes") ;-Wsuggest-attribute=const -Wsuggest-attribute=pure ;; ask compiler for hints on attributes ${common_mm.DMXin_build_flags} - -D WLED_ENABLE_I2SCLOCKLESS lib_deps = ${common_mm.lib_deps_S} ;; do not include ${esp32.lib_depsV4} here !!!! ${common_mm.DMXin_lib_deps} From abf80c362081cf1fa1fa0303a28b2f7b57295458 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 4 Jul 2024 19:58:54 +0100 Subject: [PATCH 23/23] No C3 --- platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index e809045d52..03a810fca7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -438,7 +438,6 @@ build_flags = -g -DARDUINO_USB_MODE=1 ;; this flag is mandatory for ESP32-C3 ;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry: ;; ARDUINO_USB_CDC_ON_BOOT - -D WLED_ENABLE_I2SCLOCKLESS lib_deps = https://github.com/pbolduc/AsyncTCP.git @ 1.2.0