![]() |
HitLib 1.3.0
VEX V5 LED animation library for PROS
|
Driver for a single WS2812B-compatible LED strip on a VEX ADI port. More...
#include <led_strand.hpp>
Classes | |
| struct | BitScrollSegment |
| One colored segment in a bitscroll pattern. More... | |
| struct | GaugeStop |
| One color on a GAUGE region's scale. More... | |
| struct | SpliceRegion |
| One independently placed override region for a custom splice mask. More... | |
| struct | MusicTrack |
| A song's intensity envelope, baked ahead of time into one 8-bit sample per frame. More... | |
Public Types | |
Types | |
| enum class | SpliceRegionAnimKind : uint8_t { OFF , SOLID , PULSE , FLASH , FLOW , RAINBOW , TWINKLE , BITSCROLL , GAUGE } |
| What a custom splice mask region shows. More... | |
| enum class | GaugeStyle : uint8_t { HEAT , BAR } |
| How a GAUGE region turns its level into pixels. More... | |
| enum class | GaugeBlend : uint8_t { LERP , STEP } |
| How a GAUGE region moves between two stops. More... | |
| using | LevelFn |
| Signature for the reader a fill meter follows, see levelSource(). | |
Public Member Functions | |
Construction | |
| LedStrand (uint8_t adiPort, uint8_t length, uint32_t refreshMs=20) | |
| Construct a strand on a standard ADI port. | |
| LedStrand (uint8_t smartPort, uint8_t adiPort, uint8_t length, uint32_t refreshMs=20) | |
| Construct a strand on an ADI expander port. | |
Initialization | |
| void | init () |
| Initialize the hardware LED object. | |
| void | tick () |
| Advance one animation frame. | |
Base Animations | |
All methods are thread-safe. Changes take effect on the next refresh tick. | |
| void | off () |
| Turn all LEDs off (set to black). | |
| void | setColor (uint32_t color) |
| Set all LEDs to a solid color. | |
| void | pulse (uint32_t color, uint8_t runLength, uint8_t speed, uint32_t bgColor=0x000000, bool invert=false, bool bounce=false) |
| Animate a run of color moving across a background. | |
| void | flash (uint32_t color, uint32_t onMs, uint32_t offMs, uint32_t bgColor=0x000000) |
| Blink the whole strip on and off. | |
| void | flow (uint32_t color1, uint32_t color2, uint8_t speed, bool invert=false, bool seamless=true) |
| Scroll a two-color gradient across the strip. | |
| void | rainbow (uint8_t speed) |
| Scroll a full HSV rainbow across the strip. | |
| void | twinkle (const std::vector< uint32_t > &colors, uint8_t densityPct=30, uint8_t fadeStep=16, uint32_t bgColor=0x000000) |
| Spawn randomly fading sparkles from a color palette. | |
| void | bitscroll (const std::vector< BitScrollSegment > &segments, uint8_t speed, bool invert=false, uint32_t bgColor=0x000000, bool bounce=false, uint8_t spacing=5, bool repeating=true) |
| Scroll a pattern of colored segments across the strip. | |
Level Meter & Music Sync | |
A meter fills the strip from one end in proportion to a 0-255 level. levelFill() decides what it looks like, and one of three things decides how full it is:
The three are mutually exclusive: whichever was set up last is what drives the meter, so handing it to a song doesn't leave a stale sensor fighting it for the same pixels. | |
| void | levelFill (uint32_t color, uint32_t color2=0x000000, bool gradient=false, uint32_t bgColor=0x000000, bool invert=false) |
| Configure the strip as a level meter, and take manual control of it. | |
| void | setLevel (uint8_t level) |
| Set how full the meter is. | |
| uint8_t | getLevel () const |
| Return the meter's current level (0-255). | |
| void | levelSource (LevelFn read, double emptyAt, double fullAt, bool wrap=false, uint8_t smoothing=0) |
| Point the meter at a live value and let it follow it on its own. | |
| void | clearLevelSource () |
| Stop following a levelSource() reader, leaving the fill where it is. | |
| bool | levelSourceActive () const |
| Whether a levelSource() reader is currently driving the meter. | |
| void | musicSync (const MusicTrack &track, uint32_t color, uint32_t color2=0x000000, bool gradient=false, uint32_t bgColor=0x000000, bool invert=false, uint8_t sensitivity=100, bool loop=false) |
| Fill the meter from a baked music envelope, and start playing it. | |
| void | musicSeek (uint32_t positionMs) |
| Jump playback to a position in the song. | |
| void | musicPause (bool paused=true) |
| Pause or resume playback, holding the meter where it is. | |
| bool | musicPlaying () const |
| Whether a MusicTrack is attached and not paused. | |
| uint32_t | musicPositionMs () const |
| Current playback position in milliseconds. | |
| void | setSensitivity (uint8_t pct) |
| Change the gain applied to envelope samples without restarting. | |
Overlay Animations | |
Write into a second buffer, shown in spliceMask()'s masked bins instead of | |
| void | overlaySetColor (uint32_t color) |
| Set the overlay buffer to a solid color. | |
| void | overlayPulse (uint32_t color, uint8_t runLength, uint8_t speed, uint32_t bgColor=0x000000) |
| Animate a moving run in the overlay buffer. | |
| void | overlayFlash (uint32_t color, uint32_t onMs, uint32_t offMs, uint32_t bgColor=0x000000) |
| Blink the overlay buffer on and off (see flash()). | |
| void | overlayFlow (uint32_t color1, uint32_t color2, uint8_t speed, bool seamless=true) |
| Scroll a gradient in the overlay buffer. | |
| void | overlayRainbow (uint8_t speed) |
| Scroll a rainbow in the overlay buffer. | |
| void | overlayTwinkle (const std::vector< uint32_t > &colors, uint8_t densityPct=30, uint8_t fadeStep=16, uint32_t bgColor=0x000000) |
| Sparkle random pixels of the overlay buffer (see twinkle()). | |
| void | overlayBitscroll (const std::vector< BitScrollSegment > &segments, uint8_t speed, bool invert=false, uint32_t bgColor=0x000000, uint8_t spacing=5, bool repeating=true) |
| Scroll a repeating bit pattern in the overlay buffer (see bitscroll()). | |
Brightness | |
| void | setBrightness (uint8_t pct) |
| Set global brightness for this strand. | |
| uint8_t | getBrightness () const |
| Return the current brightness percentage. | |
Profile System | |
| void | attachProfile (const Profile *profile) |
| Attach a Profile and reset the mode stack. | |
| void | detachProfile () |
| Detach the active profile and turn the strand off. | |
| void | activateMode (uint8_t modeIdx) |
| Push a persistent mode onto the mode stack. | |
| void | activateModeTimed (uint8_t modeIdx, uint32_t durationMs) |
| Push a timed mode onto the mode stack. | |
| void | deactivateMode (uint8_t modeIdx) |
| Remove a mode from the stack immediately. | |
Accessors | |
| uint8_t | getLength () const |
| Return the number of LEDs in this strand. | |
Static Public Attributes | |
| static constexpr uint8_t | MAX_LEDS |
Splice Mask | |
Overrides part of the strip, either as equal alternating bins sharing one overlay buffer (spliceMask) or as arbitrarily placed regions that each animate independently (spliceMaskCustom). The two are mutually exclusive, whichever was called most recently is what's active. | |
| void | spliceMask (uint8_t sections, bool invert=false, bool alternating=false, uint32_t altPeriodMs=100, uint32_t bgColor=0x000000, bool useOverlay=false) |
| Apply a splice mask that overrides alternating equal-width bins. | |
| void | spliceMaskCustom (const std::vector< SpliceRegion > ®ions) |
| Apply a splice mask made of independently placed/sized regions, each running its own animation. | |
| void | setRegionLevel (uint8_t regionIdx, uint8_t level) |
| Set how full a hand-driven GAUGE region is. | |
| void | clearSpliceMask () |
| Remove the active splice mask, whichever kind is active. | |
| static SpliceRegion | motorHeatGauge (uint8_t start, uint8_t width, LevelFn read=nullptr) |
| A GAUGE region pre-loaded with the V5 motor's own heat schedule. | |
Driver for a single WS2812B-compatible LED strip on a VEX ADI port.
LedStrand owns one hardware pros::adi::Led and drives it from a task-managed refresh loop via LedGroup. All public animation methods are thread-safe, they take effect on the next refresh tick.
Signature for the reader a fill meter follows, see levelSource().
Called once per refresh tick, from the LedGroup task rather than from your loop, and expected to just read something and return it, in whatever units that something already speaks.
A capture-less lambda converts to one of these, which is how it usually gets written:
A lambda has to actually return a double, so a reading that comes back as an integer needs saying so: [] { return (double)rot.get_angle(); }.
|
strong |
What a custom splice mask region shows.
OFF through BITSCROLL mirror the overlay*() animation vocabulary (see Overlay Animations), since each region gets a buffer built and animated the same way.
GAUGE animates from a reading rather than from a clock, making the region an independent meter. See GaugeStop and SpliceRegion's gauge fields.
| Enumerator | |
|---|---|
| OFF | |
| SOLID | |
| PULSE | |
| FLASH | |
| FLOW | |
| RAINBOW | |
| TWINKLE | |
| BITSCROLL | |
| GAUGE | |
|
strong |
How a GAUGE region turns its level into pixels.
| Enumerator | |
|---|---|
| HEAT | The whole region shows one color, picked off the scale. |
| BAR | The region fills proportionally, like a miniature levelFill(). |
|
strong |
| hitlib::LedStrand::LedStrand | ( | uint8_t | adiPort, |
| uint8_t | length, | ||
| uint32_t | refreshMs = 20 ) |
Construct a strand on a standard ADI port.
| adiPort | ADI port number (1–8). |
| length | Number of LEDs. Clamped to MAX_LEDS (64). |
| refreshMs | Refresh interval in milliseconds (default 20 ms = 50 Hz). |
| hitlib::LedStrand::LedStrand | ( | uint8_t | smartPort, |
| uint8_t | adiPort, | ||
| uint8_t | length, | ||
| uint32_t | refreshMs = 20 ) |
Construct a strand on an ADI expander port.
| smartPort | Smart port the expander is connected to (1–21). |
| adiPort | ADI port on the expander (1–8). |
| length | Number of LEDs. Clamped to MAX_LEDS (64). |
| refreshMs | Refresh interval in milliseconds (default 20 ms). |
| void hitlib::LedStrand::init | ( | ) |
Initialize the hardware LED object.
Must be called from PROS initialize() (or before the first tick). Safe to call multiple times, subsequent calls are no-ops.
| void hitlib::LedStrand::tick | ( | ) |
Advance one animation frame.
Called automatically by LedGroup's internal task. Do not call this directly.
| void hitlib::LedStrand::off | ( | ) |
Turn all LEDs off (set to black).
| void hitlib::LedStrand::setColor | ( | uint32_t | color | ) |
Set all LEDs to a solid color.
| color | 24-bit RGB color (0xRRGGBB). |
| void hitlib::LedStrand::pulse | ( | uint32_t | color, |
| uint8_t | runLength, | ||
| uint8_t | speed, | ||
| uint32_t | bgColor = 0x000000, | ||
| bool | invert = false, | ||
| bool | bounce = false ) |
Animate a run of color moving across a background.
| color | Foreground color (0xRRGGBB). |
| runLength | Number of lit pixels in the run. |
| speed | Pixels advanced per tick (1 = slowest). |
| bgColor | Background color (default black). |
| invert | Reverse the travel direction (default false). |
| bounce | Reverse direction at each end instead of wrapping (default false). |
| void hitlib::LedStrand::flash | ( | uint32_t | color, |
| uint32_t | onMs, | ||
| uint32_t | offMs, | ||
| uint32_t | bgColor = 0x000000 ) |
Blink the whole strip on and off.
Every pixel lights at once for onMs, then the whole strip shows bgColor for offMs, and the cycle repeats. On and off times are independent, so rate and duty cycle are set separately.
Durations are rounded to whole refresh ticks and clamped to a minimum of one tick, so the strand can't be asked to blink faster than its refresh interval (see the refreshMs constructor parameter).
| color | Lit color (0xRRGGBB). |
| onMs | How long the strip stays lit, in milliseconds. |
| offMs | How long the strip stays blank, in milliseconds. |
| bgColor | Background color shown while blank (default black). |
| void hitlib::LedStrand::flow | ( | uint32_t | color1, |
| uint32_t | color2, | ||
| uint8_t | speed, | ||
| bool | invert = false, | ||
| bool | seamless = true ) |
Scroll a two-color gradient across the strip.
| color1 | Start color (0xRRGGBB). |
| color2 | End color (0xRRGGBB). |
| speed | Pixels shifted per tick. |
| invert | Scroll in the reverse direction (default false). |
| seamless | Loop the gradient back to color1 instead of cutting straight from color2 to color1 at the wrap (default true). |
| void hitlib::LedStrand::rainbow | ( | uint8_t | speed | ) |
Scroll a full HSV rainbow across the strip.
| speed | Pixels shifted per tick. |
| void hitlib::LedStrand::twinkle | ( | const std::vector< uint32_t > & | colors, |
| uint8_t | densityPct = 30, | ||
| uint8_t | fadeStep = 16, | ||
| uint32_t | bgColor = 0x000000 ) |
Spawn randomly fading sparkles from a color palette.
Each sparkle fades in to full brightness, holds briefly, then fades out. New sparkles are spawned at most one per tick to stagger phase offsets.
| colors | Color palette, one color is chosen at random per sparkle. |
| densityPct | Target percentage of LEDs simultaneously lit (0–100). |
| fadeStep | Brightness step applied each tick (higher = faster fade). |
| bgColor | Background color shown on unlit pixels (default black). |
| void hitlib::LedStrand::bitscroll | ( | const std::vector< BitScrollSegment > & | segments, |
| uint8_t | speed, | ||
| bool | invert = false, | ||
| uint32_t | bgColor = 0x000000, | ||
| bool | bounce = false, | ||
| uint8_t | spacing = 5, | ||
| bool | repeating = true ) |
Scroll a pattern of colored segments across the strip.
| segments | List of BitScrollSegment descriptors defining the pattern. |
| speed | Pixels advanced per tick. |
| invert | Scroll in the reverse direction (default false). |
| bgColor | Color shown between segments and in blank areas. |
| bounce | Rock the pattern back and forth instead of wrapping. |
| spacing | Gap pixels inserted between segments (default 5). |
| repeating | Tile the pattern across the whole strip (true) or show a single copy of it (false). works for both wrapping and bounce travel. |
| void hitlib::LedStrand::levelFill | ( | uint32_t | color, |
| uint32_t | color2 = 0x000000, | ||
| bool | gradient = false, | ||
| uint32_t | bgColor = 0x000000, | ||
| bool | invert = false ) |
Configure the strip as a level meter, and take manual control of it.
Sets up the colors the meter fills with, then leaves the level itself alone, drive it with setLevel(). A meter starts empty, so nothing lights until the first setLevel() call.
With gradient the two colors are laid out across the whole strip, not across the lit part, so a given pixel is always the same color no matter how full the meter is (a VU meter that runs green at the bottom and red at the top, rather than a gradient that stretches). With gradient false only color is used.
The pixel at the edge of the fill is dimmed proportionally rather than snapping on, so a 30-LED strand shows a smooth ramp instead of 30 visible steps.
Calling this takes the meter back to manual control: any MusicTrack or levelSource() reader is detached, since either would overwrite whatever setLevel() puts there on the very next tick.
| color | Fill color, and the gradient's start color (0xRRGGBB). |
| color2 | Gradient end color. Ignored unless gradient. |
| gradient | Blend color to color2 across the strip. |
| bgColor | Color shown on the unfilled part (default black). |
| invert | Fill from the far end of the strip instead of pixel 0. |
| void hitlib::LedStrand::setLevel | ( | uint8_t | level | ) |
Set how full the meter is.
Cheap enough to call every control-loop iteration, it only stores a byte, the fill is computed at flush time. Detaches any MusicTrack or levelSource() reader, so manual updates aren't fighting one of those for the same meter.
| level | 0 = empty, 255 = the whole strip lit. |
|
inline |
Return the meter's current level (0-255).
| void hitlib::LedStrand::levelSource | ( | LevelFn | read, |
| double | emptyAt, | ||
| double | fullAt, | ||
| bool | wrap = false, | ||
| uint8_t | smoothing = 0 ) |
Point the meter at a live value and let it follow it on its own.
The strand polls read once per refresh tick and maps what comes back onto the strip, so a gauge needs no code in your control loop: set it up once (in initialize(), or in a ProfileMode's onActivate) and the bar tracks the value from then on.
Units are yours to choose, emptyAt and fullAt are given in whatever the reader returns:
Values outside the range clamp to empty or full. With wrap they cycle instead, for a continuously turning motor or a heading: 450° of a 0-360 range shows the bar a quarter full, not full.
Putting fullAt below emptyAt is allowed and reverses the meter, so a "distance remaining" bar that drains as a number climbs needs no arithmetic of its own.
This keeps the colors from the preceding levelFill(), it only changes what drives the fill, so call levelFill() first. Any MusicTrack is detached.
| read | Value to follow. nullptr clears the source, so exported code can name a hook before it is assigned. |
| emptyAt | Reading that shows an empty strip. |
| fullAt | Reading that shows a full one. |
| wrap | Cycle back to empty past fullAt instead of clamping. |
| smoothing | 0-99. How much of the previous frame's fill to keep each tick: 0 follows the value exactly, higher glides toward it, for noisy readings (motor velocity, current draw). The bar still reaches its target, over a few ticks. |
| void hitlib::LedStrand::clearLevelSource | ( | ) |
Stop following a levelSource() reader, leaving the fill where it is.
The meter stays set up and keeps its colors, it just stops moving on its own, so setLevel() takes over cleanly from here.
|
inline |
Whether a levelSource() reader is currently driving the meter.
| void hitlib::LedStrand::musicSync | ( | const MusicTrack & | track, |
| uint32_t | color, | ||
| uint32_t | color2 = 0x000000, | ||
| bool | gradient = false, | ||
| uint32_t | bgColor = 0x000000, | ||
| bool | invert = false, | ||
| uint8_t | sensitivity = 100, | ||
| bool | loop = false ) |
Fill the meter from a baked music envelope, and start playing it.
Playback is anchored to the wall clock at the moment of this call, so call it when the music starts, typically from a ProfileMode's onActivate. The strand then tracks the song on its own with no further calls, samples are interpolated between frames so the fill stays smooth even when the envelope's frame rate is coarser than refreshMs.
Colors, gradient and invert behave exactly as in levelFill(). Any levelSource() reader is detached, the song drives the meter now.
| track | Envelope to play. Must outlive the strand. |
| color | Fill color, and the gradient's start color. |
| color2 | Gradient end color. Ignored unless gradient. |
| gradient | Blend color to color2 across the strip. |
| bgColor | Color shown on the unfilled part. |
| invert | Fill from the far end of the strip. |
| sensitivity | Gain applied to every sample, as a percentage. 100 = the envelope as baked, higher makes quiet passages reach further up the strip (and clips loud ones at full), lower makes it more selective. |
| loop | Restart from the top when the song ends instead of going dark. |
| void hitlib::LedStrand::musicSeek | ( | uint32_t | positionMs | ) |
Jump playback to a position in the song.
| positionMs | Offset from the start of the track, in milliseconds. |
| void hitlib::LedStrand::musicPause | ( | bool | paused = true | ) |
Pause or resume playback, holding the meter where it is.
| paused | true to pause, false to resume. |
|
inline |
Whether a MusicTrack is attached and not paused.
| uint32_t hitlib::LedStrand::musicPositionMs | ( | ) | const |
Current playback position in milliseconds.
| void hitlib::LedStrand::setSensitivity | ( | uint8_t | pct | ) |
Change the gain applied to envelope samples without restarting.
| pct | Percentage gain, see musicSync()'s sensitivity. |
| void hitlib::LedStrand::spliceMask | ( | uint8_t | sections, |
| bool | invert = false, | ||
| bool | alternating = false, | ||
| uint32_t | altPeriodMs = 100, | ||
| uint32_t | bgColor = 0x000000, | ||
| bool | useOverlay = false ) |
Apply a splice mask that overrides alternating equal-width bins.
The strip is divided into sections + 1 equal bins. Even-indexed bins (or their complement when invert is true) show bgColor, or the overlay buffer when useOverlay is true, instead of the active base animation.
| sections | Number of divider boundaries (e.g. 1 = two halves). Pass 0 to disable. |
| invert | Swap which bins are overridden (default false). |
| alternating | Toggle invert automatically every altPeriodMs. |
| altPeriodMs | Toggle period when alternating is true (ms). |
| bgColor | Color shown in masked bins when useOverlay is false. |
| useOverlay | Show the overlay buffer in masked bins instead of bgColor. |
| void hitlib::LedStrand::spliceMaskCustom | ( | const std::vector< SpliceRegion > & | regions | ) |
Apply a splice mask made of independently placed/sized regions, each running its own animation.
Unlike spliceMask(), regions can start and end anywhere on the strip, don't alternate, and each gets a dedicated buffer generated over just its own width. So e.g. one region can rainbow-scroll while another pulses, simultaneously. Regions stay fixed until spliceMaskCustom() or clearSpliceMask() is called again. Later entries win where regions overlap.
A GAUGE region is the same idea pointed at a sensor instead of a clock: it polls its own reader every tick and colors itself off its own scale, so one strip can carry several independent meters. The strand-wide levelFill() meter is limited to one per strand.
| regions | Override regions to apply. |
| void hitlib::LedStrand::setRegionLevel | ( | uint8_t | regionIdx, |
| uint8_t | level ) |
Set how full a hand-driven GAUGE region is.
The counterpart of setLevel() for one region rather than the whole strand, for gauges whose SpliceRegion left read as nullptr. Cheap enough to call every control-loop iteration: it stores a byte, and the region repaints at flush time.
Ignored for a region that has a reader of its own, which would overwrite it on the very next tick anyway.
| regionIdx | Index into the vector last handed to spliceMaskCustom(). |
| level | 0 = the bottom of the region's scale, 255 = the top. |
|
static |
A GAUGE region pre-loaded with the V5 motor's own heat schedule.
The stops are the temperatures the motor itself changes behaviour at, so the colors mean something specific rather than being a pretty ramp:
| Reading | Color | What the motor is doing |
|---|---|---|
| 20 °C | green | cold, full power |
| 45 °C | yellow | warm, nearing the first cut |
| 55 °C | orange | current limited to 50% |
| 60 °C | red | current limited to 25% |
| 65 °C | deep red | current limited to 12.5% |
| 70 °C | magenta | shut down |
Magenta at the top is deliberate - it is the one color on the scale that cannot be mistaken for "a bit hotter than the last one".
The returned region is an ordinary SpliceRegion, so anything about it can be overridden before it is handed to spliceMaskCustom().
| start | First pixel of the segment. |
| width | Number of pixels in it. |
| read | Reader returning a motor temperature in °C. nullptr leaves the segment driven by setRegionLevel(). |
| void hitlib::LedStrand::clearSpliceMask | ( | ) |
Remove the active splice mask, whichever kind is active.
| void hitlib::LedStrand::overlaySetColor | ( | uint32_t | color | ) |
Set the overlay buffer to a solid color.
| void hitlib::LedStrand::overlayPulse | ( | uint32_t | color, |
| uint8_t | runLength, | ||
| uint8_t | speed, | ||
| uint32_t | bgColor = 0x000000 ) |
Animate a moving run in the overlay buffer.
| void hitlib::LedStrand::overlayFlash | ( | uint32_t | color, |
| uint32_t | onMs, | ||
| uint32_t | offMs, | ||
| uint32_t | bgColor = 0x000000 ) |
Blink the overlay buffer on and off (see flash()).
| void hitlib::LedStrand::overlayFlow | ( | uint32_t | color1, |
| uint32_t | color2, | ||
| uint8_t | speed, | ||
| bool | seamless = true ) |
Scroll a gradient in the overlay buffer.
| seamless | Loop the gradient back to color1 instead of cutting straight from color2 to color1 at the wrap (default true). See flow(). |
| void hitlib::LedStrand::overlayRainbow | ( | uint8_t | speed | ) |
Scroll a rainbow in the overlay buffer.
| void hitlib::LedStrand::overlayTwinkle | ( | const std::vector< uint32_t > & | colors, |
| uint8_t | densityPct = 30, | ||
| uint8_t | fadeStep = 16, | ||
| uint32_t | bgColor = 0x000000 ) |
Sparkle random pixels of the overlay buffer (see twinkle()).
| void hitlib::LedStrand::overlayBitscroll | ( | const std::vector< BitScrollSegment > & | segments, |
| uint8_t | speed, | ||
| bool | invert = false, | ||
| uint32_t | bgColor = 0x000000, | ||
| uint8_t | spacing = 5, | ||
| bool | repeating = true ) |
Scroll a repeating bit pattern in the overlay buffer (see bitscroll()).
No bounce: the overlay is a single scrolling buffer, and bouncing needs a wider master pattern to slide a window over. Use the base animation for that.
| void hitlib::LedStrand::setBrightness | ( | uint8_t | pct | ) |
Set global brightness for this strand.
Applied non-destructively at flush time, the animation buffers are not modified. Does not require the strand to be re-initialized.
| pct | Brightness percentage (0 = off, 100 = full). Clamped to [0, 100]. |
|
inline |
Return the current brightness percentage.
| void hitlib::LedStrand::attachProfile | ( | const Profile * | profile | ) |
| void hitlib::LedStrand::detachProfile | ( | ) |
Detach the active profile and turn the strand off.
| void hitlib::LedStrand::activateMode | ( | uint8_t | modeIdx | ) |
Push a persistent mode onto the mode stack.
The mode remains active until explicitly removed with deactivateMode(). Calling this for an already-active persistent mode is a no-op.
| modeIdx | Index into the attached profile's modes array. |
| void hitlib::LedStrand::activateModeTimed | ( | uint8_t | modeIdx, |
| uint32_t | durationMs ) |
Push a timed mode onto the mode stack.
The mode auto-expires after durationMs milliseconds. If the mode is already active (as a timed entry), its deadline is extended rather than creating a duplicate.
| modeIdx | Index into the attached profile's modes array. |
| durationMs | How long the mode stays active (milliseconds). |
| void hitlib::LedStrand::deactivateMode | ( | uint8_t | modeIdx | ) |
Remove a mode from the stack immediately.
| modeIdx | Index of the mode to remove. |
|
inline |
Return the number of LEDs in this strand.
|
staticconstexpr |