From 283a7284b491bf3d11f663b25d86bb17f20549b3 Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:15:46 -0400 Subject: [PATCH 1/8] ES8311 support added for the ESP32-P4 EV board with mic. --- usermods/audioreactive/audio_reactive.h | 16 +++- usermods/audioreactive/audio_source.h | 100 ++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 1c46e33a..cbf21523 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -2022,7 +2022,16 @@ class AudioReactive : public Usermod { if ((sclPin >= 0) && (i2c_scl < 0)) i2c_scl = sclPin; if (i2c_sda >= 0) sdaPin = -1; // -1 = use global if (i2c_scl >= 0) sclPin = -1; - + case 9: + DEBUGSR_PRINTLN(F("AR: ES8311 Source (Mic)")); + audioSource = new ES8311Source(SAMPLE_RATE, BLOCK_SIZE, 1.0f); + //useInputFilter = 0; // to disable low-cut software filtering and restore previous behaviour + delay(100); + // WLEDMM align global pins + if ((sdaPin >= 0) && (i2c_sda < 0)) i2c_sda = sdaPin; // copy usermod prefs into globals (if globals not defined) + if ((sclPin >= 0) && (i2c_scl < 0)) i2c_scl = sclPin; + if (i2c_sda >= 0) sdaPin = -1; // -1 = use global + if (i2c_scl >= 0) sclPin = -1; if (audioSource) audioSource->initialize(i2swsPin, i2ssdPin, i2sckPin, mclkPin); break; @@ -2934,6 +2943,11 @@ class AudioReactive : public Usermod { #else oappend(SET_F("addOption(dd,'AC101 ☾',8);")); #endif + #if SR_DMTYPE==9 + oappend(SET_F("addOption(dd,'ES8311 ☾ (⎌)',9);")); + #else + oappend(SET_F("addOption(dd,'ES8311 ☾',9);")); + #endif #ifdef SR_SQUELCH oappend(SET_F("addInfo(ux+':config:squelch',1,'⎌ ")); oappendi(SR_SQUELCH); oappend("');"); // 0 is field type, 1 is actual field #endif diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h index 77111446..61f37c4f 100644 --- a/usermods/audioreactive/audio_source.h +++ b/usermods/audioreactive/audio_source.h @@ -640,6 +640,106 @@ class ES8388Source : public I2SSource { }; +/* ES8311 Sound Module + This is an I2S sound processing unit that requires initialization over + I2C before I2S data can be received. +*/ +class ES8311Source : public I2SSource { + private: + // I2C initialization functions for es8311 + void _es8311I2cBegin() { + Wire.setClock(100000); + } + + void _es8311I2cWrite(uint8_t reg, uint8_t val) { + #ifndef ES8311_ADDR + #define ES8311_ADDR 0x18 // default address is... foggy + #endif + Wire.beginTransmission(ES8311_ADDR); + Wire.write((uint8_t)reg); + Wire.write((uint8_t)val); + uint8_t i2cErr = Wire.endTransmission(); // i2cErr == 0 means OK + if (i2cErr != 0) { + DEBUGSR_PRINTF("AR: ES8311 I2C write failed with error=%d (addr=0x%X, reg 0x%X, val 0x%X).\n", i2cErr, ES8311_ADDR, reg, val); + } + } + + void _es8311InitAdc() { + // + // Currently only tested with the ESP32-P4 EV board with the onboard mic. + // Datasheet with I2C commands: https://dl.xkwy2018.com/downloads/RK3588/01_Official%20Release/04_Product%20Line%20Branch_NVR/02_Key%20Device%20Specifications/ES8311%20DS.pdf + // + _es8311I2cBegin(); + _es8311I2cWrite(0x00, 0b00011111); // RESET, default value + _es8311I2cWrite(0x45, 0b00000000); // GP, default value + _es8311I2cWrite(0x01, 0b00111010); // CLOCK MANAGER was 0b00110000 trying 0b00111010 (MCLK enable?) + + _es8311I2cWrite(0x02, 0b00000000); // 22050hz calculated + _es8311I2cWrite(0x05, 0b00000000); // 22050hz calculated + _es8311I2cWrite(0x03, 0b00010000); // 22050hz calculated + _es8311I2cWrite(0x04, 0b00010000); // 22050hz calculated + _es8311I2cWrite(0x07, 0b00000000); // 22050hz calculated + _es8311I2cWrite(0x08, 0b11111111); // 22050hz calculated + _es8311I2cWrite(0x06, 0b11100011); // 22050hz calculated + + _es8311I2cWrite(0x16, 0b00100000); // ADC was 0b00000011 trying 0b00100100 now + _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(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(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 + + } + + public: + ES8311Source(SRate_t sampleRate, int blockSize, float sampleScale = 1.0f, bool i2sMaster=true) : + I2SSource(sampleRate, blockSize, sampleScale, i2sMaster) { + _config.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT; + }; + + void initialize(int8_t i2swsPin, int8_t i2ssdPin, int8_t i2sckPin, int8_t mclkPin) { + DEBUGSR_PRINTLN("es8311Source:: initialize();"); + + // if ((i2sckPin < 0) || (mclkPin < 0)) { // WLEDMM not sure if this check is needed here, too + // ERRORSR_PRINTF("\nAR: invalid I2S es8311 pin: SCK=%d, MCLK=%d\n", i2sckPin, mclkPin); + // return; + // } + // BUG: "use global I2C pins" are valid as -1, and -1 is seen as invalid here. + // Workaround: Set I2C pins here, which will also set them globally. + // Bug also exists in ES7243. + if ((i2c_sda < 0) || (i2c_scl < 0)) { // check that global I2C pins are not "undefined" + ERRORSR_PRINTF("\nAR: invalid es8311 global I2C pins: SDA=%d, SCL=%d\n", i2c_sda, i2c_scl); + return; + } + if (!pinManager.joinWire(i2c_sda, i2c_scl)) { // WLEDMM specific: start I2C with globally defined pins + ERRORSR_PRINTF("\nAR: failed to join I2C bus with SDA=%d, SCL=%d\n", i2c_sda, i2c_scl); + return; + } + + // First route mclk, then configure ADC over I2C, then configure I2S + _es8311InitAdc(); + I2SSource::initialize(i2swsPin, i2ssdPin, i2sckPin, mclkPin); + } + + void deinitialize() { + I2SSource::deinitialize(); + } + +}; + class WM8978Source : public I2SSource { private: // I2C initialization functions for WM8978 From f2f621befcc493cad6e7058a3e6d8d8ee9b9f7df Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:48:11 +0100 Subject: [PATCH 2/8] minor FX improvements Fire2012: better randomness Julia: avoid darkening when using "blur" --- wled00/FX.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index f44db9da..c3a5c595 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2128,12 +2128,16 @@ uint16_t mode_fire_2012() { const uint8_t ignition = max(3,SEGLEN/10); // ignition area: 10% of segment length or minimum 3 pixels + #if defined(ARDUINO_ARCH_ESP32) + random16_add_entropy(esp_random() & 0xFFFF); // improves randonmess + #endif + // Step 1. Cool down every cell a little for (int i = 0; i < SEGLEN; i++) { uint8_t cool = (it != SEGENV.step) ? random8((((20 + SEGMENT.speed/3) * 16) / SEGLEN)+2) : random8(4); uint8_t minTemp = (ixcen = 0.; julias->ycen = 0.; julias->xymag = 1.0; From 0dbde5a257999e85925d08aa46fc3c01e2cbb809 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:06:47 +0100 Subject: [PATCH 3/8] audioreactive multi-comet (backported from WELD-SR 0.13.4) --- wled00/FX.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ wled00/FX.h | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index c3a5c595..0f7c7526 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1794,6 +1794,61 @@ uint16_t mode_multi_comet(void) { } static const char _data_FX_MODE_MULTI_COMET[] PROGMEM = "Multi Comet"; +// audioreactive multi-comet by @softhack007 +uint16_t mode_multi_comet_ar(void) { + constexpr unsigned MAX_COMETS = 16; // was 8 + uint32_t cycleTime = max(1, int((255 - SEGMENT.speed)/4)); + uint32_t it = strip.now / cycleTime; + if (SEGENV.step == it) return FRAMETIME; // too early + + if (!SEGENV.allocateData(sizeof(uint16_t) * MAX_COMETS)) return mode_static(); //allocation failed + uint16_t* comets = reinterpret_cast(SEGENV.data); + if (SEGENV.call == 0) { // do some initializations + SEGMENT.setUpLeds(); SEGMENT.fill(BLACK); + for(uint8_t i=0; i < MAX_COMETS; i++) comets[i] = SEGLEN; // WLEDMM make sure comments are started individually + SEGENV.aux0 = 0; + } + SEGMENT.fade_out(254 - SEGMENT.intensity/2); + + um_data_t *um_data; + if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) um_data = simulateSound(SEGMENT.soundSim); + float volumeSmth = *(float*) um_data->u_data[0]; + int16_t volumeRaw = *(int16_t*) um_data->u_data[1]; + uint8_t samplePeak = *(uint8_t*) um_data->u_data[3]; + + uint16_t armed = SEGENV.aux0; // allows to delay comet launch + + #if defined(ARDUINO_ARCH_ESP32) + random16_add_entropy(esp_random() & 0xFFFF); // improve randomness (esp32) + #endif + bool shotOne = false; // avoids starting several coments at the same time (invisible due to overlap) + for(unsigned i=0; i < MAX_COMETS; i++) { + if(comets[i] < SEGLEN) { + // draw comet + uint16_t index = comets[i]; + if (SEGCOLOR(2) != 0) + SEGMENT.setPixelColor(index, i % 2 ? SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0) : SEGCOLOR(2)); + else + SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0)); + comets[i]++; // move + } else { + // randomly launch a new comet + if (random16(min(uint16_t(256), SEGLEN)) < 3) armed++; // new comet loaded and ready + if (armed > 2) armed = 2; // max three armed at once (avoid overlap) + // delay comet "launch" during silence, and wait until next beat + if ( (armed > 0) && (shotOne == false) + && (volumeSmth > 1.0f) && ((samplePeak > 0) || (volumeRaw > 104)) ) { // delayed lauch - wait until peak, don't launch in silence + comets[i] = 0; // start a new comet! + armed--; // un-arm one + shotOne = true; + } + } + } + SEGENV.aux0 = armed; + SEGENV.step = it; + return FRAMETIME; +} +static const char _data_FX_MODE_MULTI_COMET_AR[] PROGMEM = "Multi Comet audio ☾@Speed,Tail Length;!,!;!;1v;sx=160,ix=32,m12=7,si=1"; // Pinwheel, WeWillRockU /* * Running random pixels ("Stream 2") @@ -9017,6 +9072,7 @@ void WS2812FX::setupEffectData() { addEffect(FX_MODE_LIGHTNING, &mode_lightning, _data_FX_MODE_LIGHTNING); addEffect(FX_MODE_ICU, &mode_icu, _data_FX_MODE_ICU); addEffect(FX_MODE_MULTI_COMET, &mode_multi_comet, _data_FX_MODE_MULTI_COMET); + addEffect(FX_MODE_MULTI_COMET_AR, &mode_multi_comet_ar, _data_FX_MODE_MULTI_COMET_AR); addEffect(FX_MODE_DUAL_LARSON_SCANNER, &mode_dual_larson_scanner, _data_FX_MODE_DUAL_LARSON_SCANNER); addEffect(FX_MODE_RANDOM_CHASE, &mode_random_chase, _data_FX_MODE_RANDOM_CHASE); addEffect(FX_MODE_OSCILLATE, &mode_oscillate, _data_FX_MODE_OSCILLATE); diff --git a/wled00/FX.h b/wled00/FX.h index beba0517..670c321a 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -330,7 +330,7 @@ bool strip_uses_global_leds(void) __attribute__((pure)); // WLEDMM implemented // Experimental Audioresponsive modes from WLED-SR // #define FX_MODE_3DSphereMove 189 // experimental WLED-SR "cube" mode #define FX_MODE_POPCORN_AR 190 // WLED-SR audioreactive popcorn -// #define FX_MODE_MULTI_COMET_AR 191 // WLED-SR audioreactive multi-comet +#define FX_MODE_MULTI_COMET_AR 191 // WLED-SR audioreactive multi-comet #define FX_MODE_STARBURST_AR 192 // WLED-SR audioreactive fireworks starburst // #define FX_MODE_PALETTE_AR 193 // WLED-SR audioreactive palette #define FX_MODE_FIREWORKS_AR 194 // WLED-SR audioreactive fireworks From 9922d2aa8d01373a64b96a8685a0be14d264c4f2 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:44:46 +0100 Subject: [PATCH 4/8] bugfix: don't render segments that are "off" --- wled00/FX_fcn.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 0f750b0f..a450dca7 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1913,6 +1913,7 @@ void WS2812FX::service() { seg.resetIfRequired(); if (!seg.isActive()) continue; + if (!seg.on && !seg.transitional) continue; // WLEDMM skip disabled segments, unless a crossfade is ongoing // last condition ensures all solid segments are updated at the same time if(nowUp >= seg.next_time || _triggered || (doShow && seg.mode == FX_MODE_STATIC)) // WLEDMM ">=" instead of ">" From 23d41e66c94e5f111e6dec44e3ed731171c964d2 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:04:21 +0100 Subject: [PATCH 5/8] bugfix #2 for switched-off segments segments that are "off" were still rendered during transitions. --- wled00/FX.h | 2 ++ wled00/FX_fcn.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/wled00/FX.h b/wled00/FX.h index 670c321a..c35c54fb 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -380,6 +380,7 @@ typedef struct Segment { }; uint8_t grouping, spacing; uint8_t opacity; + uint8_t lastBri; // WLEDMM optimization for black-to-black "transitions" bool needsBlank; // WLEDMM indicates that Segment needs to be blanked (due to change of mirror / reverse / transpose / spacing) uint32_t colors[NUM_COLORS]; uint8_t cct; //0==1900K, 255==10091K @@ -490,6 +491,7 @@ typedef struct Segment { grouping(1), spacing(0), opacity(255), + lastBri(255), needsBlank(false), colors{DEFAULT_COLOR,BLACK,BLACK}, cct(127), diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index a450dca7..b2d7162f 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1935,6 +1935,7 @@ void WS2812FX::service() { now = millis() + timebase; #endif seg.startFrame(); // WLEDMM + if (!_triggered && (seg.currentBri(seg.opacity) == 0) && (seg.lastBri == 0)) continue; // WLEDMM skip totally black segments // effect blending (execute previous effect) // actual code may be a bit more involved as effects have runtime data including allocated memory //if (seg.transitional && seg._modeP) (*_mode[seg._modeP])(progress()); @@ -1944,6 +1945,7 @@ void WS2812FX::service() { if (seg.mode != FX_MODE_HALLOWEEN_EYES) seg.call++; if (seg.transitional && frameDelay > FRAMETIME) frameDelay = FRAMETIME; // force faster updates during transition + seg.lastBri = seg.currentBri(seg.on ? seg.opacity:0); // WLEDMM remember for next time seg.handleTransition(); } From 86ed5a82e3d03df1e2a40af3110cb6935428c880 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:31:52 +0100 Subject: [PATCH 6/8] DNA effect: additional parameter "phases" (thanks @ewoudwijma ) controls the number of phases shown by the effect breaking - the old code was using a fixed width per wave, while the new one always fits the same number waves into the panel width. --- wled00/FX.cpp | 12 +++++++++--- wled00/wled.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 0f7c7526..f255fa5a 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5124,6 +5124,7 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa const uint16_t cols = SEGMENT.virtualWidth(); const uint16_t rows = SEGMENT.virtualHeight(); + uint8_t phases = SEGMENT.custom1; if (SEGENV.call == 0) { SEGMENT.setUpLeds(); @@ -5136,8 +5137,13 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa int lastY1 = -1; int lastY2 = -1; for (int i = 0; i < cols; i++) { - int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4 ); - int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4+128); + // int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4 ); + ///int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4+128); + unsigned phase = cols * i / 8; // 256 is a complete phase; half a phase is dna is 128 + phase = i * 4 * phases / cols; // cols ==0 cannot happen due to the for loop + int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, phase ); + int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, phase+128); + if ((i==0) || ((abs(lastY1 - posY1) < 2) && (abs(lastY2 - posY2) < 2))) { // use original code when no holes SEGMENT.setPixelColorXY(i, posY1, ColorFromPalette(SEGPALETTE, i*5+strip.now/17, beatsin8_t(5, 55, 255, 0, i*10), LINEARBLEND)); SEGMENT.setPixelColorXY(i, posY2, ColorFromPalette(SEGPALETTE, i*5+128+strip.now/17, beatsin8_t(5, 55, 255, 0, i*10+128), LINEARBLEND)); @@ -5152,7 +5158,7 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa return FRAMETIME; } // mode_2Ddna() -static const char _data_FX_MODE_2DDNA[] PROGMEM = "DNA@Scroll speed,Blur;;!;2"; +static const char _data_FX_MODE_2DDNA[] PROGMEM = "DNA@Scroll speed,Blur,Phases;;!;2"; ///////////////////////// diff --git a/wled00/wled.h b/wled00/wled.h index 28110365..7af6b43c 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2411290 +#define VERSION 2412030 // WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED. #define _MoonModules_WLED_ From 9ea2303ecbfc8a0bd5ebe3c8ada6b6c903756846 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 20:00:26 +0100 Subject: [PATCH 7/8] DNA effect optimization (phases) * non-breaking - reproduces the old behavior at phases = 127 * minor math optimizations * phase boost for large values (good for small panels) --- wled00/FX.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index f255fa5a..53d99886 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5119,12 +5119,13 @@ static const char _data_FX_MODE_2DCOLOREDBURSTS[] PROGMEM = "Colored Bursts@Spee ///////////////////// // 2D DNA // ///////////////////// -uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pastebin.com/pCkkkzcs. Updated by Preyy. WLED conversion by Andrew Tuline. +uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pastebin.com/pCkkkzcs. Updated by Preyy. WLED conversion by Andrew Tuline. Phases added by @ewoudwijma if (!strip.isMatrix) return mode_static(); // not a 2D set-up const uint16_t cols = SEGMENT.virtualWidth(); const uint16_t rows = SEGMENT.virtualHeight(); - uint8_t phases = SEGMENT.custom1; + unsigned phases = SEGMENT.custom1; + if (phases > 179) phases = 179 + 2.5f * (phases - 179); // boost for values > 179 if (SEGENV.call == 0) { SEGMENT.setUpLeds(); @@ -5137,10 +5138,9 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa int lastY1 = -1; int lastY2 = -1; for (int i = 0; i < cols; i++) { - // int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4 ); - ///int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4+128); - unsigned phase = cols * i / 8; // 256 is a complete phase; half a phase is dna is 128 - phase = i * 4 * phases / cols; // cols ==0 cannot happen due to the for loop + // 256 is a complete phase; half a phase of dna is 128 + // unsigned phase = i * 4 * phases / cols; // original formula; cols ==0 cannot happen due to the for loop + unsigned phase = i * 4 * phases / 128; // WLEDMM this reproduces the previous behaviour at phases=127 int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, phase ); int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, phase+128); From f4ac04b9f981659fc539e522d49b03e80b4554c4 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:48:35 +0100 Subject: [PATCH 8/8] Update platformio.ini - fix for duplicate WLED_RELEASE_NAMEs esp32S3_4MB_S and esp32s3_8MB_M were used by two different buildenvs. --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index e49c32da..b1ce10e2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -2164,7 +2164,7 @@ board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, ;; board_build.partitions = tools/WLED_ESP32_4MB_512KB_FS.csv ;; 1.7MB firmware, 500KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions) build_flags = ${common.build_flags} ${esp32s3.build_flags} -Wno-misleading-indentation -Wno-format-truncation ${common_mm.build_flags_S} - -D WLED_RELEASE_NAME=esp32S3_4MB_S + -D WLED_RELEASE_NAME=esp32S3_4MB_PSRAM_S -DBOARD_HAS_PSRAM ;; -D WLED_USE_PSRAM -D WLED_USE_PSRAM_JSON -DALL_JSON_TO_PSRAM ; WLEDMM --> force all JSON stuff into PSRAM; gives more free heap -DCONFIG_MBEDTLS_DYNAMIC_BUFFER=1 ;; optional - allows some buffers to use PSRAM @@ -2202,7 +2202,7 @@ board = lolin_s3_mini ;; -S3 mini: 4MB flash 2MB PSRAM board_build.partitions = ${esp32.default_partitions} build_flags = ${common.build_flags} ${esp32s3.build_flags} -Wno-misleading-indentation -Wno-format-truncation ${common_mm.build_flags_S} ${common_mm.build_flags_M} - -D WLED_RELEASE_NAME=esp32S3_4MB_M + -D WLED_RELEASE_NAME=esp32S3_4MB_PSRAM_M -DBOARD_HAS_PSRAM ;; -D WLED_USE_PSRAM -D WLED_USE_PSRAM_JSON -DALL_JSON_TO_PSRAM ; WLEDMM --> force all JSON stuff into PSRAM; gives more free heap -DCONFIG_MBEDTLS_DYNAMIC_BUFFER=1 ;; optional - allows some buffers to use PSRAM