Rolling Waves (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:

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.

Supports color modes for both the main and background colors.

There is an alternate, "fast" version of this effect, Rolling Waves Fast. It has a few extra restrictions, but should run faster than this effect.

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)};
   
RollingWavesSL rollingWaves(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 */

RollingWavesSL rollingWaves(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 */

RollingWavesSL rollingWaves(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
RollingWavesSL(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
RollingWavesSL(SegmentSetPS &SegSet, palettePS &Palette, CRGB BGColor, uint8_t GradLength, 
               uint8_t TrailMode, uint8_t Spacing, uint16_t Rate);

//Constructor with random colors
RollingWavesSL(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)
RollingWavesSL(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 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.

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

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