Repository navigation
Premium render substrate + 13 premium modes (1/7) - #42
Merged
Merged
Conversation
ROADMAP.md and copilot-instructions.md still framed Scenes as a pending 'implement-or-remove' decision, but the day-one scene half-build was already removed in #27. Reframe as a deferred future 'presets' feature on the command/EffectSpec model; no scene code exists today. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Delete every built-in effect (.cpp) ahead of rebuilding a small, premium/ organic set from scratch on the current self-declaring EffectSpec contract. Effects self-register via static EffectRegistrar, so deleting the .cpp fully removes them; 65/65 native tests still pass. The two 'rainbow' startup defaults (main.cpp, storage.cpp) now fail safe: setEffect() returns false on an unknown id and update() guards !effect->fn, so a segment with no effect renders nothing (no crash) until the new lineup lands. Empty the engine.js demo-fallback catalog to match (source only; the data/ artifact needs a deliberate sync — it has drifted behind ui-concepts). Deferred to the rebuild: tools/emulator.html + test_effects_simple.sh (dev-only, not in CI) still name old ids; registry silent-drop hardening; new lineup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Build the substrate the premium light-modes spec requires — nothing may ever
visibly step — and prove it end-to-end with Curator, the flagship 'static mode
that isn't'. Effects now render into a 16-bit linear canvas; the output stage,
run every show() (not the frame-gated tick), composes it down to the 8-bit wire:
content16 × dim-to-warm × master-brightness (perceptual)
→ one-pole IIR low-pass (pre-gamma, show-rate)
→ gamma16 (once) → WS2812B correction → error-diffusion dither → red-floor
core/render16.h: pure, FastLED-free primitives (CRGB16, Gamma16 LUT, iirStep with
guaranteed exact settle, dither16to8 + per-pixel ditherSeed). Host-tested in
test_render16 (9 cases).
Composition reconciled per review: gamma applied ONCE at the end (γ(a)·γ(b) ≠
γ(a·b)), so the old global gamma-on-brightness is gone; FastLED's own
brightness/correction/dither are neutralised (setBrightness pinned to 255,
DISABLE_DITHER) so nothing double-processes or fights the error diffusion. The
public setBrightness no longer pushes to the driver (would double-dim). IIR sits
in linear/pre-gamma space and runs at show() rate.
SegmentView backing flipped CRGB→CRGB16 (free — zero effects to migrate); its
primitives gained 8-bit convenience overloads. Segment brightness scales in 16-bit.
Curator: tunable warm white that wanders ±~100K / ±~3% on inoise16 over minutes —
the minimal exerciser of the whole pipeline at the bottom codes. Startup default
points at it (main.cpp, storage.cpp).
Diagnostics: show()-rate (Hz) + render FPS counters, logged every ~3s, since the
dither depends on a high show() rate that must be validated on-device.
test_command_bus: the 5 output-stage tests that asserted on the removed global
mechanism rewritten as per-pixel pipeline integration tests on lit content
(brightness dims monotonically, per-channel floor invariant, deeper gamma pulls
mids down, dim-to-warm lowers blue/red at the low end). test_region uses CRGB16.
74/74 native pass; C3 firmware builds (RAM 27%, flash 89%).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
On-device pass on the C3 (47-LED WS2812B) surfaced four things, all fixed: - Warmth was inverted vs its label: higher now = warmer (0 cool → 255 warm). - Warmth read far too cool (~4-5K at max): the WS2812B correction preserves blue relative to green, so nominally-warm RGB lands cooler on the strip. Pushed the Curator white anchors deliberately amber to compensate; default warmth 200. - Drift Speed did nothing perceptible across its range: removed the >>4 scaling so low stays imperceptible but high shows a visible gentle wander. - Boot flashed green then blue: the output IIR was ramping up from black through the bottom codes where every channel floors to LED_MIN_OUTPUT and a WS2812B reads green/turquoise. Now the pipeline SNAPS (no ease) until the first LIT frame, landing boot straight on warm white; and the dither seed is uniform across a pixel's channels (a per-channel offset had given blue a head-start). Known follow-up: fading brightness up from full-off can still catch a hint of the floor tint (brightness rides the same IIR); the clean fix is a pipeline-ordering change to fold in with the mode-crossfade work. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The per-channel LED_MIN_OUTPUT floor lifted green/blue to 4 in the bottom codes, which a WS2812B renders as cyan — and which directly fought dim-to-warm (that deliberately pulls G/B toward 0 to go warm). It was an 8-bit-era hack: before 16-bit error-diffusion dithering, dim channels hard-rounded to 0 and white collapsed to red, so the floor held them up. The 16-bit dither now carries the low end, so the fade-out stays warm all the way down and cuts cleanly to black — fixing the 'turquoise right before dark' the user saw on power-off. test_command_bus: the per-channel floor invariant is replaced by a warmth invariant (aggregate red >= blue across a low-brightness sweep on white content; aggregated over frames since the dither flickers channels 0/1 per-frame at the bottom). 74/74 native pass; C3 flashed + confirmed on-device. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Regenerate the served LittleFS assets from the ui-concepts/ sources via sync_web.py, bringing data/ current with #41's cache-busting + the emptied premium demo catalog. data/ had drifted behind ui-concepts for several PRs; this realigns the artifact with its source. Flashed via uploadfs and confirmed live (lume.local serving the current UI). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The spec's motion rule: anything that moves tracks position in 16-bit fixed point and splits its brightness across adjacent LEDs — never whole-LED steps. Add the primitive that delivers it: - render16.h: scale16(CRGB16, uint16) 16-bit fractional scale (the split weight), plus qadd16/addSat saturating add for additive drawing (overlapping points, trails). - SegmentView::addWuPoint(posFixed16_16, color): anti-aliased point at a 16.16 fixed-point logical position — integer part picks the near LED, the fraction splits brightness across it and its neighbour, added saturating. Writes through operator[], so it's remap-safe; a point on the far edge contributes only its in-range half (no wrap). Host-tested: integer position lands on one pixel, .5 splits ~50/50 with energy conserved, additive accumulation + edge clamping, and correct placement under a reversed view. 79/79 native pass. Infra for Silk (and any future moving mode); no mode uses it yet, so nothing visual to flash. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Switching effects snapped (only the fast output IIR softened it). The spec wants a 2-3s eased blend between modes, so add a controller-level whole-canvas crossfade: on an effect change from an already-rendering mode, freeze the outgoing frame into outgoing_ and ease the canvas from it toward the incoming live render over kModeCrossfadeMs (2s), upstream of the output pipeline (so IIR/gamma/dither still apply once on the blended result). - changeEffectWithCrossfade() wraps setEffect at the two runtime command sites (SetEffect, ApplyEffectSpec). First assignment and boot restore bypass it — they appear via the pipeline's snap-on-first-lit-frame, no blend. - Whole-canvas (not per-segment): the premium case is one mode spanning the strip; an unchanged segment blends frozen->live but for slow modes that's imperceptible. Host-tested: a white->black effect switch stays lit the frame after the change (frozen white dominates the ease) and only reaches black once the window elapses — a snap would jump in one frame. 80/80 native pass; tuned to 2s + flashed on-device. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Second premium mode (after Curator): a deep warm ember base with slightly hotter amber patches drifting on slow 2D noise (position × time), well below half brightness. Built on the substrate, so it inherits the warm low end + smoothing. On-device tuned with the user: - Drift uses a persistent phase ACCUMULATOR (scratchpad): speed sets the drift RATE, advanced each frame. The old frame*speed teleported the noise whenever speed changed (a 2s flimmer) then crawled imperceptibly — now speed changes are smooth and the drift is continuously alive even at the default. - Heat is a temperature offset (inverted to match intuition: up = hotter, a deep even ember glow; down = pale patchy embers), with the noise adding slight patch variation on top. C3 builds + flashed; drift + heat direction confirmed on-device. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Third premium mode: a single hue on a slow ~12s breath — quicker smooth rise, a slight hold at the top, then a long lazy fall. Luminance floats ~20-60% (never zero, never full), and the period drifts slightly on slow noise so it never feels metronomic. Uniform across the strip. Phase accumulator (speed = breath rate). On-device tuned: the max end steepened so top speed is a brisk ~4s breath while the default and slow end stay put. C3 builds + flashed; cadence + range confirmed on-device. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The secondary "Byrne/Euclid plate" UI served at /euclid/ is dropped to shrink the LittleFS image (device flash is tight). The main console UI (console-euclid-live, served at /) is untouched. - delete ui-concepts/euclid-live/ source dir - scripts/sync_web.py: drop sync_euclid() + its call site and /euclid/ docs - src/network/server.cpp: de-euclid the HTML-revalidate comment (routing was already generic, no euclid-specific branch existed) - scripts/dev_server.js, ui-concepts/README.md, docs/*: drop /euclid/ refs Frees ~20.3 KB gzipped (~89 KB raw) from the flashed filesystem image. data/ is a generated artifact and is intentionally not committed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-from-notes-160282
Fourth premium mode: a very dim amber-rose that breathes in SPACE, not brightness — a soft warm core swells outward from a point along the strip and recedes over ~30s, capped at ~35%. Core brightness is ~constant; what breathes is the reach. One slow tidal gesture, distinct from Breathe (luminance pulse) and Hearth (drift). Phase accumulator (speed = tide rate); Center param positions the swell. Colors/cap to be refined after a dark-room look (a bright room washes it out). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fifth premium mode: the whole strip drifts along the blackbody curve over 10+ minutes — candlelight -> warm white -> cool daylight -> back — interpolating a chain of colour-temperature anchors so it stays on the locus and never detours through green/magenta. A subtle brightness lift toward daylight gives a day rising/setting feel. Uniform; phase accumulator (Arc Speed = rate, crankable to preview the slow arc). Any-dimension. C3 builds + flashed; arc + on-locus colour confirmed on-device. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sixth premium mode: very dim cool white with broad luminance dips (clouds) that glide AND morph along the strip on low-frequency noise — motion without a rigid uniform scroll. Lives in the bottom brightness codes (the dithering showpiece). Base pushed cool/blue to survive the low-end dim-to-warm. Phase accumulator. Note: surfaced the one real tension — a future per-effect 'skip dim-to-warm' opt-out would let Nocturne stay truly cool at the floor. Deferred. C3 builds + flashed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This reverts commit 157c5a5.
…a, Opal, Silk, Fireflies)
Completes the 13-mode premium set on the substrate. All flashed + reviewed on-device.
- Mirage — interfering sine/noise layers → soft aqua-white pool caustics.
- Drift — 1D metaballs: warm blobs stretch/merge/split (lava lamp).
- Waltz — palette index-field folded by layered sines: a drifting window of
the gradient, palette-agnostic.
- Aurora — pastel teal/green/violet curtains sliding on layered inoise16.
- Opal — warm white with a faint rose/mint/lilac iridescence drifting through.
- Silk — a soft subpixel luminance swell glides the strip (long eased tail),
then a random pause before the next pass.
- Fireflies — rare soft blooms (2s in / 4s out), never two nearby, over a dim warm base.
All use the phase-accumulator pattern (speed = rate, smooth to change). Silk +
Fireflies use floating-point subpixel positions. C3 flash 90.9%, 80/80 native pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Sep 12, 2026
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical arithmetic bugs and moderate UI, persistence, crossfade, and fallback issues block approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Replaces LUME’s legacy effects with a 16-bit rendering foundation and 13 premium modes, updating rendering, persistence, UI, tests, and documentation.
Changes:
- Adds 16-bit output processing, smoothing, gamma, correction, dithering, Wu motion, and crossfades.
- Introduces premium modes and removes legacy effects.
- Refreshes UI catalogs, defaults, native tests, build configuration, and documentation.
File summaries
| File | Reviewed change |
|---|---|
ui-concepts/_engine/engine.js |
Updates development fallback and demo effect data; fallback catalog and IDs need correction. |
test/test_render16/test_render16.cpp |
Adds 16-bit render pipeline tests. |
test/test_region/test_region.cpp |
Tests 16-bit views and Wu motion. |
test/test_command_bus/test_command_bus.cpp |
Extends render and crossfade tests. |
src/visuallib/effects/wave.cpp |
Removes legacy Wave effect. |
src/visuallib/effects/waltz.cpp |
Adds Waltz mode. |
src/visuallib/effects/twinkle.cpp |
Removes legacy Twinkle effect. |
src/visuallib/effects/sparkle.cpp |
Removes legacy Sparkle effect. |
src/visuallib/effects/solstice.cpp |
Adds Solstice mode. |
src/visuallib/effects/solid.cpp |
Removes legacy Solid effect; create defaults still reference it. |
src/visuallib/effects/solace.cpp |
Adds Solace mode; low valid speeds can leave its phase frozen. |
src/visuallib/effects/sinelon.cpp |
Removes legacy Sinelon effect. |
src/visuallib/effects/silk.cpp |
Adds Silk mode. |
src/visuallib/effects/scanner.cpp |
Removes legacy Scanner effect. |
src/visuallib/effects/rainbow.cpp |
Removes legacy Rainbow effect. |
src/visuallib/effects/rain.cpp |
Removes legacy Rain effect. |
src/visuallib/effects/pulse.cpp |
Removes legacy Pulse effect. |
src/visuallib/effects/pride.cpp |
Removes legacy Pride effect. |
src/visuallib/effects/pacifica.cpp |
Removes legacy Pacifica effect. |
src/visuallib/effects/opal.cpp |
Adds Opal mode. |
src/visuallib/effects/noise.cpp |
Removes legacy Noise effect. |
src/visuallib/effects/nocturne.cpp |
Adds Nocturne mode; noise scaling can overflow. |
src/visuallib/effects/mirage.cpp |
Adds Mirage mode. |
src/visuallib/effects/meteor.cpp |
Removes legacy Meteor effect. |
src/visuallib/effects/hearth.cpp |
Adds Hearth mode; noise scaling can overflow. |
src/visuallib/effects/gradient.cpp |
Removes legacy Gradient effect. |
src/visuallib/effects/fireup.cpp |
Removes legacy Fire Up effect. |
src/visuallib/effects/fireflies.cpp |
Adds Fireflies mode. |
src/visuallib/effects/fire.cpp |
Removes legacy Fire effect. |
src/visuallib/effects/drift.cpp |
Adds Drift mode. |
src/visuallib/effects/curator.cpp |
Adds Curator mode; speed edits can cause phase jumps. |
src/visuallib/effects/comet.cpp |
Removes legacy Comet effect. |
src/visuallib/effects/colorwaves.cpp |
Removes legacy Color Waves effect. |
src/visuallib/effects/candle.cpp |
Removes legacy Candle effect. |
src/visuallib/effects/breathe.cpp |
Reworks Breathe mode. |
src/visuallib/effects/aurora.cpp |
Adds Aurora mode. |
src/storage.cpp |
Updates persisted defaults; legacy IDs require migration or validation. |
src/main.cpp |
Uses the premium startup default; restore failures need handling. |
src/core/segment.h |
Updates segment state for 16-bit rendering. |
src/core/segment_view.h |
Adds 16-bit canvas and Wu primitives. |
src/core/render16.h |
Defines the 16-bit substrate; blending arithmetic and pipeline documentation need correction. |
src/core/fastled_output.h |
Prevents duplicate FastLED shaping. |
src/core/controller.h |
Adds render buffers and pipeline state. |
src/core/controller.cpp |
Integrates output processing and crossfades; blending affects unrelated segments. |
platformio.ini |
Enables native render tests. |
docs/ROADMAP.md |
Corrects Scenes documentation. |
data/index.html |
Updates the primary UI shell. |
data/euclid/index.html |
Updates the alternate UI shell. |
data/euclid/app.js |
Updates alternate UI configuration handling. |
data/assets/engine.js |
Updates shared fallback and effect catalog; unreachable devices receive no usable catalog. |
data/assets/app.js |
Adds controls and channel UI; settings control is inaccessible by keyboard and defaults reference solid. |
data/assets/app.css |
Adds theme, module, and channel styling. |
.github/copilot-instructions.md |
Updates repository guidance. |
Review details
Suppressed comments (4)
src/core/render16.h:25
- This description is stale and contradicts the new pipeline:
renderOutput16()applies WS2812B correction before the 16→8 dither, and the oldLED_MIN_OUTPUTfloor is explicitly removed. Please update the comment so future changes do not reintroduce the retired 8-bit floor or assume correction happens in the driver.
// WS2812B colour correction and the LED_MIN_OUTPUT red-floor — stay in the
// output driver, downstream of the 8-bit values this produces.
src/storage.cpp:159
- Changing the missing-key default does not migrate existing devices:
Preferences::getStringreturns the already-stored legacy ID (for examplerainbow) unchanged. The boot path then callssetEffect()without checking its false result, so an old persisted layout or last-effect value can leave a segment with no effect and a black strip; validate/migrate persisted IDs to a registered premium effect during restore.
effectId = prefs.getString("lasteffect", "curator"); // Default to curator (premium)
src/visuallib/effects/solace.cpp:58
- For the schema's valid speed range 1–7,
(speed * 5) / 8truncates to zero, sos->phasenever advances and Solace is permanently frozen at those settings. Ensure the computed step has a minimum of one.
src/visuallib/effects/solid.cpp:1 - Removing this effect ID without updating the shipped UI's add-channel defaults leaves both create paths sending
effect: "solid". The API still accepts the create but ignores the unknown effect, so newly added segments have no renderer; migrate those callers to a registered premium ID such ascuratorin the same change.
- Files reviewed: 53/53 changed files
- Comments generated: 9
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| // Linear interpolate two 16-bit channels; frac 0 → a, 65535 → b. | ||
| inline uint16_t lerp16(uint16_t a, uint16_t b, uint16_t frac) { | ||
| return (int32_t)a + (((int32_t)b - (int32_t)a) * (int32_t)frac >> 16); |
| // inoise16 doesn't use the full 0..65535 range — it clusters roughly in | ||
| // [~12000, ~53000]. Stretch that band to 0..65535 so patches have real contrast. | ||
| static inline uint16_t stretchNoise(uint32_t n) { | ||
| int32_t v = ((int32_t)n - 12000) * 65535 / 41000; |
|
|
||
| // inoise16 clusters ~[12000,53000]; stretch to 0..65535 for real cloud contrast. | ||
| static inline uint16_t stretchNoise(uint32_t n) { | ||
| int32_t v = ((int32_t)n - 12000) * 65535 / 41000; |
Comment on lines
+269
to
+271
| <span class="tab-cog" role="button" tabindex="-1" aria-label="Channel settings"> | ||
| <svg viewBox="0 0 24 24" fill="currentColor"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg> | ||
| </span> |
Comment on lines
+60
to
+64
| // Demo/fallback effect catalog (used only when no device answers GET | ||
| // /api/v2/effects). Emptied during the premium-modes rebuild — the old 20 | ||
| // built-ins were purged; this repopulates mode-by-mode as each premium mode | ||
| // (Curator, Hearth, Breathe, …) lands. The live list always comes from the device. | ||
| var FALLBACK_EFFECTS = []; |
Comment on lines
+188
to
+192
| if (modeCrossfade_.isActive()) { | ||
| uint16_t frac = (uint16_t)(modeCrossfade_.eased(now) * 65535.0f); | ||
| for (uint16_t i = 0; i < ledCount; i++) { | ||
| canvas_[i] = blend16(outgoing_[i], canvas_[i], frac); | ||
| } |
Comment on lines
219
to
+223
| if (storage.loadLastEffect(lastEffect) && lastEffect.length() > 0) { | ||
| mainSegment->setEffect(lastEffect.c_str()); | ||
| LOG_INFO(LogTag::LED, "Restored last effect: %s", lastEffect.c_str()); | ||
| } else { | ||
| mainSegment->setEffect("rainbow"); | ||
| LOG_INFO(LogTag::LED, "No saved effect, using default: rainbow"); | ||
| mainSegment->setEffect("curator"); |
| // Slow noise phase. Two decorrelated samples drive temperature and brightness; | ||
| // `speed` sets how fast the phase advances (low = imperceptible over minutes, | ||
| // high = a soft wander over a few seconds). | ||
| uint32_t phase = frame * (uint32_t)speed; |
Comment on lines
+60
to
+64
| // Demo/fallback effect catalog (used only when no device answers GET | ||
| // /api/v2/effects). Emptied during the premium-modes rebuild — the old 20 | ||
| // built-ins were purged; this repopulates mode-by-mode as each premium mode | ||
| // (Curator, Hearth, Breathe, …) lands. The live list always comes from the device. | ||
| var FALLBACK_EFFECTS = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The premium-modes chapter: the old 20 built-in effects are purged and rebuilt on a new rendering foundation.
src/core/render16.h,renderOutput16()incontroller.cpp): effects draw into a 16-bit canvas; the output stage applies master brightness, dim-to-warm, a per-pixel one-pole IIR, gamma, WS2812B correction and error-diffusion dither, then descends to 8-bit. The old 8-bit low-end floor is dropped (warm fade-out, no cyan)..cpp: Curator, Hearth, Breathe, Solace, Solstice, Nocturne, Mirage, Drift, Waltz, Aurora, Opal, Silk, Fireflies.Review notes
render16.h+renderOutput16(); each effect file stands alone.lerp16()signed-overflow UB, and the crossfade blending the whole canvas instead of the changed segment.Verification
Built and tested on this branch alone. This stacked state is new, so it was verified independently rather than assumed: 80/80 native tests pass, the firmware builds for
seeed_xiao_esp32c3(90.9% of the app partition), and the web UI JS passesnode --check.🤖 Generated with Claude Code
The stack (merge top to bottom):