pub trait SetDutyCycle: ErrorType {
    // Required methods
    fn get_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§

source

fn get_max_duty_cycle(&self) -> u16

Get the maximum duty cycle value.

This value corresponds to a 100% duty cycle.

source

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 get_max_duty.

Provided Methods§

source

fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>

Set the duty cycle to 0%, or always inactive.

source

fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>

Set the duty cycle to 100%, or always active.

source

fn set_duty_cycle_fraction( &mut self, num: u16, denom: u16 ) -> Result<(), Self::Error>

Set the duty cycle to num / denom.

The caller is responsible for ensuring that num is less than or equal to denom, and that denom is not zero.

source

fn set_duty_cycle_percent(&mut self, percent: u8) -> Result<(), Self::Error>

Set the duty cycle to percent / 100

The caller is responsible for ensuring that percent is less than or equal to 100.

Implementations on Foreign Types§

source§

impl<T: SetDutyCycle + ?Sized> SetDutyCycle for &mut T

source§

fn get_max_duty_cycle(&self) -> u16

source§

fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>

source§

fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>

source§

fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>

source§

fn set_duty_cycle_fraction( &mut self, num: u16, denom: u16 ) -> Result<(), Self::Error>

source§

fn set_duty_cycle_percent(&mut self, percent: u8) -> Result<(), Self::Error>

Implementors§