Twinkle (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki
See the Documentation Guide for help understanding each page section.
Effect Sample (see here for sample info) (Shown in 1D) |
Fades random pixels in and out (like FastLED TwinkleFox). The color of the pixels can be set to a single color, chosen randomly, or picked from a palette. The number of fade in and out steps is set by fadeInSteps
and fadeOutSteps
, allowing you full customization over how the effect pixels look. Try a single fade in step, with 5+ fade out steps for a "rain drop" type look.
The effect is adapted to work on segment lines for 2D use. Each line will be a single color.
Supports color modes for both the main and background colors.
Note that the effect always spawns one fading pixel with every update cycle, while fading any existing twinkles out by one step. This means that the total number of twinkles active at one time will be numTwinkles * (FadeInSteps + FadeOutSteps)
. So even a low numTwinkles
, will lead to quite a lot of lit pixels. Just run an example and you'll see what I mean.
For a more complex version of this effect that offers more control over the twinkle density, see Twinkle 2 (Seg Line or Seg). For more lightweight, faster version of this effect see Twinkle Fast (Seg Line).
Note that adjusting most of the effect's settings will reset the effect.
Sets how the twinkle colors will be picked.
- 0 -- Picks colors randomly from the palette.
- 1 -- Picks colors totally at random.
Warning, for the effect to work, it needs to keep track of all the active twinkles as they fade in/out. To do this it uses a pair of dynamically created 2D uint16_t and CRGB arrays of size numTwinkles * (fadeInSteps + fadeOutSteps
). This can take up a good amount of ram, so be aware of your available memory. To avoid memory fragmentation, when you create the effect, you should set numTwinkles
, fadeInSteps
, and fadeOutSteps
to the maximum values you expect to use. See Memory Management for more details.
TwinkleSL twinkle(mainSegments, cybPnkPal_PS, 0, 3, 1, 6, 60);
/* Will choose 3 pixels each cycle to fade to/from colors from the cybPnkPal_PS palette.
The background is blank.
The pixels will have 1 fade in and 6 fade out steps,
updating at a rate of 60ms. */
TwinkleSL twinkle(mainSegments, CRGB::Red, CRGB::Blue, 2, 4, 4, 70);
/* Will choose 2 pixels each cycle to fade to/from red.
The background is blue.
The pixels will 4 fade in and out steps,
updating at a rate of 70ms. */
//Constructor for a full palette effect
TwinkleSL(SegmentSetPS &SegSet, palettePS &Palette, CRGB BgColor, uint16_t numTwinkles, uint8_t FadeInSteps,
uint8_t FadeOutSteps, uint16_t Rate);
//Constructor for a using a single color
TwinkleSL(SegmentSetPS &SegSet, CRGB Color, CRGB BgColor, uint16_t numTwinkles, uint8_t FadeInSteps,
uint8_t FadeOutSteps, uint16_t Rate);
-
SegmentSetPS* segSet -- The Segment Set the effect will draw on. See common vars
segSet
entry for more details. -
palettePS* palette (optional, see constructors) -- The set of colors the effect will use. See palettes. It is a pointer. See common vars
palette
entry for more details. -
CRGB color (optional, see constructors) -- A single color for the effect. The color will be placed into the effect's local palette,
paletteTemp
for use. -
CRGB* bgColor -- The color used for background pixels. Is a pointer, allowing you to bind it to an external color. By default it's bound the effect's local,
bgColorOrig
color. See common varsbgColor
entry for more details. -
uint16_t numTwinkles -- The number of random pixels chosen for twinkling each cycle. Can be changed later using
setNumTwinkles()
. -
uint8_t fadeInSteps (min 1) -- The number of blend steps to fade a pixel in. Can be changed later using
setSteps()
. -
uint8_t fadeOutSteps (min 1) -- The number of blend steps to fade a pixel out. Can be changed later using
setSteps()
. -
uint16_t* rate -- Update rate (ms). Is a pointer, allowing you to bind it to an external variable. By default it's bound the effect's local variable,
rateOrig
. See common varsrate
entry for more.
-
uint8_t colorMode (default 0) -- The colorMode use for the effect, also see common vars
colorMode
entry for more details. -
uint8_t bgColorMode (default 0) -- The colorMode used for the background pixels, also see common vars
colorMode
entry for more details. -
uint8_t randMode (default 0) -- (See
randMode
notes in intro). -
bool fillBg (default false) -- If true, then all pixels will be re-colored with each update(), rather than just drawing those that have changed. See common vars
fillBg
entry for more details. -
bool showNow (default true) -- Controls if the effect "draws" during each update cycle by calling
FastLED.show()
. Common to all effects. See common varsshowNow
entry for more details.
-
void setSingleColor( CRGB Color );
Sets the effect to use a single color for the pixels. The color will be placed into the effect's local palette,
paletteTemp
for use. -
void setNumTwinkles( uint16_t newNumTwinkles );
Sets a new number of pixels to be twinkled each cycle. (Will reset the effect if the new number of pixels is different than the current number).
-
void setSteps( uint8_t newFadeInSteps, uint8_t newFadeOutSteps );
Sets the number of fade in and out steps. (Will reset the effect if the new total number of steps
(fadeInSteps + fadeOutSteps)
is greater than the current total). -
void reset();
Restarts the effect. Clears any existing twinkles.
-
void update();
Updates the effect.
-
uint16_t numTwinkles -- (See Constructor Inputs above), set with
setNumTwinkles()
. -
uint8_t fadeInSteps -- (See Constructor Inputs above), set using
setSteps()
. -
uint8_t fadeOutSteps -- (See Constructor Inputs above), set using
setSteps()
.