PreviewModule¶
A consumer Module that reads the blended output from a DriverLayer each loop() and logs a checksum of the frame. Refactored in Release 1, Sprint 5 — now reads from a DriverLayer instead of a specific SineEffectModule. Release 1, Sprint 7 adds ModuleManager wiring and state persistence.
What it does¶
On each loop() call, PreviewModule reads the latest blended Channel* from a DriverLayer (via the atomic readyChannel() pointer), computes a byte-sum checksum over all pixels, and logs it every N ticks. The varying checksum confirms that the producer pipeline is writing new frames and the blend is reaching the preview. The module knows nothing about specific effects — the DriverLayer is its only dependency.
Controls¶
| Parameter | Source | Default | Description |
|---|---|---|---|
source |
setInput("source", ...) |
— | DriverLayer* to read from |
logEveryN |
setProps / loadState |
100 | Log a checksum line every this many ticks |
source is a data-flow input — wired by the ModuleManager before setup() via the "inputs" field in state/modulemanager.json. logEveryN is a persisted control: set by setProps() and/or loadState(), saved by saveState() to state/<id>.json.
Platform notes¶
Runs on PC and ESP32 without modification. The checksum loop over 16×16 pixels takes ~0.02 ms on ESP32 (~48 K fps) and is sub-microsecond on PC.
Build and run results¶
See Release 1 — Proof of Concept for consolidated timings across all sprints.
Sprint 4 summary — PC: ~6.5 M fps own (sub-microsecond). ESP32: ~48.5 K fps own (0.021 ms avg). The checksum oscillates as the sine wave animates — confirming blended frames are reaching the preview. Sprint 5 summary — ESP32: ~47.7 K fps (unchanged; DriverLayer, not PreviewModule, owns the blend cost).
Source¶
- src/modules/PreviewModule.h
- src/modules/drivers/PreviewModule.h
- tests/test_preview_e2e.cpp
- tests/test_layers.cpp
Test coverage¶
→ Preview Pipeline — non-zero output after 50 ticks, checksum variation across ticks, fps > 0 via HTTP.
→ Health Checks — healthReport format, checksum consistency with SineEffectModule, zero-residue after teardown.