diff --git a/wled00/FX.cpp b/wled00/FX.cpp index b775c787a..14a46b534 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1720,7 +1720,8 @@ uint16_t WS2812FX::mode_colorwaves() uint8_t msmultiplier = beatsin88(147, 23, 60); uint16_t hue16 = sHue16;//gHue * 256; - uint16_t hueinc16 = beatsin88(113, 300, 1500); + // uint16_t hueinc16 = beatsin88(113, 300, 1500); + uint16_t hueinc16 = beatsin88(113, 60, 300)*SEGMENT.intensity*10/255; // Use the Intensity Slider for the hues sPseudotime += duration * msmultiplier; sHue16 += duration * beatsin88(400, 5, 9); @@ -2890,7 +2891,7 @@ uint16_t WS2812FX::mode_exploding_fireworks(void) uint16_t WS2812FX::mode_drip(void) { //allocate segment data - uint16_t numDrops = 2; + uint16_t numDrops = 4; uint16_t dataSize = sizeof(spark) * numDrops; if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed @@ -2898,6 +2899,8 @@ uint16_t WS2812FX::mode_drip(void) Spark* drops = reinterpret_cast(SEGENV.data); + numDrops = 1 + (SEGMENT.intensity >> 6); + float gravity = -0.001 - (SEGMENT.speed/50000.0); gravity *= SEGLEN; int sourcedrop = 12; @@ -2915,7 +2918,7 @@ uint16_t WS2812FX::mode_drip(void) if (drops[j].col>255) drops[j].col=255; setPixelColor(int(drops[j].pos),color_blend(BLACK,SEGCOLOR(0),drops[j].col)); - drops[j].col += map(SEGMENT.intensity, 0, 255, 1, 6); // swelling + drops[j].col += map(SEGMENT.speed, 0, 255, 1, 6); // swelling if (random8() < drops[j].col/10) { // random drop drops[j].colIndex=2; //fall @@ -2954,3 +2957,22 @@ uint16_t WS2812FX::mode_drip(void) } return FRAMETIME; } + + +/* +/ Plasma Effect +/ adapted from https://github.com/atuline/FastLED-Demos/blob/master/plasma/plasma.ino +*/ +uint16_t WS2812FX::mode_plasma(void) { + uint8_t thisPhase = beatsin8(6,-64,64); // Setting phase change for a couple of waves. + uint8_t thatPhase = beatsin8(7,-64,64); + + for (int i = 0; i < SEGLEN; i++) { // For each of the LED's in the strand, set color & brightness based on a wave as follows: + uint8_t colorIndex = cubicwave8((i*(1+ 3*(SEGMENT.speed >> 5)))+(thisPhase) & 0xFF)/2 // factor=23 // Create a wave and add a phase change and add another wave with its own phase change. + + cos8((i*(1+ 2*(SEGMENT.speed >> 5)))+(thatPhase) & 0xFF)/2; // factor=15 // Hey, you can even change the frequencies if you wish. + uint8_t thisBright = qsub8(colorIndex, beatsin8(6,0,128)); + setPixelColor(i, color_blend(SEGCOLOR(1), color_from_palette(colorIndex, false, false, 0), thisBright)); + } + + return FRAMETIME; +} diff --git a/wled00/FX.h b/wled00/FX.h index 623f874bb..2ed1f2f4b 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -91,7 +91,7 @@ #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) -#define MODE_COUNT 97 +#define MODE_COUNT 98 #define FX_MODE_STATIC 0 #define FX_MODE_BLINK 1 @@ -190,6 +190,7 @@ #define FX_MODE_SINELON_RAINBOW 94 #define FX_MODE_POPCORN 95 #define FX_MODE_DRIP 96 +#define FX_MODE_PLASMA 97 class WS2812FX { @@ -376,6 +377,7 @@ class WS2812FX { _mode[FX_MODE_SINELON_RAINBOW] = &WS2812FX::mode_sinelon_rainbow; _mode[FX_MODE_POPCORN] = &WS2812FX::mode_popcorn; _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; + _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; _brightness = DEFAULT_BRIGHTNESS; currentPalette = CRGBPalette16(CRGB::Black); @@ -557,7 +559,8 @@ class WS2812FX { mode_sinelon_dual(void), mode_sinelon_rainbow(void), mode_popcorn(void), - mode_drip(void); + mode_drip(void), + mode_plasma(void); private: @@ -637,7 +640,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([ "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", "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" +"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma" ])=====";