From 86ae11f4c44fe1b37a325af5040b9438a6d5ed9d Mon Sep 17 00:00:00 2001 From: fishbone-git Date: Tue, 10 Dec 2019 20:26:02 +0100 Subject: [PATCH] add sinelon effect --- wled00/FX.cpp | 25 +++++++++++++++++++++++++ wled00/FX.h | 9 ++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 495c0397a..d0a34a28d 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2348,4 +2348,29 @@ uint16_t WS2812FX::mode_BouncingBalls(void) { } return 20; +} + +/* +* Sinelon stolen from FASTLED examples +*/ +uint16_t WS2812FX::mode_sinelon(void) { + + fade_out(SEGMENT.intensity); + int pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1); + static int prevpos = 0; + + // setRange seems great to use, but doesn't work here for some reason + if( pos < prevpos ) { + for (uint16_t i = pos; i < prevpos; i++) + { + setPixelColor(i, color_from_palette(pos, false, false, 0)); + } + } else { + for (uint16_t i = prevpos; i < pos; i++) + { + setPixelColor(i, color_from_palette(pos, false, false, 0)); + } + } + prevpos = pos; + return FRAMETIME; } \ No newline at end of file diff --git a/wled00/FX.h b/wled00/FX.h index 5642850a3..aabf70790 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -84,7 +84,7 @@ #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) -#define MODE_COUNT 88 +#define MODE_COUNT 89 #define FX_MODE_STATIC 0 #define FX_MODE_BLINK 1 @@ -174,6 +174,7 @@ #define FX_MODE_SPOTS 85 #define FX_MODE_SPOTS_FADE 86 #define FX_MODE_BOUNCINGBALLS 87 +#define FX_MODE_SINELON 88 class WS2812FX { @@ -319,6 +320,7 @@ class WS2812FX { _mode[FX_MODE_SPOTS] = &WS2812FX::mode_spots; _mode[FX_MODE_SPOTS_FADE] = &WS2812FX::mode_spots_fade; _mode[FX_MODE_BOUNCINGBALLS] = &WS2812FX::mode_BouncingBalls; + _mode[FX_MODE_SINELON] = &WS2812FX::mode_sinelon; _brightness = DEFAULT_BRIGHTNESS; currentPalette = CRGBPalette16(CRGB::Black); @@ -500,7 +502,8 @@ class WS2812FX { mode_tri_static_pattern(void), mode_spots(void), mode_spots_fade(void), - mode_BouncingBalls(void); + mode_BouncingBalls(void), + mode_sinelon(void); private: NeoPixelWrapper *bus; @@ -573,7 +576,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([ "Two Dots","Two Areas","Circus","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet", "Dual Scanner","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise", "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Smooth Meteor","Railway","Ripple", -"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Bouncing Balls" +"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Bouncing Balls", "Sinelon" ])=====";