Skip to content

Commit 0a80cbc

Browse files
authored
Merge branch 'MoonModules:mdev' into Strip_Level_Color_Adjust
2 parents 45e8590 + 0f79e9b commit 0a80cbc

File tree

25 files changed

+789
-71
lines changed

25 files changed

+789
-71
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ body:
4848
attributes:
4949
label: What version/release of MM WLED?
5050
description: You can find this in by going to Config -> Security & Updates -> Scroll to Bottom. Copy and paste the entire line after "Server message"
51-
placeholder: "e.g. build 2401290, WLEDMM_0.14.1-b30.36_esp32_4MB_M.bin"
51+
placeholder: "e.g. build 2401290, WLEDMM_0.14.1-b30.37_esp32_4MB_M.bin"
5252
validations:
5353
required: true
5454
- type: dropdown

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
## [WLED upstream](https://github.com/Aircoookie/WLED/tree/0_14_1) changelog
22

3+
#### Build 2403290
4+
- WLED 0.14.3 release
5+
- Fix for transition 0 (#3854, #3832, #3720)
6+
7+
#### Build 2403170
8+
- WLED 0.14.2 release
9+
10+
#### Build 2403110
11+
- Beta WLED 0.14.2-b2
12+
- Fixing a potential array bounds violation in ESPDMX
13+
- LockedJsonResponse: Release early if possible (by @willmmiles)
14+
15+
#### Build 2402120
16+
- Beta WLED 0.14.2-b1
17+
- Possible fix for #3589 & partial fix for #3605
18+
- Prevent JSON buffer clear after failed lock attempt
19+
- Multiple analog button fix for #3549
20+
- UM Audioreactive: add two compiler options (#3732 by @wled-install)
21+
- Fix for #3693
22+
23+
#### Build 2401141
24+
- Official release of WLED 0.14.1
25+
- Fix for #3566, #3665, #3672
26+
- Sorting of palettes in custom palette editor (#3674 by @WoodyLetsCode)
27+
28+
#### Build 2401060
29+
- Version bump: 0.14.1-b3
30+
- Global JSON buffer guarding (#3648 by @willmmiles, resolves #3641, #3312, #3367, #3637, #3646, #3447)
31+
- Fix for #3632
32+
- Custom palette editor mobile UI enhancement (#3617 by @imeszaros)
33+
- changelog update
34+
335
#### Build 2312290
436
- Fix for #3622
537
- NB: fix for #3613 #3609 are not needed in MoonModules fork
@@ -61,6 +93,12 @@
6193
- Improved ESP8266 stability by reducing WebSocket response resends
6294
- Updated ESP8266 core to 3.1.2
6395

96+
#### Build 2306180
97+
98+
- Added client-side option for applying effect defaults from metadata
99+
- Improved ESP8266 stability by reducing WebSocket response resends
100+
- Updated ESP8266 core to 3.1.2
101+
64102
#### Build 2306141
65103
- Lissajous improvements
66104
- Scrolling Text improvements (leading 0)

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
Here are a few suggestions to make it easier for you to contribute!
44

5+
### Describe your PR
6+
7+
Please add a description of your proposed code changes. It does not need to be an exhaustive essay, however a PR with no description or just a few words might not get accepted, simply because very basic information is missing.
8+
9+
A good description helps us to review and understand your proposed changes. For example, you could say a few words about
10+
* what you try to achieve (new feature, fixing a bug, refactoring, security enhancements, etc.)
11+
* how your code works (short technical summary - focus on important aspects that might not be obvious when reading the code)
12+
* testing you performed, known limitations, open ends you possibly could not solve.
13+
* any areas where you like to get help from an experienced maintainer (yes WLEDMM has become big 😉)
14+
515
### Code style
616

717
When in doubt, it is easiest to replicate the code style you find in the files you want to edit :)
@@ -79,4 +89,5 @@ Good:
7989

8090
There is no set character limit for a comment within a line,
8191
though as a rule of thumb you should wrap your comment if it exceeds the width of your editor window.
92+
8293
Inline comments are OK if they describe that line only and are not exceedingly wide.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wled",
3-
"version": "0.14.1-b30.36",
3+
"version": "0.14.1-b30.37",
44
"description": "Tools for WLED project",
55
"main": "tools/cdata.js",
66
"directories": {

platformio.ini

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ arduino_core_2_7_4 = [email protected]
113113
arduino_core_3_0_0 = [email protected]
114114
arduino_core_3_2_0 = [email protected]
115115
arduino_core_4_1_0 = [email protected]
116-
arduino_core_3_1_2 = [email protected].0
116+
arduino_core_3_1_2 = [email protected].1
117117

118118
# Development platforms
119119
arduino_core_develop = https://github.com/platformio/platform-espressif8266#develop
@@ -123,8 +123,7 @@ arduino_core_git = https://github.com/platformio/platform-espressif8266#feature/
123123
platform_wled_default = ${common.arduino_core_3_1_2}
124124
# We use 2.7.4.7 for all, includes PWM flicker fix and Wstring optimization
125125
#platform_packages = tasmota/framework-arduinoespressif8266 @ 3.20704.7
126-
platform_packages = platformio/framework-arduinoespressif8266
127-
platformio/toolchain-xtensa @ ~2.100300.220621 #2.40802.200502
126+
platform_packages = platformio/toolchain-xtensa @ ~2.100300.220621 #2.40802.200502
128127
platformio/tool-esptool #@ ~1.413.0
129128
platformio/tool-esptoolpy #@ ~1.30000.0
130129

@@ -241,6 +240,7 @@ lib_deps =
241240
;;makuna/NeoPixelBus @ 2.7.5 ;; WLEDMM will be added in board specific sections
242241
;;https://github.com/Aircoookie/ESPAsyncWebServer.git @ ~2.0.7
243242
https://github.com/lost-hope/ESPAsyncWebServer.git#master ;; WLEDMM to display .log and .wled files in /edit
243+
;; https://github.com/Aircoookie/ESPAsyncWebServer.git @ ^2.2.1
244244
#For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line
245245
#TFT_eSPI
246246
#For compatible OLED display uncomment following
@@ -452,6 +452,11 @@ build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP8266 #-DWLED
452452
lib_deps = ${esp8266.lib_deps}
453453
monitor_filters = esp8266_exception_decoder
454454

455+
[env:nodemcuv2_160]
456+
extends = env:nodemcuv2
457+
board_build.f_cpu = 160000000L
458+
build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP8266_160 #-DWLED_DISABLE_2D
459+
455460
[env:esp8266_2m]
456461
board = esp_wroom_02
457462
platform = ${common.platform_wled_default}
@@ -461,6 +466,11 @@ build_unflags = ${common.build_unflags}
461466
build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP02
462467
lib_deps = ${esp8266.lib_deps}
463468

469+
[env:esp8266_2m_160]
470+
extends = env:esp8266_2m
471+
board_build.f_cpu = 160000000L
472+
build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP02_160
473+
464474
;WLEDMM: see below
465475
; [env:esp01_1m_full]
466476
; board = esp01_1m
@@ -471,6 +481,11 @@ lib_deps = ${esp8266.lib_deps}
471481
; build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP01 -D WLED_DISABLE_OTA
472482
; ; -D WLED_USE_UNREAL_MATH ;; may cause wrong sunset/sunrise times, but saves 7064 bytes FLASH and 975 bytes RAM
473483
; lib_deps = ${esp8266.lib_deps}
484+
; [env:esp01_1m_full_160]
485+
; extends = env:esp01_1m_full
486+
; board_build.f_cpu = 160000000L
487+
; build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP01_160 -D WLED_DISABLE_OTA
488+
; ; -D WLED_USE_UNREAL_MATH ;; may cause wrong sunset/sunrise times, but saves 7064 bytes FLASH and 975 bytes RAM
474489

475490
[env:esp07]
476491
board = esp07
@@ -963,6 +978,7 @@ build_flags_S =
963978
; -D WLED_DISABLE_2D ;; un-comment to build a firmware without 2D matrix support
964979
; -D WLED_USE_CIE_BRIGHTNESS_TABLE ;; experimental: use different color / brightness lookup table
965980
-D USERMOD_AUDIOREACTIVE
981+
-D USERMOD_AUTO_PLAYLIST
966982
-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
967983
; -D USERMOD_ARTIFX ;; WLEDMM usermod - temporarily moved into "_M", due to problems in "_S" when compiling with -O2
968984
-D WLEDMM_FASTPATH ;; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions.

usermods/audioreactive/audio_reactive.h

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <driver/i2s.h>
88
#include <driver/adc.h>
99

10+
#include <math.h>
1011
#endif
1112

1213
#if defined(ARDUINO_ARCH_ESP32) && (defined(WLED_DEBUG) || defined(SR_DEBUG))
@@ -141,6 +142,8 @@ static uint8_t fftResult[NUM_GEQ_CHANNELS]= {0}; // Our calculated freq. chann
141142
static float fftCalc[NUM_GEQ_CHANNELS] = {0.0f}; // Try and normalize fftBin values to a max of 4096, so that 4096/16 = 256. (also used by dynamics limiter)
142143
static float fftAvg[NUM_GEQ_CHANNELS] = {0.0f}; // Calculated frequency channel results, with smoothing (used if dynamics limiter is ON)
143144

145+
static uint16_t zeroCrossingCount = 0; // number of zero crossings in the current batch of 512 samples
146+
144147
// TODO: probably best not used by receive nodes
145148
static float agcSensitivity = 128; // AGC sensitivity estimation, based on agc gain (multAgc). calculated by getSensitivity(). range 0..255
146149

@@ -543,15 +546,27 @@ void FFTcode(void * parameter)
543546
}
544547
}
545548

546-
// find highest sample in the batch
549+
// set imaginary parts to 0
550+
memset(vImag, 0, sizeof(vImag));
551+
552+
// find highest sample in the batch, and count zero crossings
547553
float maxSample = 0.0f; // max sample from FFT batch
554+
uint_fast16_t newZeroCrossingCount = 0;
548555
for (int i=0; i < samplesFFT; i++) {
549-
// set imaginary parts to 0
550-
vImag[i] = 0;
551556
// pick our our current mic sample - we take the max value from all samples that go into FFT
552557
if ((vReal[i] <= (INT16_MAX - 1024)) && (vReal[i] >= (INT16_MIN + 1024))) //skip extreme values - normally these are artefacts
553558
if (fabsf((float)vReal[i]) > maxSample) maxSample = fabsf((float)vReal[i]);
559+
560+
// WLED-MM/TroyHacks: Calculate zero crossings
561+
//
562+
if (i < (samplesFFT-1)) {
563+
if (__builtin_signbit(vReal[i]) != __builtin_signbit(vReal[i+1])) // test sign bit: sign changed -> zero crossing
564+
newZeroCrossingCount++;
565+
}
554566
}
567+
newZeroCrossingCount = (newZeroCrossingCount*2)/3; // reduce value so it typicially stays below 256
568+
zeroCrossingCount = newZeroCrossingCount; // update only once, to avoid that effects pick up an intermediate value
569+
555570
// release highest sample to volume reactive effects early - not strictly necessary here - could also be done at the end of the function
556571
// early release allows the filters (getSample() and agcAvg()) to work with fresh values - we will have matching gain and noise gate values when we want to process the FFT results.
557572
micDataReal = maxSample;
@@ -770,8 +785,7 @@ void FFTcode(void * parameter)
770785
// run peak detection
771786
autoResetPeak();
772787
detectSamplePeak();
773-
774-
// we have new results - notify UDP sound send
788+
775789
haveNewFFTResult = true;
776790

777791
#if !defined(I2S_GRAB_ADC1_COMPLETELY)
@@ -1007,7 +1021,7 @@ class AudioReactive : public Usermod {
10071021
uint8_t samplePeak; // 01 Bytes offset 16 - 0 no peak; >=1 peak detected. In future, this will also provide peak Magnitude
10081022
uint8_t frameCounter; // 01 Bytes offset 17 - track duplicate/out of order packets
10091023
uint8_t fftResult[16]; // 16 Bytes offset 18
1010-
uint8_t gap2[2]; // gap added by compiler: 02 Bytes, offset 34
1024+
uint16_t zeroCrossingCount; // 02 Bytes, offset 34
10111025
float FFT_Magnitude; // 04 Bytes offset 36
10121026
float FFT_MajorPeak; // 04 Bytes offset 40
10131027
};
@@ -1547,6 +1561,7 @@ class AudioReactive : public Usermod {
15471561
transmitData.samplePeak = udpSamplePeak ? 1:0;
15481562
udpSamplePeak = false; // Reset udpSamplePeak after we've transmitted it
15491563
transmitData.frameCounter = frameCounter;
1564+
transmitData.zeroCrossingCount = zeroCrossingCount;
15501565

15511566
for (int i = 0; i < NUM_GEQ_CHANNELS; i++) {
15521567
transmitData.fftResult[i] = (uint8_t)constrain(fftResult[i], 0, 254);
@@ -1619,6 +1634,7 @@ class AudioReactive : public Usermod {
16191634
FFT_MajorPeak = constrain(receivedPacket->FFT_MajorPeak, 1.0f, 11025.0f); // restrict value to range expected by effects
16201635
soundPressure = volumeSmth; // substitute - V2 format does not (yet) include this value
16211636
agcSensitivity = 128.0f; // substitute - V2 format does not (yet) include this value
1637+
zeroCrossingCount = receivedPacket->zeroCrossingCount;
16221638

16231639
return true;
16241640
}
@@ -1720,7 +1736,7 @@ class AudioReactive : public Usermod {
17201736
// usermod exchangeable data
17211737
// we will assign all usermod exportable data here as pointers to original variables or arrays and allocate memory for pointers
17221738
um_data = new um_data_t;
1723-
um_data->u_size = 11;
1739+
um_data->u_size = 12;
17241740
um_data->u_type = new um_types_t[um_data->u_size];
17251741
um_data->u_data = new void*[um_data->u_size];
17261742
um_data->u_data[0] = &volumeSmth; //*used (New)
@@ -1746,6 +1762,8 @@ class AudioReactive : public Usermod {
17461762
um_data->u_type[9] = UMT_FLOAT;
17471763
um_data->u_data[10] = &agcSensitivity; // used (New)
17481764
um_data->u_type[10] = UMT_FLOAT;
1765+
um_data->u_data[11] = &zeroCrossingCount;
1766+
um_data->u_type[11] = UMT_UINT16;
17491767
#else
17501768
// ESP8266
17511769
// See https://github.com/MoonModules/WLED/pull/60#issuecomment-1666972133 for explanation of these alternative sources of data
@@ -1760,6 +1778,8 @@ class AudioReactive : public Usermod {
17601778
um_data->u_type[9] = UMT_FLOAT;
17611779
um_data->u_data[10] = &agcSensitivity; // used (New) - dummy value (128 => 50%)
17621780
um_data->u_type[10] = UMT_FLOAT;
1781+
um_data->u_data[11] = &zeroCrossingCount;
1782+
um_data->u_type[11] = UMT_UINT16;
17631783
#endif
17641784
}
17651785

@@ -1921,7 +1941,7 @@ class AudioReactive : public Usermod {
19211941
USER_PRINTF("| uint8_t samplePeak offset = %2d size = %2d\n", offsetof(audioSyncPacket, samplePeak), sizeof(data.samplePeak)); // offset 16 size 1
19221942
USER_PRINTF("| uint8_t frameCounter offset = %2d size = %2d\n", offsetof(audioSyncPacket, frameCounter), sizeof(data.frameCounter)); // offset 17 size 1
19231943
USER_PRINTF("| uint8_t fftResult[16] offset = %2d size = %2d\n", offsetof(audioSyncPacket, fftResult[0]), sizeof(data.fftResult)); // offset 18 size 16
1924-
USER_PRINTF("| uint8_t gap2[2] offset = %2d size = %2d\n", offsetof(audioSyncPacket, gap2[0]), sizeof(data.gap2)); // offset 34 size 2
1944+
USER_PRINTF("| uint16_t zeroCrossingCount offset = %2d size = %2d\n", offsetof(audioSyncPacket, zeroCrossingCount), sizeof(data.zeroCrossingCount)); // offset 34 size 2
19251945
USER_PRINTF("| float FFT_Magnitude offset = %2d size = %2d\n", offsetof(audioSyncPacket, FFT_Magnitude), sizeof(data.FFT_Magnitude));// offset 36 size 4
19261946
USER_PRINTF("| float FFT_MajorPeak offset = %2d size = %2d\n", offsetof(audioSyncPacket, FFT_MajorPeak), sizeof(data.FFT_MajorPeak));// offset 40 size 4
19271947
USER_PRINTLN(); USER_FLUSH();

usermods/audioreactive/audio_source.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,13 @@ class WM8978Source : public I2SSource {
667667
_wm8978I2cWrite( 1,0b000111110); // Power Management 1 - power off most things, but enable mic bias and I/O tie-off to help mitigate mic leakage.
668668
_wm8978I2cWrite( 2,0b110111111); // Power Management 2 - enable output and amp stages (amps may lift signal but it works better on the ADCs)
669669
_wm8978I2cWrite( 3,0b000001100); // Power Management 3 - enable L&R output mixers
670+
671+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
670672
_wm8978I2cWrite( 4,0b001010000); // Audio Interface - standard I2S, 24-bit
673+
#else
674+
_wm8978I2cWrite( 4,0b001001000); // Audio Interface - left-justified I2S, 24-bit
675+
#endif
676+
671677
_wm8978I2cWrite( 6,0b000000000); // Clock generation control - use external mclk
672678
_wm8978I2cWrite( 7,0b000000100); // Sets sample rate to ~24kHz (only used for internal calculations, not I2S)
673679
_wm8978I2cWrite(14,0b010001000); // 128x ADC oversampling - high pass filter disabled as it kills the bass response

0 commit comments

Comments
 (0)