DemoReelEffect
Source:
DemoReelEffect.h
DemoReelEffect¶
src/light/effects/DemoReelEffect.h:32Inherits:
EffectBase
Showcase effect: cycles through other effects with a name overlay.
Author: MoonLight original, on Mark Kriegsman's FastLED DemoReel100 pattern, https://github.com/FastLED/FastLED/blob/master/examples/DemoReel100/DemoReel100.ino
Cycles through every other registered effect, advancing every interval seconds. It hosts one live child at a time, created from the registry and parented to this Layer. So the reel is an effect that swaps which effect it is over time.
Prior art: FastLED's DemoReel100 sketch, with the registry-driven, self-skipping variant ours.
Public Attributes¶
uint8_t interval = 8
: Seconds each effect plays before the reel advances.
bool shuffle = false
: Pick the next effect at random rather than in registry order.
bool randomPalette = true
: Pick a fresh palette on each cycle, which showcases the palette set.
bool showName = true
: Overlay the playing effect's name, which is what makes the reel a showcase tool.
Public Methods¶
virtual inline const char * tags() const override
: Catalog tags: the demo reel.
virtual inline Dim dimensions() const override
: D3, since the reel produces a complete frame and extrudes the child itself before the overlay.
virtual inline void defineControls() override
: Publish the cycle interval, the order, the palette and the overlay.
virtual inline void prepare() override
: List every eligible effect and stand the first one up.
virtual inline void tick() override
: Advance on the interval, run the hosted child, extrude it, then draw the name.
virtual inline void release() override
: Tear the hosted child down, then chain so this effect's own state is freed.
inline ~DemoReelEffect() override
: Delete the hosted child with the reel.
inline uint8_t eligibleCountForTest() const
: Test seam: how many effects the reel found to cycle through.
inline const char * currentTypeForTest() const
: Test seam: the type name of the effect currently playing.
inline void advanceForTest()
: Test seam: advance the reel without waiting out the interval.
More info¶
It sequences rather than composites¶
The Layer stack and its blend modes already composite, so the reel plays effects in turn. The child's own controls stay at their defaults, and the reel exposes only the cycle controls.
The child rides the normal lifecycle¶
A swap tears the child down, deletes it, and creates the next one. That child sees the Layer as its parent, so its buffer, extents and clock resolve to this target. It runs the same create, defineControls, setup, prepare and loop lifecycle a Layer gives any effect.