add sinelon effect

This commit is contained in:
fishbone-git 2019-12-10 20:26:02 +01:00
parent 7ca1970fff
commit 86ae11f4c4
2 changed files with 31 additions and 3 deletions

View File

@ -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;
}

View File

@ -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"
])=====";