From 07d204e43113bbca926597c4cdc68e789ab4c1a0 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:00:49 +0200 Subject: [PATCH 1/5] enable AGC in new installs if SR_SQUELCH is specified by the build env, change AGC default to enabled. --- usermods/audioreactive/audio_reactive.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 9de947ae..4f978607 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -98,7 +98,12 @@ static float micDataReal = 0.0f; // MicIn data with full 24bit re static float multAgc = 1.0f; // sample * multAgc = sampleAgc. Our AGC multiplier static float sampleAvg = 0.0f; // Smoothed Average sample - sampleAvg < 1 means "quiet" (simple noise gate) static float sampleAgc = 0.0f; // Smoothed AGC sample +#ifdef SR_SQUELCH +static uint8_t soundAgc = 1; // Automagic gain control: 0 - none, 1 - normal, 2 - vivid, 3 - lazy (config value) - enable AGC if default "squelch" was provided +#else static uint8_t soundAgc = 0; // Automagic gain control: 0 - none, 1 - normal, 2 - vivid, 3 - lazy (config value) +#endif + #endif static float volumeSmth = 0.0f; // either sampleAvg or sampleAgc depending on soundAgc; smoothed sample static float FFT_MajorPeak = 1.0f; // FFT: strongest (peak) frequency From 523893be02f90be7e643f9fe4ab65682e15691fd Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:18:37 +0200 Subject: [PATCH 2/5] 8266 audioreactive: fix crash during OTA * fix crash when starting OTA: `Panic core_esp8266_main.cpp:191 __yield ` * prevent sound sync reconnect during OTA --- usermods/audioreactive/audio_reactive.h | 8 ++++++-- wled00/wled.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 4f978607..c7fd194a 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -992,6 +992,8 @@ class AudioReactive : public Usermod { const uint16_t delayMs = 10; // I don't want to sample too often and overload WLED uint16_t audioSyncPort= 11988;// default port for UDP sound sync + bool updateIsRunning = false; // true during OTA. + #ifdef ARDUINO_ARCH_ESP32 // used for AGC int last_soundAgc = -1; // used to detect AGC mode change (for resetting AGC internal error buffers) @@ -1436,6 +1438,7 @@ class AudioReactive : public Usermod { } if (udpSyncConnected) return; // already connected if (millis() - last_connection_attempt < 15000) return; // only try once in 15 seconds + if (updateIsRunning) return; // don't reconect during OTA // if we arrive here, we need a UDP connection but don't have one last_connection_attempt = millis(); @@ -2036,6 +2039,7 @@ class AudioReactive : public Usermod { } micDataReal = 0.0f; // just to be sure if (enabled) disableSoundProcessing = false; + updateIsRunning = init; } #else // reduced function for 8266 @@ -2056,8 +2060,8 @@ class AudioReactive : public Usermod { receivedFormat = 0; } } - yield(); // to make sure that Wifi stays alive - if (enabled) disableSoundProcessing = false; + if (enabled) disableSoundProcessing = init; // init = true means that OTA is just starting --> don't process audio + updateIsRunning = init; } #endif diff --git a/wled00/wled.h b/wled00/wled.h index 976df74d..9473e9d8 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2308240 +#define VERSION 2308250 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG From e6e30abfeb038e919a694cade0f02731cd1b93df Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:51:07 +0200 Subject: [PATCH 3/5] 8266: improve accuracy of FPS calculation based on a similar correction I made in upstream recently. --- wled00/FX_fcn.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 51c4889f..6b45977f 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1775,16 +1775,18 @@ void WS2812FX::show(void) { estimateCurrentAndLimitBri(); + #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH) + unsigned long b4show = millis(); // WLEDMM the time before calling "show" + #endif // some buses send asynchronously and this method will return before // all of the data has been sent. // See https://github.com/Makuna/NeoPixelBus/wiki/ESP32-NeoMethods#neoesp32rmt-methods - unsigned long b4show = millis(); // WLEDMM the time before calling "show" busses.show(); unsigned long now = millis(); unsigned long diff = now - _lastShow; uint16_t fpsCurr = 200; if (diff > 0) fpsCurr = 1000 / diff; - _cumulativeFps = (3 * _cumulativeFps + fpsCurr) >> 2; + _cumulativeFps = (3 * _cumulativeFps + fpsCurr +2) >> 2; // "+2" for proper rounding (2/4 = 0.5) #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH) _lastShow = b4show; // WLEDMM this is more accurate, however it also icreases CPU load - strip.service will run more frequently #else From 2b34b30314b623e9396865892c7eb4c674d90aa1 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:13:42 +0200 Subject: [PATCH 4/5] net debug for esp32_4MB_S --- platformio.ini | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 273759e9..2802084e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1094,7 +1094,7 @@ build_unflags = ; bin entries (with WLED_RELEASE_NAME) - +;; ESP32, 4MB, optimized for speed, basic features and audioreactive only [env:esp32_4MB_S] extends = esp32_4MB_S_base build_unflags = ${esp32_4MB_S_base.build_unflags} @@ -1109,12 +1109,15 @@ build_flags = ${esp32_4MB_S_base.build_flags} -D WLED_DISABLE_LOXONE ;-D WLED_DISABLE_MQTT ;-D WLED_DISABLE_INFRARED + ;WLEDMM: disable the next two lines if you don't need "net Debug". It will free ~2% of flash + -D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible + -D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868 ;; normal build ; RAM: [=== ] 25.0% (used 81988 bytes from 327680 bytes) ; Flash: [========= ] 87.4% (used 1374677 bytes from 1572864 bytes) WLEDMM: Earlier 85.7 ;; optimized-for-speed build -; RAM: [=== ] 25.1% (used 82092 bytes from 327680 bytes) -; Flash: [==========] 98.8% (used 1553629 bytes from 1572864 bytes) +; RAM: [=== ] 25.8% (used 84628 bytes from 327680 bytes) +; Flash: [==========] 99.4% (used 1562869 bytes from 1572864 bytes) [env:esp32_4MB_M] extends = esp32_4MB_M_base From bb6f84d18c85703ddfd9aab2e9731782295c712a Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:26:40 +0200 Subject: [PATCH 5/5] pin summary: don't report "fake" conflicts with same owner sometimes happens in debug mode. GPIO | Assigned to | Info --------|-----------------------|------------ i/o 1 debug output !! Conflict with debug output !! Serial TX --- wled00/pin_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index dd8eb16e..d7c7a21c 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -270,7 +270,7 @@ String PinManagerClass::getPinConflicts(int gpio) { if ((gpio == 0xFF) || (gpio < 0)) return(F("")); // explicitly allow -1 as a no-op if (!isPinOk(gpio, false)) return(F("")); // invalid GPIO - if (ownerConflict[gpio] == PinOwner::None) { + if ((ownerConflict[gpio] == PinOwner::None) || (ownerTag[gpio] == ownerConflict[gpio])) { // no conflict, or "fake" conflict with current owner return(F("")); // no conflict fot this GPIO } else { // found previous conflic! return String("!! Conflict with ") + getOwnerText(ownerConflict[gpio]) + String(" !!");