-MoonModules/WLED is a fork from [Aircoookie/WLED](https://github.com/Aircoookie/WLED) which contains latest merge of v0.14 of WLED with [additional features](https://mm.kno.wled.ge/moonmodules/what-is-moonmodules/).
+MoonModules/WLED is a fork of [Aircoookie/WLED](https://github.com/Aircoookie/WLED) which contains latest merge of v0.14 of WLED with [additional features](https://mm.kno.wled.ge/moonmodules/what-is-moonmodules/).
This fork is created by members of the [Atuline/WLED](https://github.com/atuline/WLED) team to make development against v0.14 possible while still preserving [Atuline/WLED v0.13.x](https://github.com/atuline/WLED/tree/dev) as a stable and supported version. The Atuline/WLED fork is also called WLED SR (Sound Reactive).
diff --git a/tools/partitions-8MB_spiffs-tinyuf2.csv b/tools/partitions-8MB_spiffs-tinyuf2.csv
new file mode 100644
index 0000000000..27ed4c2d6a
--- /dev/null
+++ b/tools/partitions-8MB_spiffs-tinyuf2.csv
@@ -0,0 +1,10 @@
+# ESP-IDF Partition Table
+# Name, Type, SubType, Offset, Size, Flags
+# bootloader.bin,, 0x1000, 32K
+# partition table,, 0x8000, 4K
+nvs, data, nvs, 0x9000, 20K,
+otadata, data, ota, 0xe000, 8K,
+ota_0, app, ota_0, 0x10000, 2048K,
+ota_1, app, ota_1, 0x210000, 2048K,
+uf2, app, factory,0x410000, 256K,
+spiffs, data, spiffs, 0x450000, 3776K,
diff --git a/usermods/Analog_Clock/Analog_Clock.h b/usermods/Analog_Clock/Analog_Clock.h
index 596f0acb3b..9d82f7670c 100644
--- a/usermods/Analog_Clock/Analog_Clock.h
+++ b/usermods/Analog_Clock/Analog_Clock.h
@@ -102,9 +102,9 @@ class AnalogClockUsermod : public Usermod {
void secondsEffectSineFade(int16_t secondLed, Toki::Time const& time) {
uint32_t ms = time.ms % 1000;
- uint8_t b0 = (cos8(ms * 64 / 1000) - 128) * 2;
+ uint8_t b0 = (cos8_t(ms * 64 / 1000) - 128) * 2;
setPixelColor(secondLed, gamma32(scale32(secondColor, b0)));
- uint8_t b1 = (sin8(ms * 64 / 1000) - 128) * 2;
+ uint8_t b1 = (sin8_t(ms * 64 / 1000) - 128) * 2;
setPixelColor(inc(secondLed, 1, secondsSegment), gamma32(scale32(secondColor, b1)));
}
diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h
index 57a99eea26..6ba75edf42 100644
--- a/usermods/audioreactive/audio_reactive.h
+++ b/usermods/audioreactive/audio_reactive.h
@@ -1159,16 +1159,16 @@ class AudioReactive : public Usermod {
#endif
// new "V2" audiosync struct - 44 Bytes
struct __attribute__ ((packed)) audioSyncPacket { // WLEDMM "packed" ensures that there are no additional gaps
- char header[6]; // 06 Bytes offset 0
+ char header[6]; // 06 Bytes offset 0 - "00002" for protocol version 2 ( includes \0 for c-style string termination)
uint8_t pressure[2]; // 02 Bytes, offset 6 - sound pressure as fixed point (8bit integer, 8bit fraction)
float sampleRaw; // 04 Bytes offset 8 - either "sampleRaw" or "rawSampleAgc" depending on soundAgc setting
float sampleSmth; // 04 Bytes offset 12 - either "sampleAvg" or "sampleAgc" depending on soundAgc setting
uint8_t samplePeak; // 01 Bytes offset 16 - 0 no peak; >=1 peak detected. In future, this will also provide peak Magnitude
- uint8_t frameCounter; // 01 Bytes offset 17 - track duplicate/out of order packets
- uint8_t fftResult[16]; // 16 Bytes offset 18
- uint16_t zeroCrossingCount; // 02 Bytes, offset 34
- float FFT_Magnitude; // 04 Bytes offset 36
- float FFT_MajorPeak; // 04 Bytes offset 40
+ uint8_t frameCounter; // 01 Bytes offset 17 - rolling counter to track duplicate/out of order packets
+ uint8_t fftResult[16]; // 16 Bytes offset 18 - 16 GEQ channels, each channel has one byte (uint8_t)
+ uint16_t zeroCrossingCount; // 02 Bytes, offset 34 - number of zero crossings seen in 23ms
+ float FFT_Magnitude; // 04 Bytes offset 36 - largest FFT result from a single run (raw value, can go up to 4096)
+ float FFT_MajorPeak; // 04 Bytes offset 40 - frequency (Hz) of largest FFT result
};
// old "V1" audiosync struct - 83 Bytes payload, 88 bytes total - for backwards compatibility
diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h
index 147d4a52da..ecf662b7ee 100644
--- a/usermods/audioreactive/audio_source.h
+++ b/usermods/audioreactive/audio_source.h
@@ -693,25 +693,23 @@ class ES8311Source : public I2SSource {
_es8311I2cWrite(0x08, 0b11111111); // 22050hz calculated
_es8311I2cWrite(0x06, 0b11100011); // 22050hz calculated
- _es8311I2cWrite(0x16, 0b00100000); // ADC was 0b00000011 trying 0b00100100 now
+ _es8311I2cWrite(0x16, 0b00100100); // ADC was 0b00000011 trying 0b00100100 was good, trying ...111 (...111 is better?)
_es8311I2cWrite(0x0B, 0b00000000); // SYSTEM at default
_es8311I2cWrite(0x0C, 0b00100000); // SYSTEM was 0b00001111 trying 0b00100000
_es8311I2cWrite(0x10, 0b00010011); // SYSTEM was 0b00011111 trying 0b00010011
_es8311I2cWrite(0x11, 0b01111100); // SYSTEM was 0b01111111 trying 0b01111100
_es8311I2cWrite(0x00, 0b11000000); // *** RESET (again - seems important?)
- _es8311I2cWrite(0x01, 0b00111010); // CLOCK MANAGER was 0b00111111 trying 0b00111010 (again??)
+ _es8311I2cWrite(0x01, 0b00111010); // *** CLOCK MANAGER was 0b00111111 trying 0b00111010 (again?? seems important)
_es8311I2cWrite(0x14, 0b00010000); // *** SYSTEM was 0b00011010 trying 0b00010000 (or 0b01111010) (PGA gain)
- _es8311I2cWrite(0x12, 0b00000000); // SYSTEM - DAC, likely don't care
- _es8311I2cWrite(0x13, 0b00010000); // SYSTEM - output, likely don't cate
- _es8311I2cWrite(0x09, 0b00001000); // SDP IN (likely don't care) was 0b00001100 (16-bit) - changed to 0b00001000 (I2S 32-bit)
_es8311I2cWrite(0x0A, 0b00001000); // *** SDP OUT, was 0b00001100 trying 0b00001000 (I2S 32-bit)
_es8311I2cWrite(0x0E, 0b00000010); // *** SYSTEM was 0b00000010 trying 0b00011010 (seems best so far!) (or 0b00000010)
_es8311I2cWrite(0x0F, 0b01000100); // SYSTEM was 0b01000100
- _es8311I2cWrite(0x15, 0b00000000); // ADC soft ramp (disabled)
+ _es8311I2cWrite(0x15, 0b00010000); // ADC soft ramp (disabled 0000xxxx)
_es8311I2cWrite(0x1B, 0b00000101); // ADC soft-mute was 0b00000101
_es8311I2cWrite(0x1C, 0b01100101); // ADC EQ and offset freeze was 0b01100101 (bad at 0b00101100)
_es8311I2cWrite(0x17, 0b10111111); // ADC volume was 0b11111111 trying ADC volume 0b10111111 = 0db (maxgain) 0x16
- _es8311I2cWrite(0x44, 0b00000000); // 0b10000000 - loopback test. on: 0x88; off: 0x00; mic--" speak
+ _es8311I2cWrite(0x18, 0b10000001); // ADC ALC enabled and AutoMute disabled.
+ // _es8311I2cWrite(0x19, 0b11110100); // ADC ALC max and min
}
diff --git a/wled00/FX.cpp b/wled00/FX.cpp
index 9d5538179c..eef6160b6e 100644
--- a/wled00/FX.cpp
+++ b/wled00/FX.cpp
@@ -25,13 +25,23 @@
#define indexToVStrip(index, stripNr) ((index) | (int((stripNr)+1)<<16))
+#if 0 // for benchmarking - change to "#if 1" to use less accurate, but 30% faster FastLed sin8 and cos8 functions
+#define sin8_t sin8
+#define cos8_t cos8
+#define sin16_t sin16
+#define cos16_t cos16
+#define beatsin8_t beatsin8
+#define beatsin88_t beatsin88
+#define beatsin16_t beatsin16
+#endif
+
// WLEDMM replace abs8 by abs, as abs8 does not work for numbers >127
#define abs8(x) abs(x)
// effect utility functions
static uint8_t sin_gap(uint16_t in) {
if (in & 0x100) return 0;
- return sin8(in + 192); // correct phase shift of sine so that it starts and stops at 0
+ return sin8_t(in + 192); // correct phase shift of sine so that it starts and stops at 0
}
static uint16_t triwave16(uint16_t in) {
@@ -65,7 +75,7 @@ static int8_t tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec) {
return 0;
}
-// float version of map() // WLEDMM moved here so its available for all effects
+// float version of map() // WLEDMM moved here so it is available for all effects
static float mapf(float x, float in_min, float in_max, float out_min, float out_max){
if (in_max == in_min) return (out_min); // WLEDMM avoid div/0
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
@@ -364,7 +374,7 @@ uint16_t mode_breath(void) {
counter = (counter >> 2) + (counter >> 4); //0-16384 + 0-2048
if (counter < 16384) {
if (counter > 8192) counter = 8192 - (counter - 8192);
- var = sin16(counter) / 103; //close to parabolic in range 0-8192, max val. 23170
+ var = sin16_t(counter) / 103; //close to parabolic in range 0-8192, max val. 23170
}
uint8_t lum = 30 + var;
@@ -546,7 +556,7 @@ uint16_t running_base(bool saw, bool dual=false) {
}
a = 255 - a;
}
- uint8_t s = dual ? sin_gap(a) : sin8(a);
+ uint8_t s = dual ? sin_gap(a) : sin8_t(a);
uint32_t ca = color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), s);
if (dual) {
uint16_t b = (SEGLEN-1-i)*x_scale - counter;
@@ -785,7 +795,7 @@ static const char _data_FX_MODE_MULTI_STROBE[] PROGMEM = "Strobe Mega@!,!;!,!;!;
* Android loading circle
*/
uint16_t mode_android(void) {
-
+ if (SEGLEN <= 1) return mode_static(); // WLEDMM to prevent division by zero
for (int i = 0; i < SEGLEN; i++) {
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
}
@@ -1033,7 +1043,7 @@ static const char _data_FX_MODE_TRAFFIC_LIGHT[] PROGMEM = "Traffic Light@!,US st
*/
#define FLASH_COUNT 4
uint16_t mode_chase_flash(void) {
- if (SEGLEN == 1) return mode_static();
+ if (SEGLEN <= 1) return mode_static();
uint8_t flash_step = SEGENV.call % ((FLASH_COUNT * 2) + 1);
for (int i = 0; i < SEGLEN; i++) {
@@ -1279,6 +1289,9 @@ static uint16_t mode_fireworks_core(bool useaudio) {
if (valid1) { if (SEGMENT.is2D()) SEGMENT.setPixelColorXY(SEGENV.aux0%width, SEGENV.aux0/width, sv1); else SEGMENT.setPixelColor(SEGENV.aux0, sv1); } // restore spark color after blur
if (valid2) { if (SEGMENT.is2D()) SEGMENT.setPixelColorXY(SEGENV.aux1%width, SEGENV.aux1/width, sv2); else SEGMENT.setPixelColor(SEGENV.aux1, sv2); } // restore old spark color after blur
+ #if defined(ARDUINO_ARCH_ESP32)
+ random16_add_entropy(esp_random() & 0xFFFF); // improve randomness (esp32)
+ #endif
if (addPixels) // WLEDMM
for (int i=0; i(WLEDMM ${i.rel}.bin)
build ${i.vid}