HitLib 1.3.0
VEX V5 LED animation library for PROS
Loading...
Searching...
No Matches
led_strand.hpp
Go to the documentation of this file.
1#pragma once
2#include "led_profile.hpp"
3#include "pros/adi.hpp"
4#include "pros/rtos.hpp"
5#include <cstdint>
6#include <utility>
7#include <vector>
8
13
14namespace hitlib {
15
16// ============================================================================
17
53class LedStrand {
54public:
55
56 // ========================================================================
59
64 uint32_t color;
65 uint8_t width;
66 };
67
90 using LevelFn = double (*)();
91
106
120 struct GaugeStop {
121 double at;
122 uint32_t color;
123 };
124
128 enum class GaugeStyle : uint8_t {
131 };
132
136 enum class GaugeBlend : uint8_t {
139 };
140
150 uint8_t start;
151 uint8_t width;
153 uint32_t color = 0xFFFFFF;
154 uint32_t color2 = 0x0000FF;
155 uint32_t bgColor = 0x000000;
156 uint8_t runLength = 5;
157 uint8_t speed = 1;
158 uint32_t onMs = 250;
159 uint32_t offMs = 250;
160 bool seamless = true;
163 bool invert = false;
164
165 // ---- TWINKLE only ----
166
168 std::vector<uint32_t> palette;
169 uint8_t densityPct = 30;
170 uint8_t fadeStep = 16;
171
172 // ---- BITSCROLL only ----
173
174 uint8_t segmentWidth = 3;
175 uint8_t spacing = 5;
176 bool repeating = true;
177
178 // ---- GAUGE only, ignored by every other kind ----
179
182 LevelFn read = nullptr;
183 double emptyAt = 0.0;
184 double fullAt = 100.0;
185 bool wrap = false;
186 uint8_t smoothing = 0;
192 std::vector<GaugeStop> stops;
193 };
194
217 struct MusicTrack {
218 const uint8_t* samples;
219 uint16_t frameCount;
220 uint16_t frameMs;
221 };
222
224
225 // ========================================================================
228
236 LedStrand(uint8_t adiPort, uint8_t length, uint32_t refreshMs = 20);
237
246 LedStrand(uint8_t smartPort, uint8_t adiPort, uint8_t length, uint32_t refreshMs = 20);
247
249
250 // ========================================================================
253
260 void init();
261
268 void tick();
269
271
272 // ========================================================================
278
282 void off();
283
289 void setColor(uint32_t color);
290
302 void pulse(uint32_t color, uint8_t runLength, uint8_t speed,
303 uint32_t bgColor = 0x000000, bool invert = false, bool bounce = false);
304
321 void flash(uint32_t color, uint32_t onMs, uint32_t offMs, uint32_t bgColor = 0x000000);
322
334 void flow(uint32_t color1, uint32_t color2, uint8_t speed, bool invert = false,
335 bool seamless = true);
336
342 void rainbow(uint8_t speed);
343
355 void twinkle(const std::vector<uint32_t>& colors, uint8_t densityPct = 30,
356 uint8_t fadeStep = 16, uint32_t bgColor = 0x000000);
357
371 void bitscroll(const std::vector<BitScrollSegment>& segments, uint8_t speed,
372 bool invert = false, uint32_t bgColor = 0x000000, bool bounce = false,
373 uint8_t spacing = 5, bool repeating = true);
374
376
377 // ========================================================================
394
422 void levelFill(uint32_t color, uint32_t color2 = 0x000000, bool gradient = false,
423 uint32_t bgColor = 0x000000, bool invert = false);
424
435 void setLevel(uint8_t level);
436
438 uint8_t getLevel() const { return levelValue; }
439
488 void levelSource(LevelFn read, double emptyAt, double fullAt, bool wrap = false,
489 uint8_t smoothing = 0);
490
498
500 bool levelSourceActive() const { return levelRead != nullptr; }
501
527 void musicSync(const MusicTrack& track, uint32_t color, uint32_t color2 = 0x000000,
528 bool gradient = false, uint32_t bgColor = 0x000000, bool invert = false,
529 uint8_t sensitivity = 100, bool loop = false);
530
536 void musicSeek(uint32_t positionMs);
537
543 void musicPause(bool paused = true);
544
546 bool musicPlaying() const { return musicTrack != nullptr && !musicPaused; }
547
549 uint32_t musicPositionMs() const;
550
556 void setSensitivity(uint8_t pct);
557
559
560 // ========================================================================
568
585 void spliceMask(uint8_t sections, bool invert = false, bool alternating = false,
586 uint32_t altPeriodMs = 100, uint32_t bgColor = 0x000000,
587 bool useOverlay = false);
588
618 void spliceMaskCustom(const std::vector<SpliceRegion>& regions);
619
634 void setRegionLevel(uint8_t regionIdx, uint8_t level);
635
662 static SpliceRegion motorHeatGauge(uint8_t start, uint8_t width, LevelFn read = nullptr);
663
668
670
671 // ========================================================================
677
679 void overlaySetColor(uint32_t color);
680
682 void overlayPulse(uint32_t color, uint8_t runLength, uint8_t speed,
683 uint32_t bgColor = 0x000000);
684
686 void overlayFlash(uint32_t color, uint32_t onMs, uint32_t offMs,
687 uint32_t bgColor = 0x000000);
688
695 void overlayFlow(uint32_t color1, uint32_t color2, uint8_t speed, bool seamless = true);
696
698 void overlayRainbow(uint8_t speed);
699
701 void overlayTwinkle(const std::vector<uint32_t>& colors, uint8_t densityPct = 30,
702 uint8_t fadeStep = 16, uint32_t bgColor = 0x000000);
703
711 void overlayBitscroll(const std::vector<BitScrollSegment>& segments, uint8_t speed,
712 bool invert = false, uint32_t bgColor = 0x000000,
713 uint8_t spacing = 5, bool repeating = true);
714
716
717 // ========================================================================
720
730 void setBrightness(uint8_t pct);
731
735 uint8_t getBrightness() const { return brightnessPct; }
736
738
739 // ========================================================================
742
749 void attachProfile(const Profile* profile);
750
755
764 void activateMode(uint8_t modeIdx);
765
776 void activateModeTimed(uint8_t modeIdx, uint32_t durationMs);
777
783 void deactivateMode(uint8_t modeIdx);
784
786
787 // ========================================================================
790
792 uint8_t getLength() const { return length; }
793
795
796 // ========================================================================
797 // Maximum supported LEDs per strand.
798 static constexpr uint8_t MAX_LEDS = 64;
799
800private:
801 // ---- Hardware ----
802 uint8_t adiPort;
803 uint8_t smartPort = 0;
804 uint8_t length;
805 uint32_t refreshMs;
806 pros::adi::Led* led = nullptr;
807 pros::Mutex mutex;
808
809 enum class AnimMode : uint8_t { STATIC, SHIFT, TWINKLE, FLASH, LEVEL };
810
811 // Base buffer
812 AnimMode animMode = AnimMode::STATIC;
813 int shiftStep = 0;
814 uint8_t shiftVariant = 0;
815 std::vector<uint32_t> buffer;
816
817 // Pulse bounce
818 uint8_t pulseRunLen = 0;
819 uint32_t pulseColor = 0;
820 uint32_t pulseBg = 0;
821 uint8_t pulseSpeed = 1;
822 int16_t pulseOffset = 0;
823 int8_t pulseDir = 1;
824
825 // Flash - whole-strip blink driven by tick counts rather than a shifting
826 // buffer, so the lit and blank halves can have independent durations.
827 uint32_t flashColor = 0;
828 uint32_t flashBgColor = 0;
829 uint16_t flashOnTicks = 1;
830 uint16_t flashOffTicks = 1;
831 uint16_t flashCounter = 0;
832 bool flashLit = true;
833
834 // Bitscroll bounce
835 std::vector<uint32_t> bitscrollMaster;
836 int16_t bounceScrollPos = 0;
837 int8_t bounceScrollDir = 1;
838 uint8_t bounceSpeed = 1;
839
840 // Twinkle - per-pixel fade state for one buffer. A struct rather than loose
841 // members because three different buffers animate this way: the base
842 // strand, the overlay, and any number of custom regions.
843 struct TwinkleState {
844 std::vector<uint8_t> level;
845 std::vector<uint8_t> target;
846 std::vector<uint8_t> colorIdx;
847 std::vector<uint8_t> holdTicks;
848 std::vector<uint32_t> palette;
849 uint8_t densityPct = 30;
850 uint8_t fadeStep = 16;
851 uint32_t bgColor = 0x000000;
852
853 void reset(uint8_t width, const std::vector<uint32_t>& colors, uint8_t density,
854 uint8_t fade, uint32_t bg);
855 };
856 static void advanceTwinkleInto(TwinkleState& t, std::vector<uint32_t>& buf);
857
858 TwinkleState twinkleState;
859
860 // Level meter - buffer holds the meter's colors across the whole strip and
861 // levelValue picks how much of it is revealed, so changing the level costs
862 // nothing until flush time.
863 uint8_t levelValue = 0;
864 uint32_t levelBg = 0x000000;
865 bool levelInvert = false;
866
867 // Live fill source - a reader polled once per tick plus the range that
868 // maps what it returns onto 0-255. levelPrimed exists so the first sample
869 // after levelSource() lands instantly instead of the bar crawling up to it
870 // from empty through the smoothing filter.
871 LevelFn levelRead = nullptr;
872 double levelEmptyAt = 0.0;
873 double levelFullAt = 100.0;
874 bool levelWrap = false;
875 uint8_t levelSmooth = 0;
876 bool levelPrimed = false;
877
878 // Music sync - playback is a wall-clock anchor rather than a tick counter,
879 // so a strand that misses a tick (or refreshes slowly) stays in step with
880 // the music instead of drifting behind it.
881 const MusicTrack* musicTrack = nullptr;
882 uint32_t musicAnchorMs = 0; // millis() that corresponds to position 0
883 uint32_t musicPausedAt = 0; // position held while paused
884 bool musicPaused = false;
885 bool musicLoop = false;
886 uint8_t musicSensitivity = 100;
887
888 // Splice mask
889 enum class SpliceMode : uint8_t { SPLIT, CUSTOM };
890
891 // Runtime animation state for one CUSTOM-mode region, a scaled-down
892 // version of the overlay buffer (buffer + shift step/speed), but one per
893 // region instead of shared.
894 struct SpliceRegionState {
895 uint8_t start = 0;
896 std::vector<uint32_t> buffer;
897 int shiftStep = 0;
898 uint8_t shiftSpeed = 0;
899 // Index in the vector the caller passed to spliceMaskCustom(), which
900 // is what setRegionLevel() addresses. Not the index in spliceRegions:
901 // SOLID and OFF regions never get a state, so the two disagree.
902 uint8_t userIdx = 0;
903 // GAUGE - a per-region copy of the strand-wide meter's state, so each
904 // segment follows its own reading at its own range and smoothing.
905 bool gauge = false;
906 LevelFn levelRead = nullptr;
907 double levelEmptyAt = 0.0;
908 double levelFullAt = 100.0;
909 bool levelWrap = false;
910 uint8_t levelSmooth = 0;
911 uint8_t levelValue = 0;
912 bool levelPrimed = false;
913 bool gaugeInvert = false;
914 GaugeStyle gaugeStyle = GaugeStyle::HEAT;
915 GaugeBlend gaugeBlend = GaugeBlend::LERP;
916 uint32_t gaugeBg = 0x000000;
917 // The scale, resolved onto the 0-255 axis levelValue lives on, so a
918 // tick only has to bracket a byte rather than redo the mapping.
919 std::vector<std::pair<uint8_t, uint32_t>> gaugeStops;
920 // FLASH regions blink their whole buffer on a tick timer instead of
921 // shifting it, mirroring the strand-wide flash state.
922 bool flashing = false;
923 uint32_t flashColor = 0;
924 uint32_t flashBgColor = 0;
925 uint16_t flashOnTicks = 1;
926 uint16_t flashOffTicks = 1;
927 uint16_t flashCounter = 0;
928 bool flashLit = true;
929 // TWINKLE regions repaint their buffer every tick rather than shifting
930 // it, the same way the strand-wide twinkle does.
931 bool twinkling = false;
932 TwinkleState twinkle;
933 };
934
935 bool spliceActive = false;
936 SpliceMode spliceMode = SpliceMode::SPLIT;
937 uint8_t spliceSections = 0;
938 bool spliceInvert = false;
939 bool spliceAlternating = false;
940 uint32_t spliceAltMs = 100;
941 uint32_t spliceBgColor = 0x000000;
942 bool spliceUseOverlay = false;
943 bool spliceAltPhase = false;
944 uint32_t spliceLastToggleMs = 0;
945 std::vector<bool> spliceShowAnim;
946 std::vector<uint32_t> splicePixelBg;
947 std::vector<bool> splicePixelUseOverlay;
948 std::vector<int16_t> splicePixelRegionIdx; // CUSTOM mode: index into spliceRegions, or -1
949 std::vector<SpliceRegionState> spliceRegions; // CUSTOM mode only
950 // Bumped whenever the mask is replaced. advanceSpliceRegions() releases
951 // the mutex to run a gauge's reader (user code, which may call back in),
952 // and compares this afterwards to notice that the regions it was walking
953 // are gone.
954 uint32_t spliceGeneration = 0;
955
956 // Overlay buffer
957 AnimMode overlayAnimMode = AnimMode::STATIC;
958 int overlayShiftStep = 0;
959 uint8_t overlayShiftSpeed = 0;
960 std::vector<uint32_t> overlayBuffer;
961
962 // Overlay flash - mirrors the base flash state above.
963 uint32_t overlayFlashColor = 0;
964 uint32_t overlayFlashBgColor = 0;
965 uint16_t overlayFlashOnTicks = 1;
966 uint16_t overlayFlashOffTicks = 1;
967 uint16_t overlayFlashCounter = 0;
968 bool overlayFlashLit = true;
969
970 // Overlay twinkle - mirrors the base twinkle state above.
971 TwinkleState overlayTwinkleState;
972
973 // Brightness
974 uint8_t brightnessPct = 100;
975
976 // Profile state
977 struct ModeEntry {
978 uint8_t modeIdx;
979 bool persistent;
980 uint32_t endMs;
981 };
982 const Profile* activeProfile = nullptr;
983 std::vector<ModeEntry> modeStack;
984 int16_t lastModeIdx = -1;
985
986 // Internal implementations (no lock)
987 void setColorNL(uint32_t color);
988 void pulseNL(uint32_t color, uint8_t runLen, uint8_t speed, uint32_t bg, bool invert, bool bounce);
989 void flashNL(uint32_t color, uint32_t onMs, uint32_t offMs, uint32_t bg);
990 void flowNL(uint32_t c1, uint32_t c2, uint8_t speed, bool invert, bool seamless);
991 void rainbowNL(uint8_t speed);
992 void twinkleNL(const std::vector<uint32_t>& colors, uint8_t densityPct,
993 uint8_t fadeStep, uint32_t bgColor);
994 void bitscrollNL(const std::vector<BitScrollSegment>& segments, uint8_t speed, bool invert,
995 uint32_t bgColor, bool bounce, uint8_t spacing, bool repeating);
996
997 void overlaySetColorNL(uint32_t color);
998 void overlayPulseNL(uint32_t color, uint8_t runLen, uint8_t speed, uint32_t bg);
999 void overlayFlashNL(uint32_t color, uint32_t onMs, uint32_t offMs, uint32_t bg);
1000 void overlayFlowNL(uint32_t c1, uint32_t c2, uint8_t speed, bool seamless);
1001 void overlayRainbowNL(uint8_t speed);
1002 void overlayTwinkleNL(const std::vector<uint32_t>& colors, uint8_t densityPct,
1003 uint8_t fadeStep, uint32_t bgColor);
1004 void overlayBitscrollNL(const std::vector<BitScrollSegment>& segments, uint8_t speed,
1005 bool invert, uint32_t bgColor, uint8_t spacing, bool repeating);
1006
1007 void levelFillNL(uint32_t color, uint32_t color2, bool gradient, uint32_t bg, bool invert);
1008
1009 // One tile of a bitscroll pattern: the lit runs and the gaps between them.
1010 // `contentLen` comes back as the size up to the last lit pixel, i.e.
1011 // without the trailing gap, which only separates one tile from the next.
1012 static std::vector<uint32_t> buildBitscrollUnit(const std::vector<BitScrollSegment>& segments,
1013 uint32_t bgColor, uint8_t spacing,
1014 size_t& contentLen);
1015 // Lay one tile into `buf` across `width` pixels - tiled when `repeating`,
1016 // a single copy on `bgColor` when not - and return the per-tick shift that
1017 // scrolls it. Shared by the base, overlay, and per-region bitscrolls.
1018 static uint8_t fillBitscrollBuffer(std::vector<uint32_t>& buf,
1019 const std::vector<uint32_t>& unit, size_t contentLen,
1020 uint8_t width, uint32_t bgColor, uint8_t speed,
1021 bool invert, bool repeating);
1022
1023 void advanceLevel();
1024 void advanceFlash();
1025 void advanceOverlayFlash();
1026 void advancePulseBounce();
1027 void advanceBitscrollBounce();
1028 void fillBitscrollFromMaster();
1029 void advanceSpliceAlternating(uint32_t nowMs);
1030 void advanceSpliceRegions();
1031 void paintGaugeRegion(SpliceRegionState& state);
1032 void rebuildSpliceMask();
1033
1034 void shiftBuffer();
1035 void shiftOverlayBuffer();
1036 void flushBuffer();
1037 uint32_t levelPixel(uint8_t i, uint32_t full, uint8_t frac) const;
1038 uint8_t sampleMusicNL(uint32_t positionMs) const;
1039 uint8_t mapLevelNL(double raw) const;
1040 uint8_t smoothLevelNL(uint8_t target) const;
1041
1042 // The mapping and smoothing above, with the range passed in rather than
1043 // read off the strand, so a gauge region can reuse them for its own.
1044 static uint8_t mapLevelTo(double raw, double emptyAt, double fullAt, bool wrap);
1045 static uint8_t smoothLevelTo(uint8_t target, uint8_t current, uint8_t smoothing, bool wrap);
1046 static uint32_t gaugeColorAt(const SpliceRegionState& state, uint8_t level);
1047
1048 int16_t computeEffectiveMode() const;
1049 void pruneExpired(uint32_t now);
1050 uint32_t applyBrightness(uint32_t color) const;
1051 uint16_t msToTicks(uint32_t ms) const;
1052
1053 static std::vector<uint32_t> genGradient(uint32_t c1, uint32_t c2, uint8_t len,
1054 bool seamless = false);
1055 static std::vector<uint32_t> genRainbow(uint8_t len);
1056};
1057
1058} // namespace hitlib
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 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()).
LedStrand(uint8_t smartPort, uint8_t adiPort, uint8_t length, uint32_t refreshMs=20)
Construct a strand on an ADI expander port.
void flash(uint32_t color, uint32_t onMs, uint32_t offMs, uint32_t bgColor=0x000000)
Blink the whole strip on and off.
void overlayRainbow(uint8_t speed)
Scroll a rainbow in the overlay buffer.
SpliceRegionAnimKind
What a custom splice mask region shows.
Definition led_strand.hpp:103
@ BITSCROLL
Definition led_strand.hpp:104
@ FLASH
Definition led_strand.hpp:104
@ FLOW
Definition led_strand.hpp:104
@ PULSE
Definition led_strand.hpp:104
@ TWINKLE
Definition led_strand.hpp:104
@ GAUGE
Definition led_strand.hpp:104
@ OFF
Definition led_strand.hpp:104
@ SOLID
Definition led_strand.hpp:104
@ RAINBOW
Definition led_strand.hpp:104
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 detachProfile()
Detach the active profile and turn the strand off.
void musicSeek(uint32_t positionMs)
Jump playback to a position in the song.
void spliceMaskCustom(const std::vector< SpliceRegion > &regions)
Apply a splice mask made of independently placed/sized regions, each running its own animation.
void setSensitivity(uint8_t pct)
Change the gain applied to envelope samples without restarting.
void tick()
Advance one animation frame.
LedStrand(uint8_t adiPort, uint8_t length, uint32_t refreshMs=20)
Construct a strand on a standard ADI port.
void rainbow(uint8_t speed)
Scroll a full HSV rainbow across the strip.
uint32_t musicPositionMs() const
Current playback position in milliseconds.
void overlaySetColor(uint32_t color)
Set the overlay buffer to a solid color.
void setBrightness(uint8_t pct)
Set global brightness for this strand.
void attachProfile(const Profile *profile)
Attach a Profile and reset the mode stack.
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 flow(uint32_t color1, uint32_t color2, uint8_t speed, bool invert=false, bool seamless=true)
Scroll a two-color gradient across the strip.
bool levelSourceActive() const
Whether a levelSource() reader is currently driving the meter.
Definition led_strand.hpp:500
void setLevel(uint8_t level)
Set how full the meter is.
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.
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.
void init()
Initialize the hardware LED object.
void overlayFlow(uint32_t color1, uint32_t color2, uint8_t speed, bool seamless=true)
Scroll a gradient in the overlay buffer.
void clearSpliceMask()
Remove the active splice mask, whichever kind is active.
void deactivateMode(uint8_t modeIdx)
Remove a mode from the stack immediately.
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.
void off()
Turn all LEDs off (set to black).
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 activateModeTimed(uint8_t modeIdx, uint32_t durationMs)
Push a timed mode onto the mode stack.
uint8_t getBrightness() const
Return the current brightness percentage.
Definition led_strand.hpp:735
double(*)() LevelFn
Signature for the reader a fill meter follows, see levelSource().
Definition led_strand.hpp:90
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()).
uint8_t getLength() const
Return the number of LEDs in this strand.
Definition led_strand.hpp:792
void clearLevelSource()
Stop following a levelSource() reader, leaving the fill where it is.
void activateMode(uint8_t modeIdx)
Push a persistent mode onto the mode stack.
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 setColor(uint32_t color)
Set all LEDs to a solid color.
void musicPause(bool paused=true)
Pause or resume playback, holding the meter where it is.
GaugeStyle
How a GAUGE region turns its level into pixels.
Definition led_strand.hpp:128
@ HEAT
The whole region shows one color, picked off the scale.
Definition led_strand.hpp:129
@ BAR
The region fills proportionally, like a miniature levelFill().
Definition led_strand.hpp:130
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 setRegionLevel(uint8_t regionIdx, uint8_t level)
Set how full a hand-driven GAUGE region is.
void overlayPulse(uint32_t color, uint8_t runLength, uint8_t speed, uint32_t bgColor=0x000000)
Animate a moving run in the overlay buffer.
bool musicPlaying() const
Whether a MusicTrack is attached and not paused.
Definition led_strand.hpp:546
static constexpr uint8_t MAX_LEDS
Definition led_strand.hpp:798
GaugeBlend
How a GAUGE region moves between two stops.
Definition led_strand.hpp:136
@ STEP
Hold each stop's color until the next one is reached.
Definition led_strand.hpp:138
@ LERP
Blend smoothly, so a rising reading slides between colors.
Definition led_strand.hpp:137
uint8_t getLevel() const
Return the meter's current level (0-255).
Definition led_strand.hpp:438
Profile and mode descriptors for the hitlib event-driven animation system.
Definition led_group.hpp:11
One colored segment in a bitscroll pattern.
Definition led_strand.hpp:63
uint32_t color
Segment color (0xRRGGBB).
Definition led_strand.hpp:64
uint8_t width
Width in pixels.
Definition led_strand.hpp:65
One color on a GAUGE region's scale.
Definition led_strand.hpp:120
uint32_t color
Color shown at that reading (0xRRGGBB).
Definition led_strand.hpp:122
double at
Reading this color belongs to, in the source's units.
Definition led_strand.hpp:121
A song's intensity envelope, baked ahead of time into one 8-bit sample per frame.
Definition led_strand.hpp:217
uint16_t frameCount
Number of samples in samples.
Definition led_strand.hpp:219
uint16_t frameMs
Milliseconds between consecutive samples.
Definition led_strand.hpp:220
const uint8_t * samples
Intensity 0-255, one entry per frame.
Definition led_strand.hpp:218
One independently placed override region for a custom splice mask.
Definition led_strand.hpp:149
bool wrap
Cycle past fullAt instead of pinning at it.
Definition led_strand.hpp:185
GaugeStyle style
Whole-region color, or a bar.
Definition led_strand.hpp:187
uint8_t fadeStep
Brightness step per tick, so bigger is faster.
Definition led_strand.hpp:170
uint32_t color
Foreground color (SOLID/PULSE/FLASH/FLOW/BITSCROLL).
Definition led_strand.hpp:153
uint32_t bgColor
PULSE/FLASH/TWINKLE/BITSCROLL background, and a GAUGE BAR's unlit part.
Definition led_strand.hpp:155
uint8_t speed
PULSE/FLOW/RAINBOW/BITSCROLL animation speed.
Definition led_strand.hpp:157
bool repeating
Tile the pattern across the region, or scroll one copy.
Definition led_strand.hpp:176
std::vector< GaugeStop > stops
The scale, in the reading's own units.
Definition led_strand.hpp:192
uint8_t start
First pixel index covered by this region.
Definition led_strand.hpp:150
bool invert
Reverse direction: a BITSCROLL scrolls the other way, a GAUGE BAR fills from the far end of the regio...
Definition led_strand.hpp:163
uint32_t color2
FLOW end color.
Definition led_strand.hpp:154
std::vector< uint32_t > palette
Colors sparks are drawn from. An empty palette leaves the region dark.
Definition led_strand.hpp:168
uint8_t spacing
Background pixels between runs.
Definition led_strand.hpp:175
bool seamless
FLOW only.
Definition led_strand.hpp:160
uint32_t onMs
FLASH lit duration (ms).
Definition led_strand.hpp:158
uint8_t segmentWidth
Pixels per lit run.
Definition led_strand.hpp:174
SpliceRegionAnimKind kind
What this region shows.
Definition led_strand.hpp:152
uint8_t smoothing
0-99, as in levelSource().
Definition led_strand.hpp:186
uint8_t densityPct
Share of the region lit at once (0-100).
Definition led_strand.hpp:169
double fullAt
Reading at the top of it.
Definition led_strand.hpp:184
double emptyAt
Reading at the bottom of the scale.
Definition led_strand.hpp:183
uint8_t width
Number of pixels covered.
Definition led_strand.hpp:151
uint8_t runLength
PULSE run length.
Definition led_strand.hpp:156
LevelFn read
Value this gauge follows, polled once per tick.
Definition led_strand.hpp:182
GaugeBlend blend
Blend between stops, or hold each.
Definition led_strand.hpp:188
uint32_t offMs
FLASH blank duration (ms).
Definition led_strand.hpp:159
An immutable, statically-allocated collection of ProfileMode entries.
Definition led_profile.hpp:68