update impl to enable pwm ch

This commit is contained in:
sigil-03 2025-08-11 18:28:52 -06:00
parent c212831760
commit 67d5817940

View file

@ -45,10 +45,17 @@ use adpcm_pwm_dac::{interface::DacInterface, dac::Dac};
impl<T> DacInterface for SimplePwmDacPin<'_, T>
where T: GeneralInstance16bit {
fn write_amplitude(&mut self, amplitude: u8) {
if !self.pin.is_enabled(self.ch) {
self.pin.enable(self.ch);
}
let max_duty = self.pin.get_max_duty();
let dc = amplitude as u32 * max_duty / 100;
self.pin.set_duty(self.ch, dc);
}
fn disable(&mut self) {
self.pin.disable(self.ch);
}
}
fn blink(pin: AnyPin, interval_ms: u64) {