Add chaotic pendulum color animation mode for D4K-3ch#150
Open
GlassOnTin wants to merge 6 commits intoToyKeeper:trunkfrom
Open
Add chaotic pendulum color animation mode for D4K-3ch#150GlassOnTin wants to merge 6 commits intoToyKeeper:trunkfrom
GlassOnTin wants to merge 6 commits intoToyKeeper:trunkfrom
Conversation
Implements a new channel mode (CM_CHAOS) that creates organic, non-repeating color animations using driven coupled oscillator physics. Features: - Driven double pendulum dynamics for sustained chaotic motion - Hue oscillator explores full color wheel (0-255) - Saturation oscillator keeps colors centered around white (sat 60-220) - User-adjustable energy/speed via 3H (click-click-hold) - Continuous animation via gradual_tick integration Physics model: - Two coupled oscillators with periodic driving force - Triangle wave approximation for sine (reuses existing function) - Very light damping (1/512) to prevent runaway - Coupling term creates sensitive dependence on initial conditions Documentation includes: - Technical deep-dive (docs/chaotic-pendulum-science.md) - Phase space diagrams showing chaotic attractor - Color trajectory visualizations - Time series analysis - Energy parameter comparison - Python simulation tool matching firmware algorithm
Repositioned Hue and Saturation output labels to avoid overlapping with the equation box at the bottom of the diagram.
The chaos mode was only animating during brightness ramping because gradual_tick() is only called when there's a brightness difference. Fix by: - Adding USE_CHAOS_MODE flag to D4K-3ch hwdef.h - Hooking into EV_tick in ramp-mode.c to call set_level() continuously when in chaos mode, which advances the chaos physics each frame - Making gradual_tick_chaos() always return false (not strictly needed now but keeps the function semantically correct for animation)
Energy parameter tuning: - Scale range narrowed to 6-11 (was 4-19) to avoid too-slow boring oscillations and too-fast white blur - Drive amplitude narrowed to 40-56 (was 32-63) for consistent dynamics Saturation mapping: - Added sqrt-like expansion to spend more time at vivid saturated colors and less time near white - Range expanded to 40-240 (was 60-220) 3H adjustment visual feedback: - Brightness now shows energy level during adjustment (dim=slow, bright=fast) - Brief blink on wrap-around (255->0 or 0->255) - Original brightness restored on release Updated simulation and documentation to match firmware changes.
The default omega1=200 and omega2=150 caused the system to get trapped in half the phase space (hue 0-128 only). Increasing to omega1=1000 and omega2=800 ensures the chaotic attractor explores the full hue range (0-255) from startup. Regenerated all visualization diagrams showing full color coverage.
omega1=1000 still resulted in the attractor being biased toward one half of the hue range. omega1=1500 was found empirically to give good coverage across all four quadrants of the color wheel. Regenerated visualizations now show full RGB coverage in the color trajectory polar plot.
Contributor
|
Sounds awesome. Can you share a video of the effect? Unfortunately I don't have a three channel light. |
Author
Here's a minute of colour therapy, though I chose to reduce the pendulum energy (3H) after a minute. PXL_20251212_141409159.mp4 |
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.
Summary
Adds a new channel mode (CM_CHAOS) for the Emisar D4K-3ch that creates organic, non-repeating color animations using driven coupled oscillator physics - a simplified model of a double pendulum.
Key features:
Files changed:
hw/hank/emisar-d4k-3ch/hwdef.h- Added CM_CHAOS enum and USE_CHAOS_MODE flaghw/hank/emisar-d4k-3ch/hwdef.c- Chaos physics implementation, 3H handler with visual feedbackui/anduril/ramp-mode.c- Hook for continuous animation in EV_tick handlerdocs/chaotic-pendulum-science.md- Technical documentation with physics explanationdocs/images/chaos-*.png- 6 visualization diagrams from simulationtools/chaos_simulation.py- Python simulation matching firmware exactlyUser controls:
Test plan