add support for multi-sequence
This commit is contained in:
parent
9328087e23
commit
48b836904b
2 changed files with 24 additions and 3 deletions
|
|
@ -295,6 +295,7 @@ pub struct Sequences {
|
|||
pub led0: sequencer::BasicSequence<'static>,
|
||||
pub led1: sequencer::BasicSequence<'static>,
|
||||
pub led2: sequencer::BasicSequence<'static>,
|
||||
pub audio: [&'static [sequencer::SequenceEntry]; 2],
|
||||
}
|
||||
|
||||
// things that touch hardware
|
||||
|
|
@ -345,7 +346,7 @@ impl App {
|
|||
self.timers.led2_timer.reset();
|
||||
self.timers.led2_timer.enable(true);
|
||||
|
||||
self.services.synth0.set_freq(440);
|
||||
self.services.synth0.set_freq(1);
|
||||
self.services.synth0.disable();
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +522,15 @@ impl App {
|
|||
// TODO
|
||||
#[cfg(feature = "enable_print")]
|
||||
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();
|
||||
|
||||
// TODO:
|
||||
|
|
@ -554,7 +563,7 @@ impl App {
|
|||
// 2. dac switching
|
||||
// 3. amp_en control
|
||||
// 4. write sequences
|
||||
// 5. sample player start disabled
|
||||
// 6. multiple sequences
|
||||
//
|
||||
// LED:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
struct Flag {
|
||||
value: bool,
|
||||
|
|
@ -288,6 +299,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
led0: BasicSequence::new(&LED0_SEQ),
|
||||
led1: BasicSequence::new(&LED0_SEQ),
|
||||
led2: BasicSequence::new(&LED0_SEQ),
|
||||
audio: [&TEST_SEQ, &TEST_SEQ1],
|
||||
};
|
||||
|
||||
let app_interfaces = Interfaces { pwm_core };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue