Skip to content

Touch Pond effect: MPR121 capacitive touch with audio reactivity - #2

Merged
aphelps merged 10 commits into
mainfrom
touch-ripple
Jun 14, 2026
Merged

aphelps merged 10 commits into
mainfrom
touch-ripple

Conversation

@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator

Summary

  • New Touch Pond effect: touching MPR121 electrodes spawns expanding wave rings on the LED strip
  • Idle ghost replay: records last 16 touch events and replays them as dim ghost waves after ~3s of inactivity
  • Audio reactivity: optional c3 slider mixes in audio-driven waves with AGC normalization
  • Piecewise audio curve: slider midpoint (128) is the natural "sweet spot"; sqrt-compressed lower half, linear upper half
  • Wave brightness scales with audio amplitude (real touch=255, audio=80–220, ghost=~80)

Part of aphelps/WLED_dev#14 in the parent repo.

aphelps and others added 10 commits April 26, 2026 23:53
Replace fade_out() (which fades toward Color 2, not black) with a
manual color_fade(..., false) loop. Replace addPixelColor (saturates
to white under sustained touch) with blendPixelColor.

Remove proximity glow pending MPR121 setThresholds register fix
(tracked in todo.md).

Apply MPR121_IRQ_PIN build flag to irqPin default.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Replace static "illuminate and fade" with a wave pond model:
each new touch spawns up to 8 simultaneous expanding wavefronts
that radiate outward from the electrode anchor in both directions,
fading as they travel. Held electrodes keep their anchor lit.

Key changes:
- TouchWave/TouchRippleData struct in SEGENV.data (42 bytes)
- Rising-edge detection via prevTouched bitmask
- Each electrode gets a distinct palette hue (spread across 12 slots)
- c2 parameter controls trail length; c1 = MPR121 Hz

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Replace diagnostic version with full wave effect:
- Touch onset spawns an expanding wave with a 3-pixel bright
  wavefront and a comet tail filling the interior toward the origin
- Up to 8 simultaneous waves, each with palette hue from electrode index
- While held: anchor pixel pulses with beatsin8 (30 bpm, ±3 pixels)
- Background fades at configurable rate (c2 param)
- Renamed to "Touch Pond" in PROGMEM string

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Wave lifetime was 20–80 frames (too fast). Now 50–200 frames so the
default (sx=40) expands over ~6 seconds. Speed slider still goes up to
~1.7 s at maximum.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
When no real touch occurs for ~3s, the effect replays recently recorded
touches as dim ghost waves (~31% brightness), preserving the original
inter-touch timing. The history ring buffer holds up to 16 touch events;
after each full replay cycle the effect pauses 5s before looping again.
Any new real touch immediately interrupts replay and resets the sequence.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
New "Audio" slider (c3, default 0 = off) drives spontaneous waves from
audio volume. Higher mix lowers the trigger threshold, shortens the
spawn cooldown, and increases wave brightness — blending smoothly from
silent (pure touch/ghost) to fully audio-reactive. Brightness of audio
waves (ghostBri 120-220) sits between ghost replay (80) and real touches
(255), keeping the three sources visually distinct.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- AGC: instant-attack / slow-decay (~8s half-life) running peak tracks
  recent loudness so normVol is always relative to what was loud recently
- Slider curve: sqrt mapping makes half-position (~128) behave like ~70%
  of maximum sensitivity, so the useful range spans the whole slider
- Wave brightness scales with normalized amplitude (loud = bright, 80-220)
  keeping audio waves visually distinct from real touches (255) and ghosts (80)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Raise threshold (200->165), lengthen cooldown (3-20 -> 8-40 frames),
raise AGC floor (10->30). Full slider still reactive; half slider now
roughly 1-2 waves/sec during loud passages, quiet ambient no longer
triggers after peak decays.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Old sqrt curve mapped c3=50 to effective mix≈113 (the working zone).
New curve: sqrt16 on [0,128] reaches exactly 113 at audioMix=128, then
linear [128,255]→[113,255] for full upper-range control. Default stays
at c3=50 but the slider now feels natural — midpoint is the good zone.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@aphelps
aphelps merged commit c6941cf into main Jun 14, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants