Skip to content

Commit 86ed5a8

Browse files
committed
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.
1 parent 23d41e6 commit 86ed5a8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

wled00/FX.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5124,6 +5124,7 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa
51245124

51255125
const uint16_t cols = SEGMENT.virtualWidth();
51265126
const uint16_t rows = SEGMENT.virtualHeight();
5127+
uint8_t phases = SEGMENT.custom1;
51275128

51285129
if (SEGENV.call == 0) {
51295130
SEGMENT.setUpLeds();
@@ -5136,8 +5137,13 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa
51365137
int lastY1 = -1;
51375138
int lastY2 = -1;
51385139
for (int i = 0; i < cols; i++) {
5139-
int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4 );
5140-
int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4+128);
5140+
// int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4 );
5141+
///int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, i*4+128);
5142+
unsigned phase = cols * i / 8; // 256 is a complete phase; half a phase is dna is 128
5143+
phase = i * 4 * phases / cols; // cols ==0 cannot happen due to the for loop
5144+
int posY1 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, phase );
5145+
int posY2 = beatsin8_t(SEGMENT.speed/8, 0, rows-1, 0, phase+128);
5146+
51415147
if ((i==0) || ((abs(lastY1 - posY1) < 2) && (abs(lastY2 - posY2) < 2))) { // use original code when no holes
51425148
SEGMENT.setPixelColorXY(i, posY1, ColorFromPalette(SEGPALETTE, i*5+strip.now/17, beatsin8_t(5, 55, 255, 0, i*10), LINEARBLEND));
51435149
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
51525158

51535159
return FRAMETIME;
51545160
} // mode_2Ddna()
5155-
static const char _data_FX_MODE_2DDNA[] PROGMEM = "DNA@Scroll speed,Blur;;!;2";
5161+
static const char _data_FX_MODE_2DDNA[] PROGMEM = "DNA@Scroll speed,Blur,Phases;;!;2";
51565162

51575163

51585164
/////////////////////////

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// version code in format yymmddb (b = daily build)
11-
#define VERSION 2411290
11+
#define VERSION 2412030
1212

1313
// 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.
1414
#define _MoonModules_WLED_

0 commit comments

Comments
 (0)