Gradient Cycle Fast (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki

See the Documentation Guide for help understanding each page section.

Effect Sample (see here for sample info)
Effect Sample Gif

Description:

The fast version of Gradient Cycle (Seg Line).

Moves a set of color gradients along the segment set that blend into one another. The gradients can be set to follow a pattern, use a palette, or set randomly. They have a set length, and smoothly transition from one color to the next, wrapping back to the first color at the end. If the total length of the gradients is longer than the segment set, all colors will still be shown, they will just cycle on and off the segment set.

The effect is adapted to work on segment lines for 2D use, each gradient will be repeated down the segment lines (so each segment line is a single color from the gradient).

This effect is the same as Gradient Cycle (Seg Line), but instead of calculating the color of every pixel, it only does so for the lead pixel, while copying the color of each subsequent pixel down along the strip. This leads to a much more lightweight effect, however it does have a few extra restrictions:

  1. Changing the palette on the fly will have a delayed effect on the colors. The existing colors will shift off the strip before new ones shift on. This prevents this effect from playing well with Palette Utility classes.
  2. The same restrictions as (1) apply to changing the pattern or the gradient lengths, gradLength.
  3. Changing the direction of the segments or segment set mid-effect may break it temporarily.
  4. The effect should not be run alongside other effects on the same Segment Set due to it copying colors from LEDs.
  5. The effect will not work well with the Effect Set Fader utility.

However, as a bonus, this effect supports random colored gradients, where the colors for the gradients are chosen at random as the enter the strip. This is controlled by the randMode setting:

randMode (default 0):

  • 0 -- Colors will be chosen in order from the pattern (not random).
  • 1 -- Colors will be chosen completely at random.
  • 2 -- Colors will be chosen randomly from the pattern (will not repeat the same color in a row).

Example Calls:

uint8_t pattern_arr = {0, 2, 1};
patternPS pattern = {pattern_arr, SIZE(pattern_arr), SIZE(pattern_arr)};

GradientCycleFastSL gradientCycleFast(mainSegments, pattern, cybPnkPal_PS, 10, 100);
/*  Will do a gradient cycle from color 0, to color 2, to color 1, of the palette
    with 10 steps to each gradient, and a 100ms update rate */

GradientCycleFastSL gradientCycleFast(mainSegments, cybPnkPal_PS, 10, 100);
/*  Will do a gradient cycle using the colors in the palette, with 10 steps to each gradient,
    and a 100ms update rate */

GradientCycleFastSL gradientCycleFast(mainSegments, 3, 15, 80);
/*  Will do a gradient cycle using 3 randomly chosen colors, with 15 steps to each gradient,
    and an 80ms update rate */

Constructor Definitions:

//Constructor for using pattern
GradientCycleFastSL(SegmentSetPS &SegSet, patternPS &Pattern, palettePS &Palette, uint8_t GradLength, uint16_t Rate);

//Constructor for using the palette as the pattern
GradientCycleFastSL(SegmentSetPS &SegSet, palettePS &Palette, uint8_t GradLength, uint16_t Rate);

//Constructor for using a random palette as the pattern
GradientCycleFastSL(SegmentSetPS &SegSet, uint8_t NumColors, uint8_t GradLength, uint16_t Rate);

Constructor Inputs:

  • 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.

  • patternPS* pattern (optional, see constructors) -- The color pattern the effect will use. See patterns. It is a pointer. See common vars pattern entry for more details.

  • uint8_t numColors -- The number of randomly chosen colors for the effect. The colors will be placed into the effect's local palette, paletteTemp for use.

  • uint8_t gradLength -- How many steps for each gradient.

  • 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:

  • uint8_t randMode (default 0) -- Sets how colors are chosen (see notes in Intro)

  • 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 setPaletteAsPattern();

    Sets the effect pattern to match the current effect palette. See Common Functions for more.

  • void reset();

    Restarts the effect from its initial state.

  • void update();

    Updates the effect.

Reference Vars:

  • uint8_t cycleNum -- Tracks how many cycles we've done, resets every gradLength cycles.

Flags:

  • bool initFillDone -- Indicates if the strip has been pre-filled with the effect's gradients, which happens during the first update cycle. Set true once the first update cycle has been finished.
⚠️ **GitHub.com Fallback** ⚠️