Soft 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)
Effect Sample Gif

Description:

A really simple effect, adapted from the code by Mark Kriegsman here. The effect mimics classic white incandescent Christmas lights that gently twinkle on/off.

The effect is pretty much ready as is; it doesn't have many settings. Note that it is not compatible with color modes, and should not be used with other effects on the same segment set because it needs to fetch pixel colors from the strip.

The effect is adapted to work on segment lines for 2D use, with each line being a single color.

Notes:

I've mostly kept the effect the same as the original, only tweaking it to be able to work on segment lines for 2D. As such, I won't copy all of Mark's notes here, you can read them in the code linked above, or in the effect's code in Pixel Spork. The main takeaways are:

  • The effect brightens and dims pixels by a fixed CRGB lightColor each update.

  • Instead of using a separate array to track if each pixel should be brightening/dimming, it uses the red value for each pixel's CRGB color. If it's even, we're brightening, odd, we're dimming, relying on FastLED's saturating math to flip it when it's fully bright or dim. (This could alternatively be tracked with an array of uint8_t's, which takes up more memory, but would give you more freedom to tweak the effect....).

  • Due to the above, it's critical that the red part of lightColor be both non-zero and even.

  • If you are using FastLED setCorrection(TypicalLEDStrip), then (8,7,1) as lightColor gives a very soft, warm yellowish white, a little bit like incandescent fairy lights. If you are not using FastLED color correction, try (8,5,1) (default).

Example Calls:

SoftTwinkleSL softTwinkle(mainSegments, 150, 20);
//Soft twinkles with density of 150, updating at a rate of 20ms

Constructor Definitions:

SoftTwinkleSL(SegmentSetPS &SegSet, uint8_t Density, uint16_t Rate);

Constructor Inputs:

  • SegmentSetPS* segSet -- The Segment Set the effect will draw on. See common vars segSet entry for more details.

  • uint8_t density (max 255) -- The threshold for turning on a pixel, higher will turn on more pixels at once.

  • 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 vars rate entry for more.

Other Settings:

  • CRGB lightColor default( CRGB{8, 5, 1} ) -- The color used to increment the pixel colors. As noted above, the red value should always be an even number.

  • bool showNow (default true) -- Controls if the effect "draws" during each update cycle by calling FastLED.show(). Common to all effects. See common vars showNow entry for more details.

Class Functions:

  • void reset();

    Resets all the pixels to black, restarting the effect.

  • void update();

    Updates the effect.

⚠️ **GitHub.com Fallback** ⚠️