Skip to content

SineEffectModule

A 2D sine-wave effect producer. Writes colored RGB values into a EffectsLayer each loop(). Introduced in Release 1, Sprint 4; refactored in Release 1, Sprint 5 to write through a Layer instead of owning its own buffers. Release 1, Sprint 7 adds ModuleManager wiring and state persistence. Updated to full-color RGB in Release 2, Sprint 9.


What it does

On each loop() call, SineEffectModule fills a 2D pixel grid with a colored sine pattern. Each color channel responds to a different spatial axis:

R = amplitude × sin(frequency × (x + tick))
G = amplitude × sin(frequency × (y + tick) + 2π/3)
B = amplitude × sin(frequency × (x+y + tick) × 0.5 + 4π/3)

Three sine waves at 120° phase offsets produce vivid cycling rainbow colours. Every pixel is unique (R depends on x only, G on y only, B on diagonal). tick increments every loop, animating the pattern smoothly.

The module writes directly into the EffectsLayer it was wired to — it calls acquireWriteBuffer(), fills the pixels, then calls publish(). The EffectsLayer owns the double buffer and the atomic hand-off; SineEffectModule owns no pixel memory.


Controls

Parameter Source Default Description
layer setInput("layer", ...) EffectsLayer* to write into; width/height come from the layer
frequency setProps / loadState 1 Spatial + temporal frequency of the sine wave (0–8)
amplitude setProps / loadState 255 Output amplitude (0–255)
enabled auto (StatefulModule) true When false, loop() is skipped

layer is a data-flow input — wired by the ModuleManager before setup() via the "inputs" field in state/modulemanager.json. frequency and amplitude are persisted controls saved to state/<id>.json.


Platform notes

Uses sinf(). The module owns no pixel memory — allocation is in EffectsLayer. On ESP32, sinf uses the hardware FPU. On PC, Clang vectorises the inner loop automatically.


Test coverage

Sine Effect — deterministic output, zero residue after teardown, checksum propagation through layers

Also covered in Brightness Modifier (KvStore integration) and Health Checks (healthReport format, checksum consistency).

Live pipeline test: test1 — Ripples pipeline verifies the full EffectsLayer → DriverLayer chain on real hardware.

Source