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] 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_