Pacifica Hue (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki

See the Documentation Guide for help understanding each page section.

Effect Sample (see here for sample info) (Shown cycling through hues)
Effect Sample Gif

Description:

An effect based on the pacific code here. This is an alternate version of the original Pacifica, that I've adapted to work in 2D, while also allowing you to change the overall color of the waves. This produces uniform waves that shift across the whole segment set, which shift between a colors in a limited hue range.

Recommend brightness > 80 and rate > 20ms. For low brightness values I recommend turning off dithering using FastLED.setDither(0).

Like the original, the effect is a bit computationally heavy.

Inputs Guide & Notes:

The main input for the effect is the hue, which sets a base color using the HSV rainbow. The effect's palettes then form their colors around that base color. This produces a nice gentle wave effect like the original effect, but tinted in a specific color. However, it does mean that you cannot have colors from opposite ends of the spectrum together (like green and purple for example) (try the Lava or noise effects for instead).

Some hue ranges are:

  • Red/Orange: 240 to ~10.
  • Orange/Yellow: 10 to ~40.
  • Yellow/Green: 40 to ~90.
  • Green/Blue: 90 to ~150.
  • Blue/Purple: 150 to ~180.
  • Purple/Red: 180 to 240.

By default the hue is set to 130, which closely matches the colors from the original effect.

You can also set the hue to cycle through colors over time at hueRate (ms) (see constructors below). A hue rate of 0 will stop the hue cycle. The hue is updated as part of the effect, so the hueRate should be slower than the effect's update rate. Note that the hueRate is a pointer (like the overall effect rate), so you can bind it to an external variable if wanted. By default hueRate is bound the effect's local variable, hueRateOrig. See common vars rate entry for more.

Note, to get the effect to work with multiple colors, the original Pacifica palettes needed to be heavily modified. You can find the palettes in "PacificaHuePal.h" in the code, however I will not be going over them here because you don't need specific knowledge of them for the effect.

In the original code, waves are shifted towards white where they meet using the function addWhiteCaps(). I've made this function optional (default off) for a few reasons:

  1. In the code, pixel colors are added to one another. For a 1D line or a rectangular matrix this is fine, because each pixel is part of a single Segment Line, so the addWhiteCaps() is needed to form the wave peaks. However for an uneven segment set with different length segments, a single pixel may exist in multiple lines at once. In this case, the code is already forming the wave peaks by adding the colors of the overlapping pixels multiple times, making addWhiteCaps() overkill.

  2. addWhiteCaps() was specifically written for the original blue-green colors of the original Pacifica effect. I have been unable to adapt it to work well with all hues. So in some cases, it's best to leave it off.

In addition to the above, I've also allowed you to cap the white light level of the pixels using thresholdMax as part of addWhiteCaps().

Example Calls:

PacificaHueSL pacificaHue(mainSegments, 40);
/* That's it, updates at 40ms
   (addWhiteCaps is default false, and the hue will default to 130 to match the original Pacifica colors) */

PacificaHueSL pacificaHue(mainSegments, true, 130, 40);
/*  Sets addWhiteCaps to true and the hue to 130, updates at 40ms */

PacificaHueSL pacificaHue(mainSegments, true, 50, 500, 40);
/*  Sets addWhiteCaps to true, with the hue starting at 50 and incrementing every 500ms
    The effect updates at 40ms */

Constructor Definitions:

//Normal constructor (does default Pacifica)
PacificaHueSL(SegmentSetPS &SegSet, uint16_t Rate);

//Constructor with addWhiteCaps setting
PacificaHueSL(SegmentSetPS &SegSet, bool AddWhiteCaps, uint8_t Hue, uint16_t Rate);

//Constructor with addWhiteCaps and hue rate settings
//The hue will be the initial hue of the palette
PacificaHueSL(SegmentSetPS &SegSet, bool AddWhiteCaps, uint8_t Hue, uint16_t HueRate, uint16_t Rate);

Constructor Inputs:

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

  • bool addWhiteCaps (optional, default false) -- If true, the addWhiteCaps() function will be called as part of the update cycle (see Inputs Guide Notes).

  • bool addWhiteCaps (optional, default false) -- If true, the addWhiteCaps() function will be called as part of the update cycle (see Inputs Guide Notes).

  • uint8_t hue (optional, default 130, max 255) -- The hue used in the effect (see Inputs Guide Notes). Use setHue() to change later.

  • uint16_t* hueRate (optional, default 0) -- How quickly the hue shifts (ms). By default it's bound the effect's local variable, hueRateOrig. (see Inputs Guide Notes).

  • 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 thresholdMax (default 230) -- Caps the white cap light level to prevent pixels from getting too white as part of the addWhiteCaps() function. Lower -> lower light cap.

  • PacificaHuePalPS PacificaPalette -- The Pacifica Hue Palette instance. You shouldn't need to access this.

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

    Changes the hue value to change the effect colors.

  • void update();

    Updates the effect.

Reference Vars:

  • uint8_t hue -- The current hue setting, use setHue() to change.

  • uint8_t numSteps -- How many steps there are per color gradient. Is set automatically, so you shouldn't need to change this.

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