Conversation
Uses accelerometer to detect motion and plays lightsaber sounds. Features idle hum when stationary, swing sounds on movement, and clash sounds on hard swings. LEDs glow in saber color with flicker effect. Switches change saber color (green/blue/red), knob button toggles on/off with extend/retract animation. Tries sound files from /lightsaber/ on SD card (hum, swing, clash, on, off) with play_notes fallback when files aren't present. Closes #4 https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
Both switches on (SW1 + SW2) now selects purple. The four switch combos give green, blue, red, and purple. https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
- abs() on floats is undefined on ESP32, causing a null pointer dereference. Use fabsf() from <cmath> instead. - When sound files are missing, the hum loop was retrying every 30ms which could crash the audio subsystem. Now only retries after the hum interval elapses. - Add Serial debug prints for file paths being opened. https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
Allows LED extend/retract animation to run simultaneously with the sound instead of waiting for the sound to finish first. https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
philipbl
marked this pull request as draft
March 28, 2026 17:29
Instead of replaying on a fixed timer, check is_audio_playing() and only restart the hum when it has finished. This avoids hammering the SD card with repeated file opens. https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
Calling play_sound_file while audio is already playing (e.g. hum playing when a swing triggers) causes a crash. Now try_play_file always calls stop_audio() first. Removed redundant stop_audio() calls elsewhere since try_play_file handles it. https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
Only start a new swing or clash sound when swing_end_time is 0, meaning the previous swing has finished. This prevents hammering the SD card with repeated file opens during continuous motion. https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR
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
/lightsaber/(wav or mp3)TODO
/lightsaber/:hum.wavorhum.mp3— idle lightsaber hum loopswing.wavorswing.mp3— swing whoosh soundclash.wavorclash.mp3— hard hit/clash soundon.wavoron.mp3— power-on ignition soundoff.wavoroff.mp3— power-off retraction soundTest plan
/lightsaber/Closes #4
https://claude.ai/code/session_011mUJCo2axqDYJwe7GyJ1zR