Skip to content

Commit 830e5da

Browse files
DedeHainetmindz
authored andcommitted
Adding "Complete" mode to Dissolve FX: always fades completely (#5016)
This allows for much slower speed setting to not turn into "twinkle" effect
1 parent b0570db commit 830e5da

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

wled00/FX.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ uint16_t dissolve(uint32_t color) {
713713
if (SEGENV.aux0) { //dissolve to primary/palette
714714
if (pixels[i] == SEGCOLOR(1)) {
715715
pixels[i] = color == SEGCOLOR(0) ? SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0) : color;
716-
break; //only spawn 1 new pixel per frame per 50 LEDs
716+
break; //only spawn 1 new pixel per frame
717717
}
718718
} else { //dissolve to secondary
719719
if (pixels[i] != SEGCOLOR(1)) {
@@ -724,14 +724,27 @@ uint16_t dissolve(uint32_t color) {
724724
}
725725
}
726726
}
727-
// fix for #4401
728-
for (unsigned i = 0; i < SEGLEN; i++) SEGMENT.setPixelColor(i, pixels[i]);
727+
unsigned incompletePixels = 0;
728+
for (unsigned i = 0; i < SEGLEN; i++) {
729+
SEGMENT.setPixelColor(i, pixels[i]); // fix for #4401
730+
if (SEGMENT.check2) {
731+
if (SEGENV.aux0) {
732+
if (pixels[i] == SEGCOLOR(1)) incompletePixels++;
733+
} else {
734+
if (pixels[i] != SEGCOLOR(1)) incompletePixels++;
735+
}
736+
}
737+
}
729738

730739
if (SEGENV.step > (255 - SEGMENT.speed) + 15U) {
731740
SEGENV.aux0 = !SEGENV.aux0;
732741
SEGENV.step = 0;
733742
} else {
734-
SEGENV.step++;
743+
if (SEGMENT.check2) {
744+
if (incompletePixels == 0)
745+
SEGENV.step++; // only advance step once all pixels have changed
746+
} else
747+
SEGENV.step++;
735748
}
736749

737750
return FRAMETIME;
@@ -744,7 +757,7 @@ uint16_t dissolve(uint32_t color) {
744757
uint16_t mode_dissolve(void) {
745758
return dissolve(SEGMENT.check1 ? SEGMENT.color_wheel(hw_random8()) : SEGCOLOR(0));
746759
}
747-
static const char _data_FX_MODE_DISSOLVE[] PROGMEM = "Dissolve@Repeat speed,Dissolve speed,,,,Random;!,!;!";
760+
static const char _data_FX_MODE_DISSOLVE[] PROGMEM = "Dissolve@Repeat speed,Dissolve speed,,,,Random,Complete;!,!;!";
748761

749762

750763
/*

0 commit comments

Comments
 (0)