convert app to tick servicing
This commit is contained in:
parent
008bf334a4
commit
791d5db4c8
3 changed files with 460 additions and 269 deletions
|
|
@ -26,31 +26,20 @@ impl<'a, T: GeneralInstance16bit> AppSynthesizers<'a, T> {
|
|||
self.square.tick();
|
||||
if self.square.has_new_output() {
|
||||
let out = self.square.get_output();
|
||||
// println!("OUTPUT: {out}");
|
||||
|
||||
// println!("new out");
|
||||
self.output.write_amplitude(
|
||||
ch32_hal::timer::Channel::Ch4,
|
||||
// TODO: set level here. or maybe use dac?
|
||||
out / 2,
|
||||
// (out as f32 * (u8::MAX as f32 / u32::MAX as f32)) as u8,
|
||||
);
|
||||
}
|
||||
|
||||
// println!("{}{}", self.square.counter, self.square.has_new_output());
|
||||
}
|
||||
|
||||
pub fn service(&mut self) {
|
||||
// println!("HERE");
|
||||
if self.square.has_new_output() {
|
||||
let out = self.square.get_output();
|
||||
// println!("OUTPUT: {out}");
|
||||
|
||||
// println!("new out");
|
||||
self.output.write_amplitude(
|
||||
ch32_hal::timer::Channel::Ch4,
|
||||
out / 2,
|
||||
// (out as f32 * (u8::MAX as f32 / u32::MAX as f32)) as u8,
|
||||
);
|
||||
self.output
|
||||
.write_amplitude(ch32_hal::timer::Channel::Ch4, out / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue