Skip to content

feat(examples): HydroPack - dual EL-panel beat visualizer (INMP441, normalized bass detection, 50 Hz PWM, ESP32-C3 + WASM) #3681

Closed

Description

@zackees

feat(examples): HydroPack — dual EL-panel beat visualizer (INMP441 → normalized bass detection → 50 Hz PWM, ESP32-C3 + WASM)

Summary (agent restatement of the request)

Add a new example examples/hydropack/hydropack.ino — an audio-reactive dual EL-panel controller:

  • Input: INMP441 I2S MEMS microphone.
  • Normalization: the raw mic signal runs through FastLED's audio conditioning stack — DC removal / spike filter / noise gate, the INMP441 microphone frequency-response profile, and the self-normalizing MilkDrop-style Vibe analysis — so beat detection behaves identically at whisper and club volume with no manual gain calibration.
  • Selective filtering / detection: beat detection keys off the low-frequency (bass) band of the analyzed spectrum. Two detection channels with different sensitivities:
    • Inner EL panel — "sensitive": fires on subtle bass beats (low threshold just above the song's running average).
    • Outer EL panel — "loud": fires only on strong bass hits (high threshold).
  • Output — EL panels, not addressable LEDs: each panel is driven by a dedicated GPIO producing low-frequency PWM at 50 Hz (ESP32 LEDC peripheral, 12-bit duty). The 50 Hz gating requirement exists because the outputs feed EL-panel inverter/driver hardware, which must be switched slowly rather than at kHz PWM rates.
  • Targets: ESP32-C3 (real INMP441 + LEDC 50 Hz PWM) and the FastLED WASM web compiler (browser-supplied audio via fl::UIAudio; panels rendered as an inner disc + outer ring on-screen preview via ScreenMap, since the browser has no PWM). Same sketch, no forked code paths for audio.

Design

  • fl::UIAudio audio_ui("Audio Input", fl::audio::Config::CreateInmp441(WS, SD, CLK, Right)) + FastLED.add(audio_ui) — the unified WASM/hardware audio path (same pattern as examples/Sailboat/Sailboat.ino). On WASM the browser feeds the audio; on ESP32 the stored config creates the real I2S mic and applies the INMP441 mic profile.
  • Processor::onVibeLevels() provides self-normalizing bass (~1.0 = running song average) plus rising-edge bassSpike; two UI-slider thresholds split detections: inner (sensitive) default ≈ 1.05, outer (loud) default ≈ 1.6.
  • Per-panel envelope with configurable fade time; envelope drives the 50 Hz PWM duty on ESP32 and the preview LED brightness everywhere.
  • ESP32-C3 pin map: I2S WS=7, SD=8, CLK=4 (repo convention, all valid C3 GPIOs); inner EL PWM = GPIO 5; outer EL PWM = GPIO 6; optional WS2812 preview strip = GPIO 3.
  • LEDC config: 50 Hz @ 12-bit resolution (divider fits LEDC limits at 50 Hz; same class of config as hobby-servo PWM), with the Arduino core 2.x/3.x API guard pattern from src/platforms/esp/32/drivers/cled.cpp.hpp.
  • Example carries // @filter: (mem is large) so CI only compiles it on capable boards (ESP32 family, WASM), like the other audio examples.

Acceptance criteria

  • examples/hydropack/hydropack.ino exists and follows repo example conventions.
  • Compiles as a FastLED WASM sketch via the fastled CLI (fastled examples/hydropack --just-compile).
  • Compiles for ESP32-C3 (bash compile esp32c3 --examples hydropack).
  • EL panel drive is low-frequency PWM at exactly 50 Hz on ESP32.
  • Inner panel triggers on sensitive/quiet beats; outer panel only on loud beats; both thresholds adjustable live via web-UI sliders.
  • Resolved by a merged PR; this issue closes on merge.

Defaults chosen by the agent (edit here if any are wrong)

  • INMP441 wired WS=GPIO7, SD=GPIO8, SCK=GPIO4, L/R→3.3V (right channel) — matches examples/AudioInput.
  • EL panel gate pins: inner=GPIO5, outer=GPIO6 (driving an EL inverter enable / transistor gate, active high).
  • Thresholds: inner 1.05×, outer 1.6× of the self-normalized running average; fade time 0.25 s.
  • LEDC: 50 Hz, 12-bit (duty 0–4095).
  • Preview: 12-LED inner disc + 24-LED outer ring on GPIO3, compiled on all targets (renders the WASM preview; optional/harmless debug strip on hardware).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions