add support for multi-sequence

This commit is contained in:
sigil-03 2025-11-06 09:02:08 -07:00
parent 9328087e23
commit 48b836904b
2 changed files with 24 additions and 3 deletions

View file

@ -295,6 +295,7 @@ pub struct Sequences {
pub led0: sequencer::BasicSequence<'static>, pub led0: sequencer::BasicSequence<'static>,
pub led1: sequencer::BasicSequence<'static>, pub led1: sequencer::BasicSequence<'static>,
pub led2: sequencer::BasicSequence<'static>, pub led2: sequencer::BasicSequence<'static>,
pub audio: [&'static [sequencer::SequenceEntry]; 2],
} }
// things that touch hardware // things that touch hardware
@ -345,7 +346,7 @@ impl App {
self.timers.led2_timer.reset(); self.timers.led2_timer.reset();
self.timers.led2_timer.enable(true); self.timers.led2_timer.enable(true);
self.services.synth0.set_freq(440); self.services.synth0.set_freq(1);
self.services.synth0.disable(); self.services.synth0.disable();
} }
@ -521,7 +522,15 @@ impl App {
// TODO // TODO
#[cfg(feature = "enable_print")] #[cfg(feature = "enable_print")]
println!("click"); println!("click");
self.services.sequencer.play_sequence(&crate::TEST_SEQ, 1); self.services
.sequencer
.play_sequence(self.sequences.audio[self.settings.button_sound_index], 1);
self.settings.button_sound_index += 1;
if self.settings.button_sound_index > self.sequences.audio.len() - 1 {
self.settings.button_sound_index = 0;
}
self.services.synth0.enable(); self.services.synth0.enable();
// TODO: // TODO:
@ -554,7 +563,7 @@ impl App {
// 2. dac switching // 2. dac switching
// 3. amp_en control // 3. amp_en control
// 4. write sequences // 4. write sequences
// 5. sample player start disabled // 6. multiple sequences
// //
// LED: // LED:
// //

View file

@ -50,6 +50,17 @@ pub static TEST_SEQ: [app::sequencer::SequenceEntry; 2] = [
}, },
]; ];
pub static TEST_SEQ1: [app::sequencer::SequenceEntry; 2] = [
SequenceEntry {
frequency_hz: 440,
duration_ms: 100,
},
SequenceEntry {
frequency_hz: 220,
duration_ms: 100,
},
];
#[derive(Debug)] #[derive(Debug)]
struct Flag { struct Flag {
value: bool, value: bool,
@ -288,6 +299,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
led0: BasicSequence::new(&LED0_SEQ), led0: BasicSequence::new(&LED0_SEQ),
led1: BasicSequence::new(&LED0_SEQ), led1: BasicSequence::new(&LED0_SEQ),
led2: BasicSequence::new(&LED0_SEQ), led2: BasicSequence::new(&LED0_SEQ),
audio: [&TEST_SEQ, &TEST_SEQ1],
}; };
let app_interfaces = Interfaces { pwm_core }; let app_interfaces = Interfaces { pwm_core };