Merge pull request #1208 from Phunkafizer/master
Added washing machine FX
This commit is contained in:
commit
8c513c2aad
@ -3712,3 +3712,22 @@ uint16_t WS2812FX::mode_dancing_shadows(void)
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
/*
|
||||
Imitates a washing machine, rotating same waves forward, then pause, then backward.
|
||||
By Stefan Seegel
|
||||
*/
|
||||
uint16_t WS2812FX::mode_washing_machine(void) {
|
||||
float speed = tristate_square8(now >> 7, 90, 15);
|
||||
float quot = 32.0f - ((float)SEGMENT.speed / 16.0f);
|
||||
speed /= quot;
|
||||
|
||||
SEGENV.step += (speed * 128.0f);
|
||||
|
||||
for (int i=0; i<SEGLEN; i++) {
|
||||
uint8_t col = sin8(((SEGMENT.intensity / 25 + 1) * 255 * i / SEGLEN) + (SEGENV.step >> 7));
|
||||
setPixelColor(i, color_from_palette(col, false, PALETTE_SOLID_WRAP, 3));
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
12
wled00/FX.h
12
wled00/FX.h
@ -107,7 +107,7 @@
|
||||
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
|
||||
#define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED )
|
||||
|
||||
#define MODE_COUNT 113
|
||||
#define MODE_COUNT 114
|
||||
|
||||
#define FX_MODE_STATIC 0
|
||||
#define FX_MODE_BLINK 1
|
||||
@ -222,6 +222,7 @@
|
||||
#define FX_MODE_FLOW 110
|
||||
#define FX_MODE_CHUNCHUN 111
|
||||
#define FX_MODE_DANCING_SHADOWS 112
|
||||
#define FX_MODE_WASHING_MACHINE 113
|
||||
|
||||
class WS2812FX {
|
||||
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
||||
@ -426,6 +427,7 @@ class WS2812FX {
|
||||
_mode[FX_MODE_FLOW] = &WS2812FX::mode_flow;
|
||||
_mode[FX_MODE_CHUNCHUN] = &WS2812FX::mode_chunchun;
|
||||
_mode[FX_MODE_DANCING_SHADOWS] = &WS2812FX::mode_dancing_shadows;
|
||||
_mode[FX_MODE_WASHING_MACHINE] = &WS2812FX::mode_washing_machine;
|
||||
|
||||
_brightness = DEFAULT_BRIGHTNESS;
|
||||
currentPalette = CRGBPalette16(CRGB::Black);
|
||||
@ -485,6 +487,9 @@ class WS2812FX {
|
||||
gamma8(uint8_t),
|
||||
get_random_wheel_index(uint8_t);
|
||||
|
||||
int8_t
|
||||
tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec);
|
||||
|
||||
uint16_t
|
||||
ablMilliampsMax,
|
||||
currentMilliamps,
|
||||
@ -625,7 +630,8 @@ class WS2812FX {
|
||||
mode_phased_noise(void),
|
||||
mode_flow(void),
|
||||
mode_chunchun(void),
|
||||
mode_dancing_shadows(void);
|
||||
mode_dancing_shadows(void),
|
||||
mode_washing_machine(void);
|
||||
|
||||
private:
|
||||
NeoPixelWrapper *bus;
|
||||
@ -712,7 +718,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"
|
||||
"Flow","Chunchun","Dancing Shadows","Washing Machine"
|
||||
])=====";
|
||||
|
||||
|
||||
|
@ -699,6 +699,32 @@ uint16_t WS2812FX::triwave16(uint16_t in)
|
||||
return 0xFFFF - (in - 0x8000)*2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generates a tristate square wave w/ attac & decay
|
||||
* @param x input value 0-255
|
||||
* @param pulsewidth 0-127
|
||||
* @param attdec attac & decay, max. pulsewidth / 2
|
||||
* @returns signed waveform value
|
||||
*/
|
||||
int8_t WS2812FX::tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec) {
|
||||
int8_t a = 127;
|
||||
if (x > 127) {
|
||||
a = -127;
|
||||
x -= 127;
|
||||
}
|
||||
|
||||
if (x < attdec) { //inc to max
|
||||
return (int16_t) x * a / attdec;
|
||||
}
|
||||
else if (x < pulsewidth - attdec) { //max
|
||||
return a;
|
||||
}
|
||||
else if (x < pulsewidth) { //dec to 0
|
||||
return (int16_t) (pulsewidth - x) * a / attdec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Put a value 0 to 255 in to get a color value.
|
||||
* The colours are a transition r -> g -> b -> back to r
|
||||
@ -844,7 +870,7 @@ void WS2812FX::handle_palette(void)
|
||||
load_gradient_palette(paletteIndex -13);
|
||||
}
|
||||
|
||||
if (singleSegmentMode && paletteFade) //only blend if just one segment uses FastLED mode
|
||||
if (singleSegmentMode && paletteFade && SEGENV.call > 0) //only blend if just one segment uses FastLED mode
|
||||
{
|
||||
nblendPaletteTowardPalette(currentPalette, targetPalette, 48);
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user