Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP -Audio fastpath #40

Merged
merged 114 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
fb03a37
fps help in LED settings
softhack007 Apr 30, 2023
40c96c1
a bunch of smaller speedups to core functions
softhack007 Apr 30, 2023
f69142d
optimization for AA setPixelColorXY()
softhack007 Apr 30, 2023
ac5aed8
websocket bugfix from upstream
softhack007 Apr 30, 2023
0c58c12
audio fastpath: reduce filter delay
softhack007 Apr 30, 2023
e1cadbc
(experimental) reduced websocket frequency
softhack007 Apr 30, 2023
56b6290
Update audio_reactive.h
softhack007 Apr 30, 2023
91d36fa
fastpath: use i2s#1 for 5th LED pin
softhack007 May 2, 2023
7d0e627
some effect optimizations
softhack007 May 3, 2023
4341d36
move main JSON doc into PSRAM (experimental)
softhack007 May 4, 2023
ca5a54b
Merge branch 'mdev' into audio_fastpath
ewoudwijma May 4, 2023
f57c39c
new pio environment for ESP32 rev3 with PSRAM (faster)
softhack007 May 4, 2023
63ffc6e
Update platformio.ini
softhack007 May 4, 2023
d4fb542
Merge branch 'mdev' into audio_fastpath
softhack007 May 6, 2023
9a4c020
reduce file search buffer, to reduce file access delays
softhack007 May 6, 2023
50b3c9d
library updates
softhack007 May 7, 2023
04b55a5
back to NeoPixelBus @ 2.7.1
softhack007 May 7, 2023
d8bd451
Merge branch 'mdev' into audio_fastpath
softhack007 May 8, 2023
237286f
npm run build
softhack007 May 8, 2023
4810a85
Merge branch 'mdev' into audio_fastpath
softhack007 May 9, 2023
f050e60
well-defined fastled version
softhack007 May 10, 2023
c4664e5
Merge branch 'mdev' into audio_fastpath
softhack007 May 10, 2023
f147d79
Merge branch 'mdev' into audio_fastpath
softhack007 May 11, 2023
d5c33df
file buffer size: back to default
softhack007 May 12, 2023
6317dcb
swapped-channel workaround needed a bit longer
softhack007 May 11, 2023
9f6278a
Bugfix.
blazoncek May 14, 2023
6d23eb6
improve robustness when heap is low
softhack007 May 15, 2023
2e6d58f
small LED performance improvement
softhack007 May 15, 2023
72f7f9c
fix 8266 compile error
softhack007 May 15, 2023
175375e
Merge branch 'mdev' into audio_fastpath
ewoudwijma May 16, 2023
40d1201
Merge branch 'mdev' into audio_fastpath
ewoudwijma May 17, 2023
ef12aaa
Temp fix for leds array crashes: size fixed to 10000pixels/30000bytes
ewoudwijma May 17, 2023
894fdce
Merge remote-tracking branch 'upstream/main' into mdev
softhack007 May 21, 2023
fc19340
(experimental) use malloc/realloc for customMappingTable
softhack007 May 21, 2023
63e63ad
minor speedup for liveview and websockets
softhack007 May 21, 2023
d872629
Merge remote-tracking branch 'upstream/main' into mdev
softhack007 May 22, 2023
e6fb6c4
Merge pull request #39 from troyhacks/ES8388-Lyra-T-Fixes-Test
netmindz May 23, 2023
4197f98
package.json and cdata.js: set urls to MoonModules
ewoudwijma May 24, 2023
5edd5e6
tiny
ewoudwijma May 24, 2023
71153ee
small debug improvements
softhack007 May 25, 2023
df26430
audioreactive: replace dynamic buffer with static buffer
softhack007 May 25, 2023
e2eb3e8
npm run build
softhack007 May 25, 2023
9cb6189
minor speedup for 2D
softhack007 May 26, 2023
6d78e46
strip.service() optimization
softhack007 May 26, 2023
49f2e26
arduinoFFT hash update
softhack007 May 26, 2023
5081cfb
Bug fix, allocate string to store ledmap name
ewoudwijma May 29, 2023
859adb3
Update platformio.ini: fastled version update
softhack007 May 29, 2023
d8bc5e2
Dynamic Peek framerates :tada:
ewoudwijma May 29, 2023
1daeecc
Merge branch 'mdev' into audio_fastpath
softhack007 May 30, 2023
c13a5d7
post-merge
softhack007 May 30, 2023
36c34b5
Merge branch 'mdev' into audio_fastpath
ewoudwijma May 31, 2023
52fe8e2
Merge branch 'mdev' into audio_fastpath
softhack007 Jun 1, 2023
1b8ebfd
Added heap debug - enable with WLED_DEBUG_HEAP
troyhacks Jun 1, 2023
63b03a4
Merge branch 'mdev' into audio_fastpath
softhack007 Jun 1, 2023
c052da9
Merge pull request #50 from troyhacks/heap_debug
softhack007 Jun 1, 2023
f877837
platformio.ini: WLED_DEBUG_HEAP for 16MB debug targets
softhack007 Jun 1, 2023
dc77c17
Merge branch 'mdev' into audio_fastpath
softhack007 Jun 1, 2023
0f45b4f
webserver: removing JSON_BUFFER_SIZE for esp32
softhack007 Jun 1, 2023
55b0463
heap debug: show total free + fragmentation level
softhack007 Jun 1, 2023
53c8f9f
Minor edit to remove a space for clarity
troyhacks Jun 1, 2023
be2da7b
minor edit: tab inserted
softhack007 Jun 1, 2023
62990cd
Minor edit: typo
troyhacks Jun 2, 2023
cfc1116
Force reconnect via Serial input
troyhacks Jun 2, 2023
35f3f28
Oops. Bonus brace.
troyhacks Jun 2, 2023
4d64efa
sendLiveLedsWs: don't kick clients
softhack007 Jun 4, 2023
aded74d
suspendStripService improvements
softhack007 Jun 4, 2023
143f842
WLED_DEBUG_MAPS flag added
troyhacks Jun 6, 2023
b6f1a59
global buffer for UDP sound sync
softhack007 Jun 7, 2023
e6334d8
hide "slow strip" when compiling with HEAP_DEBUG
softhack007 Jun 7, 2023
f0dd66e
SoundSync: use local static buffer
softhack007 Jun 7, 2023
4dc6a38
Added code for dealing with low heap, heap debug.
troyhacks Jun 7, 2023
06344ae
FFT UDP fush if not read.
troyhacks Jun 7, 2023
7e1d15c
Merge branch 'audio_fastpath' of https://github.com/MoonModules/WLED …
troyhacks Jun 7, 2023
309e66b
Added fallback for ESP8266 to original code.
troyhacks Jun 7, 2023
af6091b
fixing some memory leaks
softhack007 Jun 7, 2023
d8a6889
build fix
softhack007 Jun 7, 2023
7465be7
heap mud scrum
softhack007 Jun 7, 2023
82f9be5
npm run build
troyhacks Jun 7, 2023
337b117
Merge branch 'audio_fastpath' of https://github.com/MoonModules/WLED …
troyhacks Jun 7, 2023
5c79375
Bug fix segment view, use ledmapMaxSize (TroyHack)
ewoudwijma Jun 8, 2023
b473a40
Tiny things
ewoudwijma Jun 8, 2023
d1b2759
npm run build
softhack007 Jun 8, 2023
7dcc8f1
enumerateLedmaps improvements
softhack007 Jun 8, 2023
d4a37ec
clean up ledmap names when directly reading from file
softhack007 Jun 9, 2023
a9cdd21
prevent strip flickering
softhack007 Jun 12, 2023
6883996
another mitigation for flickering
softhack007 Jun 13, 2023
47de28e
2D Lissajous improvements
softhack007 Jun 14, 2023
2410c22
2D Lissajous: revive old anti-aliased code
softhack007 Jun 14, 2023
3127c60
Merge branch 'mdev' into audio_fastpath
softhack007 Jun 15, 2023
d51a41f
post-merge
softhack007 Jun 15, 2023
a7d627b
Merge branch 'mdev' into audio_fastpath
softhack007 Jun 16, 2023
553f234
npm run build
softhack007 Jun 16, 2023
8aef434
re-enable old peak detect algo, plus ripplepeak bugfix
softhack007 Jun 18, 2023
708cd8e
free udp receive buffers before parsePacket
softhack007 Jun 20, 2023
310daa6
improve segment code robustness
softhack007 Jun 20, 2023
582b96f
robustness improvements
softhack007 Jun 21, 2023
1c53f14
Temporary bugfix for #3264
blazoncek Jun 24, 2023
3cc1d30
optimization for ABL hotfix
softhack007 Jul 1, 2023
a84c361
build number ++
softhack007 Jul 1, 2023
ecf3317
de-optimization
softhack007 Jul 3, 2023
29644cc
ABL optimization
softhack007 Jul 3, 2023
601499b
XY: minor bugfix
softhack007 Jul 6, 2023
5fe12ee
Merge branch 'mdev' into audio_fastpath
softhack007 Jul 8, 2023
a2e2ead
npm run build
softhack007 Jul 8, 2023
a45306b
blur speedup
softhack007 Jul 6, 2023
c64f74a
fix for random crashes on changing presets (UI)
softhack007 Jul 8, 2023
9a832ed
build number upgrade
softhack007 Jul 8, 2023
9ed5dc7
npm run build
softhack007 Jul 8, 2023
c22c92e
preview at full brightness
softhack007 Jul 10, 2023
0fb5edc
robustness improvements from upstream
softhack007 Jul 13, 2023
3295579
jsonToPixels robustness
softhack007 Jul 13, 2023
9a3a97e
pre-merge
softhack007 Jul 13, 2023
99def64
live view: more updates in non-fastpath builds
softhack007 Jul 13, 2023
9243b90
max is faster than MAX
softhack007 Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 51 additions & 12 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ upload_speed = 115200
# ------------------------------------------------------------------------------
lib_compat_mode = strict
lib_deps =
fastled/FastLED @ 3.5.0
;fastled/FastLED @ 3.5.0
https://github.com/FastLED/FastLED.git#master ;; up to 50% faster
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it perhaps an idea to refer to a "known good" hash, so we get predictable builds?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Makes sense 👍

IRremoteESP8266 @ 2.8.2
;;https://github.com/Aircoookie/ESPAsyncWebServer.git @ ~2.0.7
https://github.com/lost-hope/ESPAsyncWebServer.git#master ;; WLEDMM to display .log and .wled files in /edit
Expand Down Expand Up @@ -244,8 +245,8 @@ lib_deps =
#https://github.com/lorol/LITTLEFS.git
ESPAsyncTCP @ 1.2.2
ESPAsyncUDP
${env.lib_deps}
makuna/NeoPixelBus @ 2.6.9
${env.lib_deps}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordering significant or just accidental change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually ordering is significant. It seems that the first library reference "wins".
This was changed recently in upstream, to ensure that the right library versions are pulled in.


[esp32]
#platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.3/platform-espressif32-2.0.2.3.zip
Expand All @@ -269,8 +270,9 @@ lib_deps =
; https://github.com/lorol/LITTLEFS.git
; WLEDMM specific: use patched version of lorol LittleFS
https://github.com/softhack007/LITTLEFS-threadsafe.git#master
;;makuna/NeoPixelBus @ 2.6.9 ;; WLEDMM default
makuna/NeoPixelBus @ 2.7.1
${env.lib_deps}
makuna/NeoPixelBus @ 2.6.9

;; ** For compiling with latest Frameworks (IDF4.4.x and arduino-esp32 v2.0.x) **
;;; standard V4 platform
Expand All @@ -296,9 +298,8 @@ build_flagsV4 = -g
;;; V4.4.x libraries (without LOROL_LITTLEFS; with newer NeoPixelBus)
lib_depsV4 =
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 ;; WLEDMM this must be first in the list, otherwise Aircoookie/ESPAsyncWebServer pulls in an older version of AsyncTCP !!
makuna/NeoPixelBus @ 2.7.3
${env.lib_deps}
;https://github.com/Makuna/NeoPixelBus.git#master ;; NPB 2.6.9 tends to crash whith IDF V4.4.3 -> use latest NeoPixelBus dev instead
makuna/NeoPixelBus @ 2.7.1

[esp32s2]
build_flags = -g
Expand All @@ -314,8 +315,8 @@ build_flags = -g

lib_deps =
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 ;; WLEDMM this must be first in the list, otherwise Aircoookie/ESPAsyncWebServer pulls in an older version of AsyncTCP !!
makuna/NeoPixelBus @ 2.7.3 ;; WLEDMM - new version is more stable on -S2
${env.lib_deps}
makuna/NeoPixelBus @ 2.7.1 ;; WLEDMM - new version is more stable on -S2

[esp32c3]
build_flags = -g
Expand Down Expand Up @@ -352,8 +353,8 @@ build_flags = -g

lib_deps =
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
${env.lib_deps}
makuna/NeoPixelBus @ 2.7.3
${env.lib_deps}


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -812,6 +813,7 @@ build_flags_S =
-D USERMOD_AUDIOREACTIVE
-D UM_AUDIOREACTIVE_USE_NEW_FFT ; use latest (upstream) FFTLib, instead of older library modified by blazoncek. Slightly faster, more accurate, needs 2KB RAM extra
-D USERMOD_ARTIFX ; WLEDMM usermod
-D WLEDMM_FASTPATH ; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates
; -D WLED_DISABLE_LOXONE
; -D WLED_DISABLE_ALEXA
; -D WLED_DISABLE_HUESYNC
Expand Down Expand Up @@ -914,7 +916,9 @@ lib_deps = ${esp32_4MB_M_base.lib_deps} ${common_mm.lib_deps_XL}
board = esp32dev
upload_speed = 460800 ; or 921600
platform = ${esp32.platformV4}
platform_packages = ${esp32.platformV4_packages}
platform_packages =
${esp32.platformV4_packages}
toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5 ; align main tools with riscV tools
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32.build_flagsV4} ${common_mm.build_flags_S}
-Wno-misleading-indentation -Wno-format-truncation
Expand Down Expand Up @@ -1239,16 +1243,14 @@ build_flags = ${esp32_4MB_V4_M_base.build_flags}
-D WLED_RELEASE_NAME=esp32_4MB_V4_M
-D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET
-D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup
; RAM: [== ] 24.8% (used 81316 bytes from 327680 bytes)
; Flash: [==========] 97.2% (used 1528253 bytes from 1572864 bytes)
-D WLED_DISABLE_LOXONE ; FLASH 1272 bytes
-D WLED_DISABLE_ALEXA ; RAM 116 bytes; FLASH 13524 bytes
-D WLED_DISABLE_HUESYNC ;RAM 122 bytes; FLASH 6308 bytes
; RAM: [== ] 24.7% (used 81076 bytes from 327680 bytes)
; Flash: [==========] 95.8% (used 1506893 bytes from 1572864 bytes)
;-D WLED_DISABLE_MQTT ; RAM 216 bytes; FLASH 16496 bytes
-D WLED_DISABLE_INFRARED ;RAM 136 bytes; FLASH 24492 bytes ;; softhack007 disabled to stay below 100% flash size
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
;; RAM: [== ] 24.7% (used 80884 bytes from 327680 bytes)
;; Flash: [==========] 99.0% (used 1556429 bytes from 1572864 bytes)

; compiled with ESP-IDF 4.4.1
[env:esp32_16MB_V4_M]
Expand Down Expand Up @@ -1303,6 +1305,43 @@ lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compila
;; RAM: [== ] 24.3% (used 79524 bytes from 327680 bytes)
;; Flash: [========= ] 93.2% (used 1466389 bytes from 1572864 bytes)

;; similar to 4MB_PSRAM_S, but optimized for WROVER-E (chip revision >= 3) that doesn't need any workarounds for PSRAM any more
;; tl;dr: its faster on PSRAM. But it will not work on all boards.
[env:esp32_4MB_PSRAM_REV3_S]
extends = esp32_4MB_V4_S_base
;board = esp32cam
board = lolin_d32_pro
;board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; Alternative for 4MB flash: 1.8MB firmware, 256KB filesystem (esptool erase_flash needed before changing)
build_unflags = ${esp32_4MB_V4_S_base.build_unflags}
-DARDUINO_EVENT_RUNNING_CORE=1 ;; we want to run wifi on core0, so remove the standard flag
-mfix-esp32-psram-cache-issue ;; this fix is not needed any more for revision 3
-mfix-esp32-psram-cache-strategy=memw ;; same as above
;;-Os ;; if you want to be even faster - use together with "-O2" in build_flags. Enable alternative default_partitions (above) to have more program space.

build_flags = ${esp32_4MB_V4_S_base.build_flags}
-DARDUINO_EVENT_RUNNING_CORE=0 ;; assign Wifi to core0, to have more CPU on core#1 (arduino loop)
-DARDUINO_RUNNING_CORE=1 ;; should be default, but does not hurt
;-DCONFIG_MBEDTLS_DYNAMIC_BUFFER=1 ;; optional - seems to move more buffers into PSRAM
;; enable the next line together with "-Os" in build_unflags (unfortunately --> 104.0%% Flash)
;;-O2 -fno-jump-tables -fno-tree-switch-conversion -Wwrite-strings -fstrict-volatile-bitfields
-DBOARD_HAS_PSRAM -D WLED_USE_PSRAM_JSON ;; -D WLED_USE_PSRAM ;; WLED_USE_PSRAM causes major slow-down (slow LEDs) on some ESP32 boards
-D WLED_RELEASE_NAME=esp32_4MB_PSRAM_REV3_S
-D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET
-D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup
-D WLED_DISABLE_LOXONE ; FLASH 1272 bytes
-D WLED_DISABLE_HUESYNC ; RAM 122 bytes; FLASH 6308 bytes
-D WLED_DISABLE_ALEXA ; RAM 116 bytes; FLASH 13524 bytes
-D WLED_DISABLE_MQTT ; RAM 216 bytes; FLASH 16496 bytes
-D WLED_DISABLE_INFRARED ;RAM 136 bytes; FLASH 24492 bytes ewowi: disabled to stay below 100%
;-D WLED_DISABLE_ADALIGHT ;; To disable serial protocols (see upstream #3128)
; -D WLED_ENABLE_DMX
; -D WLED_DEBUG
; -D SR_DEBUG
; -D MIC_LOGGER
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
;; RAM: [== ] 16.8% (used 55124 bytes from 327680 bytes)
;; Flash: [========= ] 92.7% (used 1458729 bytes from 1572864 bytes)

;; PSRAM build env that only leaves 300Kb for filesystem (instead of 1MB), but adds 300kB for program space
[env:esp32_4MB_PSRAM_M]
extends = esp32_4MB_V4_M_base
Expand Down
13 changes: 13 additions & 0 deletions usermods/audioreactive/audio_reactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ constexpr SRate_t SAMPLE_RATE = 22050; // Base sample rate in Hz - 22Khz
//constexpr SRate_t SAMPLE_RATE = 16000; // 16kHz - use if FFTtask takes more than 20ms. Physical sample time -> 32ms
//constexpr SRate_t SAMPLE_RATE = 20480; // Base sample rate in Hz - 20Khz is experimental. Physical sample time -> 25ms
//constexpr SRate_t SAMPLE_RATE = 10240; // Base sample rate in Hz - previous default. Physical sample time -> 50ms
#ifndef WLEDMM_FASTPATH
#define FFT_MIN_CYCLE 21 // minimum time before FFT task is repeated. Use with 22Khz sampling
#else
#define FFT_MIN_CYCLE 15 // reduce min time, to allow faster catch-up when I2S is lagging
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any downside to this change? "Compromise" for speed or just masking changes behind flag until we have done enough testing to know if this should just be right value for all uses?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the downside is that the FFT task will block the core for longer (2ms in "standard", vs 7ms in "fastpath").

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are using the second core, is that an issue? What else (if anything) is using that core?

#endif
//#define FFT_MIN_CYCLE 30 // Use with 16Khz sampling
//#define FFT_MIN_CYCLE 23 // minimum time before FFT task is repeated. Use with 20Khz sampling
//#define FFT_MIN_CYCLE 46 // minimum time before FFT task is repeated. Use with 10Khz sampling
Expand Down Expand Up @@ -1129,8 +1133,13 @@ class AudioReactive : public Usermod {
{
float sampleAdj; // Gain adjusted sample value
float tmpSample; // An interim sample variable used for calculatioins.
#ifdef WLEDMM_FASTPATH
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any downside to this change? "Compromise" for speed or just masking changes behind flag until we have done enough testing to know if this should just be right value for all uses?

constexpr float weighting = 0.35f; // slightly reduced filter strength, to reduce audio latency
constexpr float weighting2 = 0.25f;
#else
const float weighting = 0.2f; // Exponential filter weighting. Will be adjustable in a future release.
const float weighting2 = 0.073f; // Exponential filter weighting, for rising signal (a bit more robust against spikes)
#endif
const int AGC_preset = (soundAgc > 0)? (soundAgc-1): 0; // make sure the _compiler_ knows this value will not change while we are inside the function
static bool isFrozen = false;
static bool haveSilence = true;
Expand Down Expand Up @@ -1732,7 +1741,11 @@ class AudioReactive : public Usermod {

// get AGC sensitivity and sound pressure
static unsigned long lastEstimate = 0;
#ifdef WLEDMM_FASTPATH
if (millis() - lastEstimate > 7) {
#else
if (millis() - lastEstimate > 12) {
#endif
lastEstimate = millis();
agcSensitivity = getSensitivity();
if (limiterOn)
Expand Down
5 changes: 5 additions & 0 deletions usermods/audioreactive/audio_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ class I2SSource : public AudioSource {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
//.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
#ifdef WLEDMM_FASTPATH
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3, // seems to reduce noise
.dma_buf_count = 28, // 160ms buffer (128 * dma_buf_count / sampleRate)
#else
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2,
.dma_buf_count = 8,
#endif
.dma_buf_len = _blockSize,
.use_apll = 0,
//.fixed_mclk = 0,
Expand Down
18 changes: 9 additions & 9 deletions usermods/usermod_v2_weather/usermod_v2_weather.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ uint16_t mode_2DWeather(void) {
// currentTime = localTime;
}
else
color = ColorFromPalette(SEGPALETTE, map((uint8_t)weather_temps[x%100], 0, 40, 0, 255), 255, LINEARBLEND);
color = ColorFromPalette(SEGPALETTE, map((uint8_t)weather_temps[x%100], 0, 40, 1, 255), 255, LINEARBLEND);

for (int y=0; y<SEGMENT.virtualHeight() * (weather_temps[x%100]-weather_minTemp)/(weather_maxTemp - weather_minTemp); y++) {
SEGMENT.setPixelColorXY(x, SEGMENT.virtualHeight() - y, color);
Expand All @@ -58,7 +58,7 @@ uint16_t mode_2DWeather(void) {
snprintf(tempString, 5, "%5.2f", currentTemp); // snprintf will prevent overflow
// Serial.println();

CRGB color = ColorFromPalette(SEGPALETTE, map((uint8_t)currentTemp, 0, 40, 0, 255), 255, LINEARBLEND);
CRGB color = ColorFromPalette(SEGPALETTE, map((uint8_t)currentTemp, 0, 40, 1, 255), 255, LINEARBLEND);
//really don't understand why this is not working if width < 16 (only works when Serial.println is uncommented ???)
// uint16_t x = 0;
// const uint16_t xSpace = (SEGMENT.virtualWidth()<16)?4:5;
Expand All @@ -78,17 +78,17 @@ uint16_t mode_2DWeather(void) {
// // Serial.printf(" %d %d\n", x, xSpace);

if (SEGMENT.virtualWidth() < 16) {
SEGMENT.drawCharacter(tempString[0], 0, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[1], 4, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[0], 0, -2, 5, 8, uint32_t(color), BLACK);
SEGMENT.drawCharacter(tempString[1], 4, -2, 5, 8, uint32_t(color), BLACK);
SEGMENT.setPixelColorXY(8, 4, color);
SEGMENT.drawCharacter(tempString[3], 9, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[3], 9, -2, 5, 8, uint32_t(color), BLACK);
}
else {
SEGMENT.drawCharacter(tempString[0], 0, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[1], 5, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[0], 0, -2, 5, 8, uint32_t(color), BLACK);
SEGMENT.drawCharacter(tempString[1], 5, -2, 5, 8, uint32_t(color), BLACK);
SEGMENT.setPixelColorXY(10, 4, color);
SEGMENT.drawCharacter(tempString[3], 12, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[4], 17, -2, 5, 8, color);
SEGMENT.drawCharacter(tempString[3], 12, -2, 5, 8, uint32_t(color), BLACK);
SEGMENT.drawCharacter(tempString[4], 17, -2, 5, 8, uint32_t(color), BLACK);
}

return FRAMETIME;
Expand Down
43 changes: 29 additions & 14 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ uint16_t mode_colortwinkle() {
}
}
}
return FRAMETIME_FIXED;
return FRAMETIME_FIXED_SLOW;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have all effects that use this constant been updated or just been changing one by one as you test?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as I tested it. Some effects seem to be meant to be slow, like Halloween eyes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should they not be time-based rather than FPS based?

}
static const char _data_FX_MODE_COLORTWINKLE[] PROGMEM = "Colortwinkles@Fade speed,Spawn speed;;!;;m12=0"; //pixels

Expand Down Expand Up @@ -3096,7 +3096,7 @@ uint16_t candle(bool multi)
}
}

return FRAMETIME_FIXED;
return FRAMETIME_FIXED_SLOW;
}


Expand Down Expand Up @@ -6042,6 +6042,7 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
// printUmData();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGENV.aux0 = 255;
SEGMENT.custom1 = *binNum;
SEGMENT.custom2 = *maxVol * 2;
Expand All @@ -6052,8 +6053,9 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
*binNum = SEGMENT.custom1; // Select a bin.
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.

SEGMENT.fade_out(240); // Lower frame rate means less effective fading than FastLED
SEGMENT.fade_out(240);
//SEGMENT.fade_out(240); // Lower frame rate means less effective fading than FastLED
//SEGMENT.fade_out(240);
SEGMENT.fade_out(224); // should be the same as 240 applied twice

for (int i = 0; i < SEGMENT.intensity/16; i++) { // Limit the number of ripples.
if (samplePeak) ripples[i].state = 255;
Expand All @@ -6066,7 +6068,8 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
ripples[i].pos = random16(SEGLEN);
#ifdef ESP32
if (FFT_MajorPeak > 1) // log10(0) is "forbidden" (throws exception)
ripples[i].color = (int)(log10f(FFT_MajorPeak)*128);
//ripples[i].color = (int)(log10f(FFT_MajorPeak)*128); // not to self: buggy !!
ripples[i].color = (int)(logf(FFT_MajorPeak)*32.0f); // works up to 10025 hz
else ripples[i].color = 0;
#else
ripples[i].color = random8();
Expand Down Expand Up @@ -6476,8 +6479,12 @@ uint16_t mode_midnoise(void) { // Midnoise. By Andrew Tuline.
}
float volumeSmth = *(float*) um_data->u_data[0];

SEGMENT.fade_out(SEGMENT.speed);
SEGMENT.fade_out(SEGMENT.speed);
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}
SEGMENT.fadeToBlackBy(SEGMENT.speed/2);
//SEGMENT.fade_out(SEGMENT.speed);

float tmpSound2 = volumeSmth * (float)SEGMENT.intensity / 256.0; // Too sensitive.
tmpSound2 *= (float)SEGMENT.intensity / 128.0; // Reduce sensitity/length.
Expand Down Expand Up @@ -6622,8 +6629,13 @@ uint16_t mode_plasmoid(void) { // Plasmoid. By Andrew Tuline.
}
float volumeSmth = *(float*) um_data->u_data[0];

SEGMENT.fadeToBlackBy(32);

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}
//SEGMENT.fadeToBlackBy(32);
SEGMENT.fadeToBlackBy(48);

plasmoip->thisphase += beatsin8(6,-4,4); // You can change direction and speed individually.
plasmoip->thatphase += beatsin8(7,-4,4); // Two phase values to make a complex pattern. By Andrew Tuline.

Expand Down Expand Up @@ -6832,7 +6844,7 @@ uint16_t mode_blurz(void) { // Blurz. By Andrew Tuline.
SEGMENT.setPixelColor(segLoc, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette((uint16_t)pixColor, false, PALETTE_SOLID_WRAP, 0),(uint8_t)pixIntensity)); // repaint center pixel after blur
} else SEGMENT.blur(max(SEGMENT.intensity, (uint8_t)1)); // silence - just blur it again

return FRAMETIME;
return FRAMETIME_FIXED;
} // mode_blurz()
static const char _data_FX_MODE_BLURZ[] PROGMEM = "Blurz ☾@Fade rate,Blur;!,Color mix;!;1f;sx=48,ix=127,m12=0,si=0"; // Pixels, Beatsin
#endif
Expand Down Expand Up @@ -6921,7 +6933,10 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN.
float my_magnitude = *(float*)um_data->u_data[5] / 4.0f;
if (FFT_MajorPeak < 1) FFT_MajorPeak = 1; // log10(0) is "forbidden" (throws exception)

if (SEGENV.call == 0) SEGMENT.fill(BLACK);
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}
int fadeoutDelay = (256 - SEGMENT.speed) / 32;
if ((fadeoutDelay <= 1 ) || ((SEGENV.call % fadeoutDelay) == 0)) SEGMENT.fade_out(SEGMENT.speed);

Expand All @@ -6944,7 +6959,7 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN.
SEGMENT.setPixelColor(locn, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(SEGMENT.intensity+pixCol, false, PALETTE_SOLID_WRAP, 0), bright));
}

return FRAMETIME;
return FRAMETIME_FIXED;
} // mode_freqmap()
static const char _data_FX_MODE_FREQMAP[] PROGMEM = "Freqmap@Fade rate,Starting color;!,!;!;1f;m12=0,si=0"; // Pixels, Beatsin

Expand Down Expand Up @@ -7067,8 +7082,8 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
SEGMENT.fill(BLACK);
}

uint8_t secondHand = micros()/(256-SEGMENT.speed)/500 % 16;
if((SEGMENT.speed > 254) || (SEGENV.aux0 != secondHand)) { // WLEDMM allow run run at full speed
uint8_t secondHand = (SEGMENT.speed < 255) ? (micros()/(256-SEGMENT.speed)/500 % 16) : 0;
if((SEGMENT.speed > 254) || (SEGENV.aux0 != secondHand)) { // WLEDMM allow to run at full speed
SEGENV.aux0 = secondHand;

float sensitivity = 0.5f * mapf(SEGMENT.custom3, 1, 31, 0.5, 10); // reduced resolution slider
Expand Down
Loading