Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added wipe in and wipe out effects #4358

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6466,6 +6466,113 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
static const char _data_FX_MODE_MATRIPIX[] PROGMEM = "Matripix@!,Brightness;!,!;!;1v;ix=64,m12=2,si=1"; //,rev=1,mi=1,rY=1,mY=1 Circle, WeWillRockYou, reverseX


//////////////////////
// * WIPE OUT //
//////////////////////
uint16_t mode_wipe_out(void) {
if (SEGLEN == 1) return mode_static();

uint16_t duration = 1000 - (SEGMENT.speed * 4); // Adjust speed (1-255) to duration (1000ms to 20ms)
uint16_t stepDuration = duration / SEGLEN;
uint32_t currentTime = millis();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use strip.now instead of millis()


if (SEGENV.call == 0) {
SEGENV.aux0 = currentTime; // Start time
SEGENV.aux1 = 0; // Current LED
}

if (currentTime - SEGENV.aux0 > stepDuration) {
SEGENV.aux0 = currentTime;
if (SEGENV.aux1 < SEGLEN) {
SEGMENT.setPixelColor(SEGENV.aux1, BLACK);
SEGENV.aux1++;
} else {
// All LEDs are off, reset
SEGENV.aux1 = 0;
strip.setBrightness(0);
return 65535;
Copy link
Collaborator

@softhack007 softhack007 Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not cause a "forever black" - the effect will run again in 65535 millis = 65 seconds. Also manipulating strip properties in an effect (at segment level) is a very fragile thing and should be avoided.

}
}

return FRAMETIME;
}

// Add the effect details to the list
static const char _data_FX_MODE_WIPE_OUT[] PROGMEM =
"Wipe Out@!,Wipe Speed;1,!;!;1v;ix=64";


//////////////////////
// * WIPE IN //
//////////////////////
uint16_t mode_wipe_in(uint16_t segPerLoop) {
if (SEGLEN == 1) return mode_static();

uint16_t duration = 1000 - (SEGMENT.speed * 4); // Adjust speed (1-255) to duration (1000ms to 20ms)
uint16_t stepDuration = duration / SEGLEN;
uint32_t currentTime = millis();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment


if (SEGENV.call == 0) {
SEGENV.aux0 = currentTime; // Start time
SEGENV.aux1 = SEGLEN - 1; // Current LED
SEGMENT.fill(BLACK); // Start with all LEDs off
}

if (currentTime - SEGENV.aux0 > stepDuration) {
SEGENV.aux0 = currentTime;
if (SEGENV.aux1 >= 0 && SEGENV.aux1 < SEGLEN) {
uint32_t color = SEGCOLOR(0); // Use primary color
if (SEGCOLOR(1) != BLACK) {
color = color_blend(color, SEGCOLOR(1), SEGMENT.intensity); // Blend with secondary color if set
}
for (int i = 1; i < segPerLoop && SEGENV.aux1 >= 0 && SEGENV.aux1 < SEGLEN; i++) {
SEGMENT.setPixelColor(SEGENV.aux1, color);
SEGENV.aux1--;
}
} else {
// All LEDs are on, reset
SEGENV.aux1 = SEGLEN - 1;
return 65535;
}
}

return FRAMETIME;
}

uint16_t mode_wipe_in_normal(void) {
return mode_wipe_in(1);
}

// Add the effect details to the list
static const char _data_FX_MODE_WIPE_IN_NORMAL[] PROGMEM =
"Wipe In@!,Wipe Speed;1,!;!;1v;ix=64";


uint16_t mode_wipe_in_fast(void) {
return mode_wipe_in(2);
}

// Add the effect details to the list
static const char _data_FX_MODE_WIPE_IN_FAST[] PROGMEM =
"Wipe In fast@!,Wipe Speed;1,!;!;1v;ix=64";


uint16_t mode_wipe_in_faster(void) {
return mode_wipe_in(3);
}

// Add the effect details to the list
static const char _data_FX_MODE_WIPE_IN_FASTER[] PROGMEM =
"Wipe In faster@!,Wipe Speed;1,!;!;1v;ix=64";

uint16_t mode_wipe_in_very_fast(void) {
return mode_wipe_in(4);
}

// Add the effect details to the list
static const char _data_FX_MODE_WIPE_IN_VERY_FAST[] PROGMEM =
"Wipe In Very Fast@!,Wipe Speed;1,!;!;1v;ix=64";

//////////////////////
// * MIDNOISE //
//////////////////////
Expand Down Expand Up @@ -7819,6 +7926,11 @@ void WS2812FX::setupEffectData() {
addEffect(FX_MODE_PIXELWAVE, &mode_pixelwave, _data_FX_MODE_PIXELWAVE);
addEffect(FX_MODE_JUGGLES, &mode_juggles, _data_FX_MODE_JUGGLES);
addEffect(FX_MODE_MATRIPIX, &mode_matripix, _data_FX_MODE_MATRIPIX);
addEffect(FX_MODE_WIPE_OUT, &mode_wipe_out, _data_FX_MODE_WIPE_OUT);
addEffect(FX_MODE_WIPE_IN, &mode_wipe_in_normal, _data_FX_MODE_WIPE_IN_NORMAL);
addEffect(FX_MODE_WIPE_IN_FAST, &mode_wipe_in_fast, _data_FX_MODE_WIPE_IN_FAST);
addEffect(FX_MODE_WIPE_IN_FASTER, &mode_wipe_in_faster, _data_FX_MODE_WIPE_IN_FASTER);
addEffect(FX_MODE_WIPE_IN_VERY_FAST, &mode_wipe_in_faster, _data_FX_MODE_WIPE_IN_FASTER);
addEffect(FX_MODE_GRAVIMETER, &mode_gravimeter, _data_FX_MODE_GRAVIMETER);
addEffect(FX_MODE_PLASMOID, &mode_plasmoid, _data_FX_MODE_PLASMOID);
addEffect(FX_MODE_PUDDLES, &mode_puddles, _data_FX_MODE_PUDDLES);
Expand Down
7 changes: 6 additions & 1 deletion wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,13 @@
#define FX_MODE_WAVESINS 184
#define FX_MODE_ROCKTAVES 185
#define FX_MODE_2DAKEMI 186
#define FX_MODE_WIPE_OUT 187
#define FX_MODE_WIPE_IN 188
#define FX_MODE_WIPE_IN_FAST 189
#define FX_MODE_WIPE_IN_FASTER 190
#define FX_MODE_WIPE_IN_VERY_FAST 191

#define MODE_COUNT 187
#define MODE_COUNT 191

typedef enum mapping1D2D {
M12_Pixels = 0,
Expand Down
Loading