kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.6k stars 347 forks source link

How to lengthen the Comet-Tail? #313

Closed EherXtrem closed 2 years ago

EherXtrem commented 2 years ago

I would like to lengthen the tail of the Comet (#44) effect a bit. Is that possible and if so, how?

moose4lord commented 2 years ago

You can use the optional OPTIONS parameter to control the length of the comet tail. One of the options is FADE_RATE which controls how long it takes to fade the comet tail, and so its length.

If you specify NO_OPTIONS (or just leave off the options parameter), you get the default fade rate, which always fades to black:

ws2812fx.setSegment(0,  0,  LED_COUNT - 1, FX_MODE_COMET, BLUE, 5000, NO_OPTIONS);

There are seven other FADE_RATE options, which make the fade rate faster or slower, and so the comet tail shorter or longer:

FADE_XFAST
FADE_FAST
FADE_MEDIUM
FADE_SLOW
FADE_XSLOW
FADE_XXSLOW
FADE_GLACIAL
ws2812fx.setSegment(0,  0,  LED_COUNT - 1, FX_MODE_COMET, BLUE, 5000, FADE_XSLOW);

Note that when you use one of the seven optional fade rates, it enables you to also fade to a background color other than black. So if you wanted a blue comet on a red background you can do this:

ws2812fx.setSegment(0,  0,  LED_COUNT - 1, FX_MODE_COMET, COLORS(BLUE, DIM(RED)), 5000, FADE_XSLOW);

There's more info about the OPTIONS parameter in the users guide.

EherXtrem commented 2 years ago

Wow ! It works preaty nice ! THX a lot !

Now I will try to discover the options for Fireworks Random (#46) by my own :)

moose4lord commented 2 years ago

You're welcome. Good luck!

EherXtrem commented 2 years ago

Is there a backgroud color option instead of black in Fireworks Random mode too?

moose4lord commented 2 years ago

You can use a fade option to get a non-black background color even with the FIREWORKS_RANDOM effect. This works for me:

  ws2812fx.setSegment(0,  0, LED_COUNT - 1, FX_MODE_FIREWORKS_RANDOM, COLORS(BLUE, DARK(RED)), 1000, FADE_MEDIUM);

It gets a little tricky with FIREWORKS_RANDOM (and other effects) if you slow down the fade too much. The background color can easily wash out the effect if the LEDs fade too slowly. For best effect set the brightness to 255 and set the background color to something very dim to produce good contrast. If you want bigger fireworks, you can combine a FADE and SIZE option like so:

ws2812fx.setSegment(0,  0, LED_COUNT - 1, FX_MODE_FIREWORKS_RANDOM, COLORS(BLUE, DARK(RED)), 1000, (uint8_t)(FADE_MEDIUM | SIZE_LARGE));
EherXtrem commented 2 years ago

Big THX - both code lines work very well. Awesome support :)