Merge pull request #683 from fishbone-git/ripple_rainbow

water ripple effect with a dimmed rainbow background
This commit is contained in:
Aircoookie 2020-02-17 10:32:30 +01:00 committed by GitHub
commit 61f3002568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 6 deletions

View File

@ -2134,7 +2134,7 @@ typedef struct Ripple {
uint16_t pos; uint16_t pos;
} ripple; } ripple;
uint16_t WS2812FX::mode_ripple() uint16_t WS2812FX::ripple_base(bool rainbow)
{ {
uint16_t maxRipples = 1 + (SEGLEN >> 2); uint16_t maxRipples = 1 + (SEGLEN >> 2);
if (maxRipples > 100) maxRipples = 100; if (maxRipples > 100) maxRipples = 100;
@ -2144,8 +2144,25 @@ uint16_t WS2812FX::mode_ripple()
Ripple* ripples = reinterpret_cast<Ripple*>(SEGENV.data); Ripple* ripples = reinterpret_cast<Ripple*>(SEGENV.data);
fill(SEGCOLOR(1)); // ranbow background or chosen background, all very dim.
if (rainbow) {
if (SEGENV.call ==0) {
SEGENV.aux0 = random8();
SEGENV.aux1 = random8();
}
if (SEGENV.aux0 == SEGENV.aux1) {
SEGENV.aux1 = random8();
}
else if (SEGENV.aux1 > SEGENV.aux0) {
SEGENV.aux0++;
} else {
SEGENV.aux0--;
}
fill(color_blend(color_wheel(SEGENV.aux0),BLACK,235));
} else {
fill(SEGCOLOR(1));
}
//draw wave //draw wave
for (uint16_t i = 0; i < maxRipples; i++) for (uint16_t i = 0; i < maxRipples; i++)
{ {
@ -2189,6 +2206,15 @@ uint16_t WS2812FX::mode_ripple()
return FRAMETIME; return FRAMETIME;
} }
uint16_t WS2812FX::mode_ripple(void) {
return ripple_base(false);
}
uint16_t WS2812FX::mode_ripple_rainbow(void) {
return ripple_base(true);
}
// TwinkleFOX by Mark Kriegsman: https://gist.github.com/kriegsman/756ea6dcae8e30845b5a // TwinkleFOX by Mark Kriegsman: https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
// //

View File

@ -91,7 +91,7 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED )
#define MODE_COUNT 99 #define MODE_COUNT 100
#define FX_MODE_STATIC 0 #define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1 #define FX_MODE_BLINK 1
@ -192,6 +192,7 @@
#define FX_MODE_DRIP 96 #define FX_MODE_DRIP 96
#define FX_MODE_PLASMA 97 #define FX_MODE_PLASMA 97
#define FX_MODE_PERCENT 98 #define FX_MODE_PERCENT 98
#define FX_MODE_RIPPLE_RAINBOW 99
class WS2812FX { class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void); typedef uint16_t (WS2812FX::*mode_ptr)(void);
@ -379,6 +380,7 @@ class WS2812FX {
_mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip;
_mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma;
_mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent; _mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent;
_mode[FX_MODE_RIPPLE_RAINBOW] = &WS2812FX::mode_ripple_rainbow;
_brightness = DEFAULT_BRIGHTNESS; _brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black); currentPalette = CRGBPalette16(CRGB::Black);
@ -562,7 +564,8 @@ class WS2812FX {
mode_popcorn(void), mode_popcorn(void),
mode_drip(void), mode_drip(void),
mode_plasma(void), mode_plasma(void),
mode_percent(void); mode_percent(void),
mode_ripple_rainbow(void);
private: private:
@ -607,6 +610,7 @@ class WS2812FX {
dissolve(uint32_t), dissolve(uint32_t),
chase(uint32_t, uint32_t, uint32_t, bool), chase(uint32_t, uint32_t, uint32_t, bool),
gradient_base(bool), gradient_base(bool),
ripple_base(bool),
police_base(uint32_t, uint32_t), police_base(uint32_t, uint32_t),
running(uint32_t, uint32_t), running(uint32_t, uint32_t),
tricolor_chase(uint32_t, uint32_t), tricolor_chase(uint32_t, uint32_t),
@ -642,7 +646,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
"Scanner Dual","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise", "Scanner Dual","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise",
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple", "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple",
"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst", "Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst",
"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent" "Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent", "Ripple Rainbow"
])====="; ])=====";