Rolling Waves Fast (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki

See the Documentation Guide for help understanding each page section.

Effect Sample (see here for sample info) (Waves look much better IRL)
Effect Sample Gif

Description:

This effect is the "Fast" version of Rolling Waves.

Repeats a set of waves along the segment set according to the input pattern and palette. Each wave is a gradient that shifts towards a set background color. The waves are configured to rise and fall across a set length, gradLength. They can be set to only have a rise, fall, or both using "trailMode" (see info below). For waves with both a rise and fall, odd numbered gradLength's work best. A spacing length can be added between the waves.

The effect is adapted to work on segment lines for 2D use. The wave colors are copied along segment lines.

This effect is the "Fast" version of Rolling Waves, 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 most Palette Utility classes.
  2. The same restrictions as (1) apply to changing the pattern, gradLength, etc.
  3. Changing the direction of the segments or segment set mid-effect may break it temporarily.
  4. This effect is not compatible with Color Modes for either the waves or the background.
  5. The effect should not be run alongside other effects on the same Segment Set due to it copying colors from LEDs.
  6. The effect will not work well with the Effect Set Fader utility.

However, as a bonus, this effect supports random colored waves, where the colors for the waves 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).

Inputs Guide & Notes:

Trail Modes:

The waves can be drawn with a lead or trailing tail or both. The gradLength sets how long the waves will be. The same gradLength will be used for each wave type, so for double waves the wave lengths will be half the gradLength.

trailMode (uint8_t):

  • 0 -- One trail facing away from the direction of motion (like a comet).
  • 1 -- Two trails, coming from both sides of the particle.
  • 2 -- One trail facing towards the direction of motion.

For example, with a gradLength of 7, the modes will produce: (The wave front is *, - are the trail, particle is moving to the right ->)

  • 0: ------*
  • 1: ---*---
  • 2: *------

Wave Fading:

By default, the waves dim quickly in a non-linear fashion. This makes the wave "head / center" brighter and standout more, which, in my opinion, looks better then just using a linear fade. You can control the linearity of the wave fades using the dimPow setting. A default of 120 is used in this effect. dimPow is borrowed from the particle based effects; you can read the dimPow notes in Particle Utils) for more.

Example Calls:

uint8_t pattern_arr = {0, 2, 1};
patternPS pattern = {pattern_arr, SIZE(pattern_arr), SIZE(pattern_arr)};
   
RollingWavesFastSL rollingWavesFast(mainSegments, pattern, cybPnkPal_PS, 0, 7, 1, 0, 100);
/*  Will do a set of waves according to the pattern, using the cybPnkPal_PS palette for colors, 
    with a blank background
    Each wave will be 7 pixels long, using both leading and trailing trails
    there will be zero spacing between the waves
    The effect will update at a 100ms */

RollingWavesFastSL rollingWavesFast(mainSegments, cybPnkPal_PS, 0, 9, 0, 2, 80);
/*  Will do a set of waves matching the cybPnkPal_PS palette with an blank background
    Each wave will be 9 pixels long, with only a trailing trail
    There will be two spaces in between each wave,
    The effect will update at 80ms */

RollingWavesFastSL rollingWavesFast(mainSegments, CRGB(CRGB::Blue), CRGB::Red, 12, 1, 3, 80);
/*  Will do a set of blue waves, with a red background
    Each wave will a length of 12, with only a leading trail
    There will be 3 background spaces between each wave
    The effect will update at 80ms
    !!If using a pre-built FastLED color for the waves,
    you need to pass it as CRGB( *color code* ) -> ex CRGB(CRGB::Blue) */

Constructor Definitions:

//Constructor with pattern
RollingWavesFastSL(SegmentSetPS &SegSet, patternPS &Pattern, palettePS &Palette, CRGB BGColor, 
                   uint8_t GradLength, uint8_t TrailMode, uint8_t Spacing, uint16_t Rate);

//Constructor with palette as pattern
RollingWavesFastSL(SegmentSetPS &SegSet, palettePS &Palette, CRGB BGColor, uint8_t GradLength, 
                   uint8_t TrailMode, uint8_t Spacing, uint16_t Rate);

//Constructor with random colors
RollingWavesFastSL(SegmentSetPS &SegSet, uint8_t NumColors, CRGB BGColor, uint8_t GradLength,
                   uint8_t TrailMode, uint8_t Spacing, uint16_t Rate);

//Constructor with a single color
//!!If using a pre-built FastLED color for the waves you need to pass it as CRGB( *color code* ) -> ex CRGB(CRGB::Blue)
RollingWavesFastSL(SegmentSetPS &SegSet, CRGB Color, CRGB BGColor, uint8_t GradLength, 
                   uint8_t TrailMode, uint8_t Spacing, 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 (optional, see constructors) -- The number of randomly chosen colors for the effect. The colors will be placed into the effect's local palette, paletteTemp for use.

  • 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. If using a pre-built FastLED color for the waves, you need to pass it as CRGB( color code ) -> ex CRGB(CRGB::Blue).

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

  • uint8_t gradLength -- The length of each wave. Can be changed later using setGradLength().

  • uint8_t trailMode -- The type of waves used (see "Trail Modes" in intro). Can be changed later using setTrailMode().

  • uint8_t spacing -- The number of background spaces between each wave.

  • 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 wave colors will be chosen. (See randMode notes in intro).

  • int8_t dimPow (default 120, min -127, max 127) -- Adjusts the rate of dimming for the wave trails (see Fading 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 setGradLength( uint8_t newGradLength ); 

    Changes the gradLength, adjusting the length of the waves.

  • void setTrailMode( uint8_t newTrailMode ); 

    Changes the trail mode used for the waves. (See Trail Mode notes in intro).

  • void update();

    Updates the effect.

Reference Vars:

  • uint8_t gradLength -- The length of the waves, set using setGradLength().

  • uint8_t trailMode -- The type of trails used for the waves, set using setTrailMode().

  • uint16_t cycleNum --Tracks what how many update cycles we've gone through, resets every totalCycleLength cycles.

  • uint16_t totalCycleLength -- Total length of all the waves of each color combined, re-calculated each update.

Flags:

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