commit
f9b44381bd
@ -2546,3 +2546,31 @@ uint16_t WS2812FX::mode_lake() {
|
||||
}
|
||||
return 33;
|
||||
}
|
||||
|
||||
// meteor effect
|
||||
// send a meteor from begining to to the end of the strip with a trail that randomly decay.
|
||||
// adapted from https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#LEDStripEffectMeteorRain
|
||||
|
||||
uint16_t WS2812FX::mode_meteor() {
|
||||
byte meteorSize=1+(256-SEGMENT.intensity)/16;
|
||||
uint32_t led_offset = SEGMENT_RUNTIME.counter_mode_step;
|
||||
uint16_t i = SEGMENT.start + led_offset;
|
||||
byte meteorTrailDecay=SEGMENT.intensity;
|
||||
|
||||
// fade all leds to colors[1] in LEDs one step
|
||||
for (uint16_t i = SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||
if (random(10)>5) {
|
||||
setPixelColor(i,color_blend(getPixelColor(i),SEGMENT.colors[1],meteorTrailDecay));
|
||||
}
|
||||
}
|
||||
|
||||
// draw meteor
|
||||
for(int j = 0; j < meteorSize; j++) {
|
||||
if( ( SEGMENT.start + j < SEGMENT.stop) ) {
|
||||
setPixelColor(i+j, SEGMENT.colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % (SEGMENT_LENGTH);
|
||||
return SPEED_FORMULA_L;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@
|
||||
#define REVERSE (uint8_t)0x80
|
||||
#define IS_REVERSE ((SEGMENT.options & REVERSE) == REVERSE)
|
||||
|
||||
#define MODE_COUNT 76
|
||||
#define MODE_COUNT 77
|
||||
|
||||
#define FX_MODE_STATIC 0
|
||||
#define FX_MODE_BLINK 1
|
||||
@ -164,6 +164,8 @@
|
||||
#define FX_MODE_NOISE16_4 73
|
||||
#define FX_MODE_COLORTWINKLE 74
|
||||
#define FX_MODE_LAKE 75
|
||||
#define FX_MODE_METEOR 76
|
||||
|
||||
|
||||
class WS2812FX {
|
||||
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
||||
@ -268,6 +270,7 @@ class WS2812FX {
|
||||
_mode[FX_MODE_NOISE16_4] = &WS2812FX::mode_noise16_4;
|
||||
_mode[FX_MODE_COLORTWINKLE] = &WS2812FX::mode_colortwinkle;
|
||||
_mode[FX_MODE_LAKE] = &WS2812FX::mode_lake;
|
||||
_mode[FX_MODE_METEOR] = &WS2812FX::mode_meteor;
|
||||
|
||||
_brightness = DEFAULT_BRIGHTNESS;
|
||||
_running = false;
|
||||
@ -443,6 +446,7 @@ class WS2812FX {
|
||||
mode_noise16_4(void),
|
||||
mode_colortwinkle(void),
|
||||
mode_lake(void),
|
||||
mode_meteor(void),
|
||||
mode_lightning(void);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user