Dynamic fade effect (#1550)

* New Effect "TV Simulator"

based on "Fake TV Light for Engineers" by Phillip Burgess https://learn.adafruit.com/fake-tv-light-for-engineers/arduino-sketch

* removed some not-used functions 

...from my 1st attempt with "Phoney TV" - but this one did not look good.

* Dynamic Effect extended with a "smooth" variant

...to close #1114 / the "Dynamice fade effect" in the projects section

Co-authored-by: Aircoookie <dev.aircoookie@gmail.com>
This commit is contained in:
Def3nder 2020-12-22 16:26:19 +01:00 committed by GitHub
parent e16bab8dd9
commit a91d993c6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 8 deletions

View File

@ -234,9 +234,9 @@ uint16_t WS2812FX::mode_random_color(void) {
/*
* Lights every LED in a random color. Changes all LED at the same time
// * to new random colors.
* to new random colors.
*/
uint16_t WS2812FX::mode_dynamic(void) {
uint16_t WS2812FX::dynamic(boolean smooth=false) {
if (!SEGENV.allocateData(SEGLEN)) return mode_static(); //allocation failed
if(SEGENV.call == 0) {
@ -253,12 +253,31 @@ uint16_t WS2812FX::mode_dynamic(void) {
SEGENV.step = it;
}
if (smooth) {
for (uint16_t i = 0; i < SEGLEN; i++) {
blendPixelColor(i, color_wheel(SEGENV.data[i]),16);
}
} else {
for (uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_wheel(SEGENV.data[i]));
}
}
return FRAMETIME;
}
/*
* Original effect "Dynamic"
*/
uint16_t WS2812FX::mode_dynamic(void) {
return dynamic(false);
}
/*
* effect "Dynamic" with smoth color-fading
*/
uint16_t WS2812FX::mode_dynamic_smooth(void) {
return dynamic(true);
}
/*
* Does the "standby-breathing" of well known i-Devices.
@ -3755,6 +3774,7 @@ uint16_t WS2812FX::mode_blends(void) {
return FRAMETIME;
}
#ifndef WLED_DISABLE_FX_HIGH_FLASH_USE
typedef struct TvSim {
uint32_t totalTime = 0;
uint32_t fadeTime = 0;
@ -3767,6 +3787,7 @@ typedef struct TvSim {
} tvSim;
#define numTVPixels (sizeof(tv_colors) / 2) // 2 bytes per Pixel (5/6/5)
#endif
/*
TV Simulator

View File

@ -119,7 +119,8 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED )
#define MODE_COUNT 117
#define MODE_COUNT 118
#define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1
@ -238,6 +239,7 @@
#define FX_MODE_CANDY_CANE 114
#define FX_MODE_BLENDS 115
#define FX_MODE_TV_SIMULATOR 116
#define FX_MODE_DYNAMIC_SMOOTH 117
class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void);
@ -468,6 +470,7 @@ class WS2812FX {
_mode[FX_MODE_CANDY_CANE] = &WS2812FX::mode_candy_cane;
_mode[FX_MODE_BLENDS] = &WS2812FX::mode_blends;
_mode[FX_MODE_TV_SIMULATOR] = &WS2812FX::mode_tv_simulator;
_mode[FX_MODE_DYNAMIC_SMOOTH] = &WS2812FX::mode_dynamic_smooth;
_brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black);
@ -679,7 +682,8 @@ class WS2812FX {
mode_washing_machine(void),
mode_candy_cane(void),
mode_blends(void),
mode_tv_simulator(void);
mode_tv_simulator(void),
mode_dynamic_smooth(void);
private:
NeoPixelWrapper *bus;
@ -712,6 +716,7 @@ class WS2812FX {
blink(uint32_t, uint32_t, bool strobe, bool),
candle(bool),
color_wipe(bool, bool),
dynamic(bool),
scan(bool),
theater_chase(uint32_t, uint32_t, bool),
running_base(bool),
@ -767,7 +772,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","Blends","TV Simulator"
"Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends","TV Simulator","Dynamic Smooth"
])=====";