Larson Scanner (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki

See the Documentation Guide for help understanding each page section.

Effect Sample (see here for sample info) (Trails are much more visible IRL)
Scan Mode 0
Scan Mode 0 Sample Gif
Scan Mode 2
Scan Mode 2 Sample Gif

Description:

This effect is intended to be a short-hand for re-creating some classic scanner effects (Cylon, Kitt). Allows you to pick the scan type, color, the size of the scan particles, etc.

Overall, it's a wrapper for a Particles-(Seg-Line) instance that actually controls the effect. For a similar, more customizable effect, see Scanner-(Seg-Line).

While this effect does provide some pass-through functions for adjusting some things like the trail length, particle size, etc. You can access the underlying "Particle" instance, scannerInst. You may access it like: yourScannerName->scannerInst->reset();.

Likewise the effect has its own particle set. To adjust the particles you can access it via yourScannerName->particleSet. Same thing with the effect's palette.

Three scanner types are built in:

  • 0 -- Like the classic Cylon scanner, one particle with two trails moving back and forth.
  • 1 -- Like the Cylon scanner, but only using one trail.
  • 2 -- Like one of the Kitt Knight Rider scanners: two particles with single trails that move back and forth, intersecting in the center of the strip. (note that this mode uses blend, see Particles-(Seg-Line) for details).
  • 3 -- A combination of modes 1 and 2; two single trail waves running in opposite directions and one double wave. All the particles are the same size. Uses blend.

Note that because Particles-(Seg-Line) works along segment lines, this effect does too, but be aware that for scan mode 2, the colors are added together when particles meet, which may lead to some weird colors for segment sets with multiple length segments.

By default all the scanner particles will bounce back at either strip end. You can change this by calling setBounce().

Supports color modes for both the main and background colors.

Note that the Particles-(Seg-Line), all its variables, including the particles are allocated dynamically. This should not be a big deal because you a limited to the fixed scan types, but still, you must have enough memory for the particle instance. See Memory Management for more details.

Example Calls:

LarsonScannerSL larsonScanner(mainSegments, 0, CRGB::Red, 0, 2, 3, 80);
/*  Will do a scanner in mode 0 (Cylon) using red.
    The scan particle will have a eye size of 2 (the non-trail portion), and a trail length of 3
    The background is blank
    The particle moves at 80ms */

Constructor Definitions:

LarsonScannerSL(SegmentSetPS &SegSet, uint8_t ScanType, CRGB ScanColor, CRGB BgColor, uint16_t EyeSize, 
                uint8_t TrailLength, 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 scanType -- The type of scan type (see intro above). Can be changed later using the setScanType() function.

  • CRGB scanColor -- The color of the scan particles. Can be changed later using the setColor() function.

  • uint16_t eyeSize -- The size of the body of the particles (min value 1). Can be changed later using the setEyeSize() function.

  • uint8_t trailLength -- The length of the trails. Using 0 will turn off the trails for the scanner. Can be changed later using the setTrailLength() function.

  • 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. Note that the bgColor of the underlying Particles instance is bound to the effect's bgColor, so you don't need to poke the Particle effect to change it.

  • 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. Note that this is synced with all the particles and also the ParticlesSL instance.

Other Settings:

  • palettePS palette -- The palette used for the particles color This is always a single length palette since scanners are a single color. Note that this is not a pointer.

  • ParticlesSL* scannerInst -- The pointer to the effect's Particles-(Seg-Line) instance.

  • particleSetPS particleSet -- The particle set used to store the scan particles (and passed to the ParticleSL instance).

  • 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 setColorMode(uint8_t colorMode, bool bgColorMode); 

    Sets either the main or background color mode for the particles. (bgColorMode = true will set the background color mode)

  • void setColor(CRGB color); 

    Sets the scan particles color.

  • void setScanType( uint8_t newType); 

    Sets the scan mode. Note, this re-creates all the particles from scratch, and resets the effect.

  • void setTrailLength( uint8_t newTrailLength ); 

    Changes the particle trail lengths. Trails will be turned off if you set the length to 0.

  • void setEyeSize( uint16_t newEyeSize ); 

    Sets the body size of the particles.

  • void setBounce( bool newBounce ); 

    Sets the bounce property of the scanner particles. If true, the particles reverse when they reach the end of the segments rather than wrapping.

  • void reset();

    Resets all particles to the starting locations.

  • void update();

    Updates the effect.

Reference Vars:

  • uint8_t trailLength -- The length of the particle trails. Set using the setTrailLength().

  • bool bounce (default true) -- The bounce property of the scan particles. Set using the setBounce().

  • uint8_t scanType -- The current scan mode. Set using the setScanType().

  • uint16_t eyeSize -- The length of the scan particle's body (not trail). Set using the setEyeSize().

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