Repository navigation
Live viz: the channel visualizer mirrors the real strip (3/7) - #44
Merged
Merged
Conversation
The channel visualizer approximated effects from their color/palette params —
and every premium mode is self-contained (no color params, no palette), so all
13 fell through to a hardcoded cyan gradient. Instead of per-effect viz hints
(which would re-couple effects to the UI), the device now reports its actual
output and the viz just paints it — a new effect needs zero viz code, ever.
Firmware:
- LumeController::copyVizPixels() exposes the PERCEPTUAL frame (smooth_ —
post master-brightness/power-fade/dim-to-warm, pre gamma/WS2812B/dither).
That's the screen-ready choice: leds[] holds gamma-encoded wire bytes that
an sRGB display would double-gamma. Unsynchronized read-only access from
the web task by design (a torn pixel is one frame of viz noise; P0.1's
single-writer rule untouched).
- GET /api/v2/pixels → {"count":N,"rgb":"rrggbb…"} (hex triplet per pixel,
physical order, no auth — matches the other GETs). Documented in API_V2.md.
Web UI:
- engine.fetchPixels() → Uint8Array|null (null in demo/unreachable);
documented in ENGINE_API.md.
- app.js: chained single-flight ~10 Hz poll while the tab is visible and a
channel is selected; vizTick paints the segment's real window, derives the
glow from the strip average, and shows the true stream rate instead of the
fake 42 FPS. Demo/unreachable falls back to the old procedural stand-in,
whose no-color fallback is now a warm ember drift instead of cyan.
- dev_server.js mocks the endpoint (animated warm wave) to stay faithful.
Verified: new native test proves the readback is perceptual + pre-gamma and
clamps (28/28 pass); C3 firmware builds; browser run against the dev server
shows live streaming on CH1/CH2 windows, power-off, and zero console errors.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The endpoint shipped unauthenticated on the claim that it "matches the other GET endpoints". It does not: the unauthenticated GETs are the v1 routes (/api/status, /api/config, /api/nightlight) plus effects/palettes, while every /api/v2 read — segments list and get, info, controller — calls checkAuth. This was the one v2 read that leaked live state (the strip's actual output, pollable at ~10 Hz) to anyone on the LAN once an authToken was configured. checkAuth is a pass-through when no token is set, so the default setup is unaffected. Note the stock web UI sends no token, so configuring one already disables the rest of the v2 read surface for it — this makes the viz consistent with that, rather than a hole in it. Documented in API_V2.md, including that caveat. Also corrects the heap comment, which claimed ~9 KB transient at MAX_LED_COUNT. AsyncWebServer copies the String in request->send(), so the real peak is ~15 KB (3 KB frame + ~6 KB String + ~6 KB copy) — still comfortable against the C3's ~93 KB free heap, and ~2.5 KB at the 160-LED default, but the old figure would have misled future heap budgeting.
Two cosmetic defects in the channel visualizer, both from the live-stream work earlier in this PR (the /api/v2/pixels readback commit). - Stale glow: when a live pixel stream dropped (device unreachable), the stand-in and powered-off branches of vizTick never repainted #vizGlow, and renderVisualizer only repaints it on an engine "change" event, which may never arrive with the device down. The last strip-average glow could therefore persist indefinitely behind the procedural fallback. Both branches now repaint — the stand-in from the segment swatch, powered-off to none. - FPS counter: fpsAt started at 0, so the first computed rate divided by time-since-page-load and read far too low; and `frames` was not cleared when the stream paused, understating the rate for one window after a resume. Added vizStreamIdle() to reset the counter whenever the stream isn't live, and fpsAt is now seeded on the first real frame. Verified in the browser against the mock device: page renders, no console errors, and engine.fetchPixels() parses to the exact expected length (900 bytes for 300 px) with the first triplet matching the source hex.
Two cosmetic follow-ups from review of the viz glow/FPS fix. - The frame that seeds the measuring window was also counted in it, so the first reading after every resume was ~10% high (11 frames in a 1000 ms window at 10 Hz). The seed frame now only opens the window. - The stream-idle reset zeroes the rate, so the readout showed "0" for about a second after every tab return, channel reselect or single failed fetch. It now shows "—" until the first window closes. - docs/API_V2.md: the pixels endpoint returns 401 when the token is omitted or wrong; the doc only said "omits". Verified: node --check passes; asset stamps regenerated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 12, 2026
bring42
changed the base branch from
claude/pr2-web-ui-source-of-truth
to
main
September 12, 2026 18:06
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 channel visualizer mirrors the real strip.
GET /api/v2/pixelsreturns the strip's current perceptual output (pre-gamma, so it looks right on a screen), and the UI paints it at ~10 Hz. A new effect needs zero viz code, ever./api/v2read. Its heap budget comment is corrected (~15 KB peak at 1000 LEDs).Review notes
/api/pixelsoverlays) correctly in the viz lands in part 7.Verification
Built and tested on this branch alone. This stacked state is new, so it was verified independently rather than assumed: 81/81 native tests pass, the firmware builds for
seeed_xiao_esp32c3(91.0% of the app partition), and the web UI JS passesnode --check.Also verified on hardware (XIAO ESP32-C3 + WS2812B): the endpoint streams the strip's real output.
🤖 Generated with Claude Code
The stack (merge top to bottom):