Adding palette blends effect (#1491)
* Adding palette blends effect * Fixes for blends effect * Improved blend effect intesity and speed control * Simplify Blends timing Co-authored-by: Tyler Walters <tyler@guardmedia.com> Co-authored-by: cschwinne <dev.aircoookie@gmail.com>
This commit is contained in:
parent
e348e66f14
commit
34c9c5a9b1
@ -3733,3 +3733,23 @@ uint16_t WS2812FX::mode_washing_machine(void) {
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
/*
|
||||
Blends random colors across palette
|
||||
Modified, originally by Mark Kriegsman https://gist.github.com/kriegsman/1f7ccbbfa492a73c015e
|
||||
*/
|
||||
uint16_t WS2812FX::mode_blends(void) {
|
||||
uint16_t dataSize = sizeof(uint32_t) * SEGLEN;
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
uint32_t* pixels = reinterpret_cast<uint32_t*>(SEGENV.data);
|
||||
uint8_t blendSpeed = map(SEGMENT.intensity, 0, UINT8_MAX, 10, 128);
|
||||
uint8_t shift = (now * ((SEGMENT.speed >> 3) +1)) >> 8;
|
||||
|
||||
for (int i = 0; i < SEGLEN; i++) {
|
||||
pixels[i] = color_blend(pixels[i], color_from_palette(shift + quadwave8((i + 1) * 16), false, PALETTE_SOLID_WRAP, 255), blendSpeed);
|
||||
setPixelColor(i, pixels[i]);
|
||||
shift += 3;
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
@ -116,7 +116,7 @@
|
||||
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
|
||||
#define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED )
|
||||
|
||||
#define MODE_COUNT 115
|
||||
#define MODE_COUNT 116
|
||||
|
||||
#define FX_MODE_STATIC 0
|
||||
#define FX_MODE_BLINK 1
|
||||
@ -233,6 +233,7 @@
|
||||
#define FX_MODE_DANCING_SHADOWS 112
|
||||
#define FX_MODE_WASHING_MACHINE 113
|
||||
#define FX_MODE_CANDY_CANE 114
|
||||
#define FX_MODE_BLENDS 115
|
||||
|
||||
class WS2812FX {
|
||||
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
||||
@ -461,6 +462,7 @@ class WS2812FX {
|
||||
_mode[FX_MODE_DANCING_SHADOWS] = &WS2812FX::mode_dancing_shadows;
|
||||
_mode[FX_MODE_WASHING_MACHINE] = &WS2812FX::mode_washing_machine;
|
||||
_mode[FX_MODE_CANDY_CANE] = &WS2812FX::mode_candy_cane;
|
||||
_mode[FX_MODE_BLENDS] = &WS2812FX::mode_blends;
|
||||
|
||||
_brightness = DEFAULT_BRIGHTNESS;
|
||||
currentPalette = CRGBPalette16(CRGB::Black);
|
||||
@ -670,7 +672,8 @@ class WS2812FX {
|
||||
mode_chunchun(void),
|
||||
mode_dancing_shadows(void),
|
||||
mode_washing_machine(void),
|
||||
mode_candy_cane(void);
|
||||
mode_candy_cane(void),
|
||||
mode_blends(void);
|
||||
|
||||
private:
|
||||
NeoPixelWrapper *bus;
|
||||
@ -758,7 +761,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
|
||||
"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", "Solid Glitter","Sunrise","Phased","Twinkleup","Noise Pal", "Sine","Phased Noise",
|
||||
"Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane"
|
||||
"Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends"
|
||||
])=====";
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user