Skip to content

Commit 72e8fca

Browse files
authored
Merge branch 'MoonModules:mdev' into Strip_Level_Color_Adjust
2 parents 8cb5028 + fc173b3 commit 72e8fca

File tree

21 files changed

+590
-213
lines changed

21 files changed

+590
-213
lines changed

pio-scripts/output_bins.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,88 @@ def _create_dirs(dirs=["firmware", "map"]):
2222
if not os.path.isdir("{}{}".format(OUTPUT_DIR, d)):
2323
os.mkdir("{}{}".format(OUTPUT_DIR, d))
2424

25+
26+
# trick for py2/3 compatibility
27+
if 'basestring' not in globals():
28+
basestring = str
29+
30+
# WLEDMM : custom print function
31+
def print_my_item(items, flag = False):
32+
if flag: print(" -D", end='')
33+
else: print(" ", end='')
34+
if isinstance(items, basestring):
35+
# print a single string
36+
print(items, end='')
37+
else:
38+
# print a list
39+
first = True
40+
for item in items:
41+
if not first: print("=", end='')
42+
print(item, end='')
43+
first = False
44+
45+
# WLEDMM : dump out buildflags : usermods, disable, enable, use_..
46+
def wledmm_print_build_info(env):
47+
all_flags = env["CPPDEFINES"]
48+
first = True
49+
50+
found = False
51+
for item in all_flags:
52+
if 'WLED_RELEASE_NAME' in item[0] or 'WLED_VERSION' in item[0] or 'ARDUINO_USB_CDC_ON_BOOT' in item[0]:
53+
if first: print("\nUsermods and Features:")
54+
print_my_item(item)
55+
first = False
56+
found = True
57+
if found: print("")
58+
59+
found = False
60+
for item in all_flags:
61+
if 'USERMOD_' in item or 'UM_' in item:
62+
if first: print("\nUsermods and Features:")
63+
print_my_item(item)
64+
first = False
65+
found = True
66+
if found: print("")
67+
68+
found = False
69+
for item in all_flags:
70+
if 'WLED_DISABLE' in item or 'WIFI_FIX' in item:
71+
if first: print("\nUsermods and Features:")
72+
print_my_item(item)
73+
first = False
74+
found = True
75+
if found: print("")
76+
77+
found = False
78+
for item in all_flags:
79+
if 'WLED_' in item or 'WLED_' in item[0] or 'MAX_LED' in item[0]:
80+
if not 'WLED_RELEASE_NAME' in item[0] and not 'WLED_VERSION' in item[0] and not 'WLED_WATCHDOG_TIMEOUT' in item[0] and not 'WLED_DISABLE' in item and not 'WLED_USE_MY_CONFIG' in item and not 'ARDUINO_PARTITION' in item:
81+
if first: print("\nUsermods and Features:")
82+
print_my_item(item)
83+
first = False
84+
found = True
85+
if found: print("")
86+
87+
first = True
88+
found = False
89+
for item in all_flags:
90+
if 'WLEDMM_' in item[0] or 'WLEDMM_' in item or 'TROYHACKS' in item:
91+
if first: print("\nWLEDMM Features:")
92+
print_my_item(item)
93+
first = False
94+
found = True
95+
if found: print("\n")
96+
97+
def wledmm_print_all_defines(env):
98+
all_flags = env["CPPDEFINES"]
99+
found = False
100+
for item in all_flags:
101+
if not found: print("\nBuild Flags:")
102+
print_my_item(item, True)
103+
found = True
104+
if found: print("\n")
105+
106+
25107
def bin_rename_copy(source, target, env):
26108
_create_dirs()
27109
variant = env["PIOENV"]
@@ -56,6 +138,9 @@ def bin_rename_copy(source, target, env):
56138
print(f"Found linker mapfile {source_map}")
57139
shutil.copy(source_map, map_file)
58140

141+
# wledmm_print_all_defines(env)
142+
# wledmm_print_build_info(env)
143+
59144
def bin_gzip(source, target, env):
60145
_create_dirs()
61146
variant = env["PIOENV"]

platformio.ini

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ build_flags = -g
305305
-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE
306306
#use LITTLEFS library by lorol in ESP32 core 1.x.x instead of built-in in 2.x.x
307307
-D LOROL_LITTLEFS
308+
; -D WLEDMM_TWOPATH ;; use I2S1 as the second bus --> ~15% faster on "V3" builds - may flicker a bit more
309+
; -D WLEDMM_SLOWPATH ;; don't use I2S for LED bus
308310
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
309311

310312
default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv ;; WLED standard for 4MB flash: 1.4MB firmware, 1MB filesystem
@@ -322,6 +324,7 @@ lib_deps =
322324
; WLEDMM specific: use patched version of lorol LittleFS
323325
https://github.com/softhack007/LITTLEFS-threadsafe.git#master
324326
makuna/NeoPixelBus @ 2.7.5
327+
;; makuna/NeoPixelBus @ 2.7.9 ;; experimental
325328
${env.lib_deps}
326329

327330
;; Compatibility with upstream --> you should prefer using ${common_mm.build_flags_S} and ${common_mm.lib_deps_S}
@@ -348,13 +351,16 @@ build_flagsV4 = -g
348351
-DCONFIG_LITTLEFS_FOR_IDF_3_2 -DLFS_THREADSAFE
349352
-D CONFIG_ASYNC_TCP_USE_WDT=0
350353
-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE
354+
; -D WLEDMM_TWOPATH ;; use I2S1 as the second bus --> slightly faster on some setups
355+
; -D WLEDMM_SLOWPATH ;; don't use I2S for LED bus
351356
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
352357
-D NO_GFX ; Disable the use of Adafruit_GFX by the HUB75 driver
353358

354359
;;; V4.4.x libraries (without LOROL_LITTLEFS; with newer NeoPixelBus)
355360
lib_depsV4 =
356361
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 !!
357362
makuna/NeoPixelBus @ 2.7.5
363+
;; makuna/NeoPixelBus @ 2.7.9 ;; experimental
358364
${common_mm.HUB75_lib_deps}
359365
${env.lib_deps}
360366

@@ -376,10 +382,13 @@ build_flags = -g
376382
-D CONFIG_ASYNC_TCP_USE_WDT=0
377383
-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE
378384
-DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
385+
; -D WLEDMM_TWOPATH ;; use I2S1 as the second bus --> slightly faster on some setups
386+
; -D WLEDMM_SLOWPATH ;; don't use I2S for LED bus
379387
default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
380388
lib_deps =
381389
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
382390
makuna/NeoPixelBus @ 2.7.5
391+
;; makuna/NeoPixelBus @ 2.7.9 ;; experimental
383392
${env.lib_deps}
384393

385394
[esp32s2]
@@ -406,7 +415,8 @@ build_flags = -g
406415

407416
lib_deps =
408417
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
409-
makuna/NeoPixelBus @ 2.7.5
418+
;; makuna/NeoPixelBus @ 2.7.5 ;; standard
419+
makuna/NeoPixelBus @ 2.7.9 ;; experimental - reduces LED glitches on -S2
410420
${env.lib_deps}
411421

412422
[esp32c3]
@@ -428,6 +438,7 @@ build_flags = -g
428438
lib_deps =
429439
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
430440
makuna/NeoPixelBus @ 2.7.5
441+
;; makuna/NeoPixelBus @ 2.7.9 ;; experimental
431442
${env.lib_deps}
432443

433444
[esp32s3]
@@ -449,6 +460,7 @@ build_flags = -g
449460
lib_deps =
450461
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
451462
makuna/NeoPixelBus @ 2.7.5
463+
;; makuna/NeoPixelBus @ 2.7.9 ;; experimental
452464
${env.lib_deps}
453465

454466

@@ -2464,16 +2476,23 @@ lib_ignore =
24642476

24652477

24662478
[env:adafruit_matrixportal_esp32s3]
2479+
; ESP32-S3 processor, 8 MB flash, 2 MB of PSRAM, dedicated driver pins for HUB75
24672480
extends = esp32_4MB_V4_M_base
24682481
platform = ${esp32.platformV4_xp} ;; 6.5.0 = first platform release supporting matrixportal
24692482
platform_packages = ${esp32.platformV4_packages_xp} ;; arduino-esp32 2.0.14 needed - previous versions were missing files for matrixportal
24702483
board = adafruit_matrixportal_esp32s3
24712484

2485+
board_build.partitions = ${esp32.large_partitions}
2486+
board_build.f_flash = 80000000L
2487+
board_build.flash_mode = qio
2488+
24722489
build_unflags = ${env:esp32S3_8MB_M.build_unflags} ;; use the same as "normal" S3 buildenv
2490+
-D ARDUINO_USB_CDC_ON_BOOT=1 ;; fix warning: "ARDUINO_USB_CDC_ON_BOOT" redefined; comment out for Serial debug
24732491
build_flags = ${common.build_flags} ${esp32s3.build_flags} -Wno-misleading-indentation -Wno-format-truncation
24742492
${common_mm.build_flags_S}
24752493
-D WLED_RELEASE_NAME=matrixportal_esp32s3
2476-
-DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 ;; for Hardware-CDC USB mode
2494+
; Serial debug enabled -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 ;; for Hardware-CDC USB mode
2495+
-D ARDUINO_USB_CDC_ON_BOOT=0
24772496
-D WLED_DISABLE_ADALIGHT ;; disables serial protocols - recommended for Hardware-CDC USB (Serial RX will receive junk commands when RX pin is unconnected, unless its pulled down by resistor)
24782497
${common_mm.animartrix_build_flags}
24792498
${common_mm.build_disable_sync_interfaces}

tools/ESP32-Chip_info.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ void show_psram_info_part2(void)
543543

544544
void showRealSpeed() {
545545
//Serial.begin(115200);
546+
if (!Serial) return; // Avoid writing to unconnected USB-CDC
547+
546548
Serial.flush();
547549
Serial.println(F("\n"));
548550
for(int aa=0; aa<65; aa++) Serial.print("="); Serial.println();

usermods/audioreactive/audio_reactive.h

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
#pragma once
22

3+
/*
4+
@title MoonModules WLED - audioreactive usermod
5+
@file audio_reactive.h
6+
@repo https://github.com/MoonModules/WLED, submit changes to this file as PRs to MoonModules/WLED
7+
@Authors https://github.com/MoonModules/WLED/commits/mdev/
8+
@Copyright © 2024 Github MoonModules Commit Authors (contact [email protected] for details)
9+
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
10+
11+
This file is part of the MoonModules WLED fork also known as "WLED-MM".
12+
WLED-MM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
13+
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
14+
15+
WLED-MM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
16+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along with WLED-MM. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
322
#include "wled.h"
423

524
#ifdef ARDUINO_ARCH_ESP32
@@ -353,9 +372,6 @@ constexpr uint16_t samplesFFT_2 = 256; // meaningfull part of FFT resul
353372
// These are the input and output vectors. Input vectors receive computed results from FFT.
354373
static float vReal[samplesFFT] = {0.0f}; // FFT sample inputs / freq output - these are our raw result bins
355374
static float vImag[samplesFFT] = {0.0f}; // imaginary parts
356-
#ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
357-
static float windowWeighingFactors[samplesFFT] = {0.0f};
358-
#endif
359375

360376
#ifdef FFT_MAJORPEAK_HUMAN_EAR
361377
static float pinkFactors[samplesFFT] = {0.0f}; // "pink noise" correction factors
@@ -381,7 +397,14 @@ constexpr float binWidth = SAMPLE_RATE / (float)samplesFFT; // frequency range o
381397
#include <arduinoFFT.h>
382398

383399
#ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
384-
static ArduinoFFT<float> FFT = ArduinoFFT<float>( vReal, vImag, samplesFFT, SAMPLE_RATE, windowWeighingFactors);
400+
#if defined(FFT_LIB_REV) && FFT_LIB_REV > 0x19
401+
// arduinoFFT 2.x has a slightly different API
402+
static ArduinoFFT<float> FFT = ArduinoFFT<float>( vReal, vImag, samplesFFT, SAMPLE_RATE, true);
403+
#else
404+
// recommended version optimized by @softhack007 (API version 1.9)
405+
static float windowWeighingFactors[samplesFFT] = {0.0f}; // cache for FFT windowing factors
406+
static ArduinoFFT<float> FFT = ArduinoFFT<float>( vReal, vImag, samplesFFT, SAMPLE_RATE, windowWeighingFactors);
407+
#endif
385408
#else
386409
static arduinoFFT FFT = arduinoFFT(vReal, vImag, samplesFFT, SAMPLE_RATE);
387410
#endif
@@ -627,9 +650,14 @@ void FFTcode(void * parameter)
627650
#endif
628651

629652
#ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
653+
#if defined(FFT_LIB_REV) && FFT_LIB_REV > 0x19
654+
// arduinoFFT 2.x has a slightly different API
655+
FFT.majorPeak(&FFT_MajorPeak, &FFT_Magnitude);
656+
#else
630657
FFT.majorPeak(FFT_MajorPeak, FFT_Magnitude); // let the effects know which freq was most dominant
658+
#endif
631659
#else
632-
FFT.MajorPeak(&FFT_MajorPeak, &FFT_Magnitude); // let the effects know which freq was most dominant
660+
FFT.MajorPeak(&FFT_MajorPeak, &FFT_Magnitude);
633661
#endif
634662

635663
if (FFT_MajorPeak < (SAMPLE_RATE / samplesFFT)) {FFT_MajorPeak = 1.0f; FFT_Magnitude = 0;} // too low - use zero
@@ -921,7 +949,7 @@ static void postProcessFFTResults(bool noiseGateOpen, int numberOfChannels) // p
921949
if (post_gain < 1.0f) post_gain = ((post_gain -1.0f) * 0.8f) +1.0f;
922950
currentResult *= post_gain;
923951
}
924-
fftResult[i] = constrain((int)currentResult, 0, 255);
952+
fftResult[i] = max(min((int)(currentResult+0.5f), 255), 0); // +0.5 for proper rounding
925953
}
926954
}
927955
////////////////////
@@ -1571,7 +1599,7 @@ class AudioReactive : public Usermod {
15711599
transmitData.zeroCrossingCount = zeroCrossingCount;
15721600

15731601
for (int i = 0; i < NUM_GEQ_CHANNELS; i++) {
1574-
transmitData.fftResult[i] = (uint8_t)constrain(fftResult[i], 0, 254);
1602+
transmitData.fftResult[i] = fftResult[i];
15751603
}
15761604

15771605
transmitData.FFT_Magnitude = my_magnitude;

usermods/audioreactive/audio_source.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
#pragma once
2+
3+
/*
4+
@title MoonModules WLED - audioreactive usermod
5+
@file audio_source.h
6+
@repo https://github.com/MoonModules/WLED, submit changes to this file as PRs to MoonModules/WLED
7+
@Authors https://github.com/MoonModules/WLED/commits/mdev/
8+
@Copyright © 2024 Github MoonModules Commit Authors (contact [email protected] for details)
9+
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
10+
11+
This file is part of the MoonModules WLED fork also known as "WLED-MM".
12+
WLED-MM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
13+
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
14+
15+
WLED-MM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
16+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along with WLED-MM. If not, see <https://www.gnu.org/licenses/>.
19+
20+
*/
21+
22+
223
#ifdef ARDUINO_ARCH_ESP32
324
#include <Wire.h>
425
#include "wled.h"

usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
#pragma once
22

3+
/*
4+
@title MoonModules WLED - auto-playlist usermod
5+
@file usermod_v2_auto_playlist.h
6+
@repo https://github.com/MoonModules/WLED, submit changes to this file as PRs to MoonModules/WLED
7+
@Authors https://github.com/MoonModules/WLED/commits/mdev/
8+
@Copyright © 2024 Github MoonModules Commit Authors (contact [email protected] for details)
9+
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
10+
11+
This file is part of the MoonModules WLED fork also known as "WLED-MM".
12+
WLED-MM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
13+
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
14+
15+
WLED-MM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
16+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along with WLED-MM. If not, see <https://www.gnu.org/licenses/>.
19+
20+
*/
21+
22+
323
#ifdef WLED_DEBUG
424
#ifndef USERMOD_AUTO_PLAYLIST_DEBUG
525
#define USERMOD_AUTO_PLAYLIST_DEBUG
@@ -302,6 +322,8 @@ class AutoPlaylistUsermod : public Usermod {
302322

303323
if (bri == 0) return;
304324

325+
if(!functionality_enabled) return;
326+
305327
um_data_t *um_data;
306328

307329
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {

0 commit comments

Comments
 (0)