Skip to content

Commit 05511c7

Browse files
bwhitmanclaude
andcommitted
amyboard: clear AMY sequences on restart_sketch so factory reset stops old loops
restart_sketch only stopped the Python loop() callback; the AMY-side sequences the old sketch registered (AMYSequence drum loops etc.) kept firing. Hardware factory reset reboots the board so AMY starts fresh, but the web simulator's "Reset to factory defaults" (and any on-device sketch restart) runs in place -- the old pattern kept playing over the new sketch. Send RESET_SEQUENCER on restart (scoped to AMY sequences; not sequencer.clear(), whose seq_remove_callbacks would also kill UI TulipSequences like show_midi), and restart the AMYSequence tag counter so repeated sketch saves don't creep toward AMY's max_sequencer_tags. Verified in the web simulator: drum sketch loops, factory reset clears all sequence tags (D1 dump shows highest_tag -1) and silences the loop, and a sketch installed after reset registers tags starting from 0 again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent d1175bd commit 05511c7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tulip/shared/amyboard-py/amyboard.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,17 @@ def stop_sketch():
758758
def restart_sketch():
759759
"""Reload and restart sketch.py."""
760760
stop_sketch()
761+
# Clear the AMY-side sequences the old sketch registered (AMYSequence drum
762+
# loops etc.). Hardware factory reset reboots the board so AMY starts
763+
# fresh, but sketch restarts on-device and everything in the web simulator
764+
# happen in-place -- without this the old sketch's pattern keeps playing
765+
# over the new one. Scoped to AMY sequences only (not sequencer.clear(),
766+
# whose seq_remove_callbacks would also kill UI TulipSequences like
767+
# show_midi). With all entries gone the sequence tag counter can restart
768+
# from 0, so repeated sketch saves don't creep toward AMY's max tag.
769+
amy.send(reset=amy.RESET_SEQUENCER)
770+
if 'sequencer' in sys.modules:
771+
sys.modules['sequencer'].AMYSequenceEvent.SEQUENCE_TAG = 0
761772
if 'sketch' in sys.modules:
762773
del sys.modules['sketch']
763774
run_sketch()

0 commit comments

Comments
 (0)