Skip to content

Commit ace46d8

Browse files
committed
Multiupdate
- LED output re-arrange by drag & drop - faster 1D arc expansion (by @Brandon502 wled#4994) - FX: consolidate Blink/Strobe & add color time/space swap (wled#4978) - FX: consolidate Running/Saw - replace color_wheel() by color_from_palette() - remove "rainbow" option from settings
1 parent d4afe5b commit ace46d8

File tree

8 files changed

+154
-203
lines changed

8 files changed

+154
-203
lines changed

wled00/FX.cpp

Lines changed: 17 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ static const char _data_FX_MODE_STATIC[] PROGMEM = "Solid";
114114
* Alternate between color1 and color2
115115
* if(strobe == true) then create a strobe effect
116116
*/
117-
uint16_t blink(CRGBA color1, CRGBA color2, bool strobe, bool do_palette) {
117+
uint16_t mode_blink() {
118+
bool rainbow = SEGMENT.check1;
119+
bool strobe = SEGMENT.check2;
120+
bool swapTimeSpace = SEGMENT.check3;
121+
118122
uint32_t cycleTime = (255 - SEGMENT.speed)*20;
119123
uint32_t onTime = FRAMETIME;
120124
if (!strobe) onTime += ((cycleTime * SEGMENT.intensity) >> 8);
@@ -130,52 +134,17 @@ uint16_t blink(CRGBA color1, CRGBA color2, bool strobe, bool do_palette) {
130134

131135
SEGENV.step = it; //save previous iteration
132136

133-
CRGBA color = on ? color1 : color2;
134-
if (color == color1 && do_palette)
135-
{
137+
if (on) {
136138
for (unsigned i = 0; i < SEGLEN; i++) {
137-
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_FIXED, 0));
139+
uint8_t index = (swapTimeSpace ? ((it * 256 * FRAMETIME) / cycleTime) : (i * 256) / SEGLEN);
140+
CRGBA color = SEGMENT.color_from_palette(index, false, PALETTE_MOVING, rainbow*255);
141+
SEGMENT.setPixelColor(i, color);
138142
}
139-
} else SEGMENT.fill(color);
143+
} else SEGMENT.fill(SEGCOLOR(1));
140144

141145
return FRAMETIME;
142146
}
143-
144-
145-
/*
146-
* Normal blinking. Intensity sets duty cycle.
147-
*/
148-
uint16_t mode_blink(void) {
149-
return blink(SEGCOLOR(0), SEGCOLOR(1), false, true);
150-
}
151-
static const char _data_FX_MODE_BLINK[] PROGMEM = "Blink@!,Duty cycle;!,!;!;01";
152-
153-
154-
/*
155-
* Classic Blink effect. Cycling through the rainbow.
156-
*/
157-
uint16_t mode_blink_rainbow(void) {
158-
return blink(SEGMENT.color_wheel(SEGENV.call & 0xFF), SEGCOLOR(1), false, false);
159-
}
160-
static const char _data_FX_MODE_BLINK_RAINBOW[] PROGMEM = "Blink Rainbow@Frequency,Blink duration;!,!;!;01";
161-
162-
163-
/*
164-
* Classic Strobe effect.
165-
*/
166-
uint16_t mode_strobe(void) {
167-
return blink(SEGCOLOR(0), SEGCOLOR(1), true, true);
168-
}
169-
static const char _data_FX_MODE_STROBE[] PROGMEM = "Strobe@!;!,!;!;01";
170-
171-
172-
/*
173-
* Classic Strobe effect. Cycling through the rainbow.
174-
*/
175-
uint16_t mode_strobe_rainbow(void) {
176-
return blink(SEGMENT.color_wheel(SEGENV.call & 0xFF), SEGCOLOR(1), true, false);
177-
}
178-
static const char _data_FX_MODE_STROBE_RAINBOW[] PROGMEM = "Strobe Rainbow@!;,!;!;01";
147+
static const char _data_FX_MODE_BLINK[] PROGMEM = "Blink@!,Duty,,,,Rainbow,Strobe,Time/space;!,!;!;01";
179148

180149

181150
/*
@@ -488,14 +457,15 @@ static const char _data_FX_MODE_THEATER_CHASE[] PROGMEM = "Theater@!,Gap size,,,
488457

489458

490459
/*
491-
* Running lights effect with smooth sine transition base.
460+
* Running lights effect with smooth sine/sawtooth transition base.
492461
* Idea: Make the gap width controllable with a third slider in the future
493462
*/
494-
static uint16_t running_base(bool saw) {
463+
uint16_t mode_running_lights(void) {
495464
const bool dual = SEGMENT.check3;
496465
unsigned x_scale = SEGMENT.intensity >> 2;
497466
uint32_t counter = (strip.now * SEGMENT.speed) >> 9;
498467
const bool moving = SEGMENT.check1;
468+
const bool saw = SEGMENT.check2;
499469

500470
for (unsigned i = 0; i < SEGLEN; i++) {
501471
unsigned a = i*x_scale - counter;
@@ -523,23 +493,7 @@ static uint16_t running_base(bool saw) {
523493

524494
return FRAMETIME;
525495
}
526-
527-
/*
528-
* Running lights effect with smooth sine transition.
529-
*/
530-
uint16_t mode_running_lights(void) {
531-
return running_base(false);
532-
}
533-
static const char _data_FX_MODE_RUNNING_LIGHTS[] PROGMEM = "Running@!,Wave width,,,,Animate palette,,Dual;!,!,!;!;;o1=0";
534-
535-
536-
/*
537-
* Running lights effect with sawtooth transition.
538-
*/
539-
uint16_t mode_saw(void) {
540-
return running_base(true);
541-
}
542-
static const char _data_FX_MODE_SAW[] PROGMEM = "Saw@!,Width,,,,Animate palette;!,!;!;;o1=0,o3=0";
496+
static const char _data_FX_MODE_RUNNING_LIGHTS[] PROGMEM = "Running@!,Width,,,,Animate palette,Saw,Dual;!,!,!;!;;o1=0,o3=0";
543497

544498

545499
/*
@@ -1979,7 +1933,7 @@ uint16_t mode_palette() {
19791933
// Finally, shift the palette a bit.
19801934
const int paletteOffset = (!inputAnimateShift) ? (inputShift-128) : (((strip.now * ((inputShift >> 3) +1)) & 0xFFFF) >> 8);
19811935
colorIndex += paletteOffset;
1982-
const CRGBA color = SEGMENT.color_wheel((uint8_t)colorIndex);
1936+
const CRGBA color = SEGMENT.color_wheel(colorIndex);
19831937
if (isMatrix) {
19841938
SEGMENT.setPixelColorXY(x, y, color);
19851939
} else {
@@ -2424,26 +2378,7 @@ uint16_t mode_ripple(void) {
24242378
SEGMENT.fill(SEGMENT.check1 ? SEGMENT.color_wheel(SEGENV.aux0).nblend(BLACK,uint8_t(192)) : SEGCOLOR(1));
24252379
return ripple_base();
24262380
}
2427-
static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,# of Waves,,,,Palette BG;,!;!;12;o1=0";
2428-
2429-
2430-
//uint16_t mode_ripple_rainbow(void) {
2431-
// if (SEGLEN <= 1) return mode_static();
2432-
// if (SEGENV.call ==0) {
2433-
// SEGENV.aux0 = hw_random8();
2434-
// SEGENV.aux1 = hw_random8();
2435-
// }
2436-
// if (SEGENV.aux0 == SEGENV.aux1) {
2437-
// SEGENV.aux1 = hw_random8();
2438-
// } else if (SEGENV.aux1 > SEGENV.aux0) {
2439-
// SEGENV.aux0++;
2440-
// } else {
2441-
// SEGENV.aux0--;
2442-
// }
2443-
// SEGMENT.fill(color_blend(SEGMENT.color_wheel(SEGENV.aux0),BLACK,uint8_t(235)));
2444-
// return ripple_base();
2445-
//}
2446-
//static const char _data_FX_MODE_RIPPLE_RAINBOW[] PROGMEM = "Ripple Rainbow@!,Waves;;!;12";
2381+
static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Waves,,,,Palette BG;,!;!;12;o1=0";
24472382

24482383

24492384
// TwinkleFOX by Mark Kriegsman: https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
@@ -3002,7 +2937,6 @@ static uint16_t rolling_balls() {
30022937

30032938
CRGBA color = SEGCOLOR(0);
30042939
if (SEGMENT.palette) {
3005-
//color = SEGMENT.color_wheel(i*(256/MAX(numBalls, 8)));
30062940
color = SEGMENT.color_from_palette(i*255/numBalls, false, PALETTE_FIXED, 0);
30072941
} else if (hasCol2) {
30082942
color = SEGCOLOR(i % NUM_COLORS);
@@ -6503,16 +6437,12 @@ void WS2812FX::setupEffectData() {
65036437
addEffect(FX_MODE_FADE, &mode_fade, _data_FX_MODE_FADE);
65046438
addEffect(FX_MODE_THEATER_CHASE, &mode_theater_chase, _data_FX_MODE_THEATER_CHASE);
65056439
addEffect(FX_MODE_RUNNING_LIGHTS, &mode_running_lights, _data_FX_MODE_RUNNING_LIGHTS);
6506-
addEffect(FX_MODE_SAW, &mode_saw, _data_FX_MODE_SAW);
65076440
addEffect(FX_MODE_TWINKLE, &mode_twinkle, _data_FX_MODE_TWINKLE);
65086441
addEffect(FX_MODE_DISSOLVE, &mode_dissolve, _data_FX_MODE_DISSOLVE);
65096442
addEffect(FX_MODE_SPARKLE, &mode_sparkle, _data_FX_MODE_SPARKLE);
65106443
addEffect(FX_MODE_FLASH_SPARKLE, &mode_flash_sparkle, _data_FX_MODE_FLASH_SPARKLE);
65116444
addEffect(FX_MODE_HYPER_SPARKLE, &mode_hyper_sparkle, _data_FX_MODE_HYPER_SPARKLE);
6512-
addEffect(FX_MODE_STROBE, &mode_strobe, _data_FX_MODE_STROBE);
6513-
addEffect(FX_MODE_STROBE_RAINBOW, &mode_strobe_rainbow, _data_FX_MODE_STROBE_RAINBOW);
65146445
addEffect(FX_MODE_MULTI_STROBE, &mode_multi_strobe, _data_FX_MODE_MULTI_STROBE);
6515-
addEffect(FX_MODE_BLINK_RAINBOW, &mode_blink_rainbow, _data_FX_MODE_BLINK_RAINBOW);
65166446
addEffect(FX_MODE_ANDROID, &mode_android, _data_FX_MODE_ANDROID);
65176447
addEffect(FX_MODE_CHASE_COLOR, &mode_chase_color, _data_FX_MODE_CHASE_COLOR);
65186448
addEffect(FX_MODE_CHASE_RANDOM, &mode_chase_random, _data_FX_MODE_CHASE_RANDOM);

wled00/FX.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,17 @@ extern byte realtimeMode; // used in getMappedPixelIndex()
154154
#define FX_MODE_THEATER_CHASE 13
155155
//#define FX_MODE_THEATER_CHASE_RAINBOW 14 // candidate for removal (use Theater)
156156
#define FX_MODE_RUNNING_LIGHTS 15
157-
#define FX_MODE_SAW 16
157+
//#define FX_MODE_SAW 16 // candidate for removal (use Running Lights with check 2)
158158
#define FX_MODE_TWINKLE 17
159159
#define FX_MODE_DISSOLVE 18
160160
//#define FX_MODE_DISSOLVE_RANDOM 19 // candidate for removal (use Dissolve with with check 3)
161161
#define FX_MODE_SPARKLE 20
162162
#define FX_MODE_FLASH_SPARKLE 21
163163
#define FX_MODE_HYPER_SPARKLE 22
164-
#define FX_MODE_STROBE 23
165-
#define FX_MODE_STROBE_RAINBOW 24
164+
//#define FX_MODE_STROBE 23 // candidate for removal (use Blink with with check 2)
165+
//#define FX_MODE_STROBE_RAINBOW 24 // candidate for removal (use Blink with with check 1 & check 2)
166166
#define FX_MODE_MULTI_STROBE 25
167-
#define FX_MODE_BLINK_RAINBOW 26
167+
//#define FX_MODE_BLINK_RAINBOW 26 // candidate for removal (use Blink with with check 1)
168168
#define FX_MODE_ANDROID 27
169169
#define FX_MODE_CHASE_COLOR 28
170170
#define FX_MODE_CHASE_RANDOM 29
@@ -635,7 +635,7 @@ class Segment {
635635
{ addPixelColor(n, CRGBA(r,g,b), preserveCR); }
636636
inline void fadePixelColor(uint16_t n, uint8_t fade) const { setPixelColor(n, getPixelColor(n).nscale8_video(fade)); }
637637
[[gnu::hot]] CRGBA color_from_palette(uint16_t, bool mapping, bool moving, uint8_t mcol, uint8_t pbri = 255) const;
638-
[[gnu::hot]] CRGBA color_wheel(uint8_t pos) const;
638+
inline CRGBA color_wheel(uint8_t pos) const { return color_from_palette(pos, false, false, 255); };
639639
// 2D matrix
640640
unsigned virtualWidth() const; // segment width in virtual pixels (accounts for groupping and spacing)
641641
unsigned virtualHeight() const; // segment height in virtual pixels (accounts for groupping and spacing)

0 commit comments

Comments
 (0)