update impl to enable pwm ch
This commit is contained in:
parent
c212831760
commit
67d5817940
1 changed files with 7 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue