Trait embedded_hal::pwm::SetDutyCycle
source · pub trait SetDutyCycle: ErrorType {
// Required methods
fn max_duty_cycle(&self) -> u16;
fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>;
// Provided methods
fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error> { ... }
fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error> { ... }
fn set_duty_cycle_fraction(
&mut self,
num: u16,
denom: u16
) -> Result<(), Self::Error> { ... }
fn set_duty_cycle_percent(&mut self, percent: u8) -> Result<(), Self::Error> { ... }
}
Expand description
Single PWM channel / pin.
Required Methods§
sourcefn max_duty_cycle(&self) -> u16
fn max_duty_cycle(&self) -> u16
Get the maximum duty cycle value.
This value corresponds to a 100% duty cycle.
sourcefn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>
fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>
Set the duty cycle to duty / max_duty
.
The caller is responsible for ensuring that the duty cycle value is less than or equal to the maximum duty cycle value,
as reported by max_duty_cycle
.
Provided Methods§
sourcefn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>
fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>
Set the duty cycle to 0%, or always inactive.
sourcefn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>
fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>
Set the duty cycle to 100%, or always active.