From 72cca365e53bd6a9d38d040a9a2e69857031ff68 Mon Sep 17 00:00:00 2001 From: Will Cooke Date: Wed, 6 May 2020 14:28:16 +0100 Subject: [PATCH] Add new mode "Solid Glitter". Gives a solid, static background colour as selected from the colour picker and overlays "glitter" (as per Rainbow Glitter, only without the rainbow). --- wled00/FX.cpp | 12 ++++++++++++ wled00/FX.h | 12 +++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 14fee5cb..c49c8304 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3322,3 +3322,15 @@ CRGB WS2812FX::pacifica_one_layer(uint16_t i, CRGBPalette16& p, uint16_t cistart uint8_t sindex8 = scale16(sindex16, 240); return ColorFromPalette(p, sindex8, bri, LINEARBLEND); } + +//Solid colour background with glitter +uint16_t WS2812FX::mode_solid_glitter() +{ + fill(SEGCOLOR(0)); + + if (SEGMENT.intensity > random8()) + { + setPixelColor(random16(SEGLEN), ULTRAWHITE); + } + return FRAMETIME; +} diff --git a/wled00/FX.h b/wled00/FX.h index c690a4e5..e3d591f9 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -98,7 +98,7 @@ #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED ) -#define MODE_COUNT 103 +#define MODE_COUNT 104 #define FX_MODE_STATIC 0 #define FX_MODE_BLINK 1 @@ -203,6 +203,7 @@ #define FX_MODE_HEARTBEAT 100 #define FX_MODE_PACIFICA 101 #define FX_MODE_CANDLE_MULTI 102 +#define FX_MODE_SOLID_GLITTER 103 class WS2812FX { typedef uint16_t (WS2812FX::*mode_ptr)(void); @@ -394,6 +395,7 @@ class WS2812FX { _mode[FX_MODE_HEARTBEAT] = &WS2812FX::mode_heartbeat; _mode[FX_MODE_PACIFICA] = &WS2812FX::mode_pacifica; _mode[FX_MODE_CANDLE_MULTI] = &WS2812FX::mode_candle_multi; + _mode[FX_MODE_SOLID_GLITTER] = &WS2812FX::mode_solid_glitter; _brightness = DEFAULT_BRIGHTNESS; currentPalette = CRGBPalette16(CRGB::Black); @@ -562,7 +564,7 @@ class WS2812FX { mode_twinklecat(void), mode_halloween_eyes(void), mode_static_pattern(void), - mode_tri_static_pattern(void), + mode_tri_static_pattern(void), mode_spots(void), mode_spots_fade(void), mode_glitter(void), @@ -580,8 +582,8 @@ class WS2812FX { mode_ripple_rainbow(void), mode_heartbeat(void), mode_pacifica(void), - mode_candle_multi(void); - + mode_candle_multi(void), + mode_solid_glitter(void); private: NeoPixelWrapper *bus; @@ -667,7 +669,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([ "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", "Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow", -"Heartbeat","Pacifica","Candle Multi" +"Heartbeat","Pacifica","Candle Multi", "Solid Glitter" ])=====";