minor fixes to sequence support

This commit is contained in:
sigil-03 2025-11-05 20:25:29 -07:00
parent 9e67026345
commit 9328087e23
4 changed files with 38 additions and 14 deletions

View file

@ -124,7 +124,7 @@ pub mod sequencer {
ticks_remaining: 0,
num_loops: 1,
loop_count: 0,
enabled: true,
enabled: false,
}
}
@ -132,6 +132,9 @@ pub mod sequencer {
self.sequence = sequence;
self.num_loops = num_loops;
self.loop_count = 0;
self.enabled = true;
self.index = 0;
self.ticks_remaining = 0;
}
pub fn enable(&mut self) {
@ -343,6 +346,7 @@ impl App {
self.timers.led2_timer.enable(true);
self.services.synth0.set_freq(440);
self.services.synth0.disable();
}
pub fn set_state(&mut self, state: State) {
@ -455,10 +459,10 @@ impl App {
if self.services.sample_player.need_service() {
self.services.sample_player.service();
// let out = self.services.sample_player.get_amplitude();
// self.interfaces
// .pwm_core
// .write_amplitude(ch32_hal::timer::Channel::Ch4, out as u8);
let out = self.services.sample_player.get_amplitude();
self.interfaces
.pwm_core
.write_amplitude(ch32_hal::timer::Channel::Ch4, out as u8);
}
}
}
@ -504,7 +508,7 @@ impl App {
self.timers.sp_timer.reset();
self.timers.lp_timer.reset();
}
pub fn coin_detect(&self) {
pub fn coin_detect(&mut self) {
#[cfg(feature = "enable_print")]
println!("coin detect");
self.services.sample_player.play_sample();
@ -513,10 +517,16 @@ impl App {
// Events
impl App {
fn main_button_click(&self) {
fn main_button_click(&mut self) {
// TODO
#[cfg(feature = "enable_print")]
println!("click");
self.services.sequencer.play_sequence(&crate::TEST_SEQ, 1);
self.services.synth0.enable();
// TODO:
// this is a hack to stop the coin thing from playing.
self.services.sample_player.disable();
}
fn main_button_short_press(&self) {
// TODO
@ -543,6 +553,8 @@ impl App {
// AUDIO:
// 2. dac switching
// 3. amp_en control
// 4. write sequences
// 5. sample player start disabled
//
// LED:
//
@ -559,3 +571,4 @@ impl App {
// 1. clean up edge detector
// 2. better handling for pwm scaling (brightness / volume)
// 3. better interrupt handling structs
// 4. led DynamicSequence