Struct esp32_hal::ledc::channel::Channel

source ·
pub struct Channel<'a, S, O>
where S: TimerSpeed, O: OutputPin,
{ /* private fields */ }
Expand description

Channel struct

Implementations§

source§

impl<'a, S, O> Channel<'a, S, O>
where S: TimerSpeed, O: OutputPin,

source

pub fn new( number: Number, output_pin: impl Peripheral<P = O> + 'a ) -> Channel<'a, S, O>

Return a new channel

Trait Implementations§

source§

impl<'a, O> ChannelHW<O> for Channel<'a, HighSpeed, O>
where O: OutputPin,

Channel HW interface for HighSpeed channels

source§

fn configure_hw(&mut self) -> Result<(), Error>

Configure Channel HW except for the duty which is set via Self::set_duty_hw.

source§

fn set_duty_hw(&self, duty: u32)

Set duty in channel HW

source§

fn start_duty_fade_hw( &self, start_duty: u32, duty_inc: bool, duty_steps: u16, cycles_per_step: u16, duty_per_cycle: u16 )

Start a duty-cycle fade HW

source§

fn configure_hw_with_pin_config(&mut self, cfg: PinConfig) -> Result<(), Error>

source§

fn is_duty_fade_running_hw(&self) -> bool

Check whether a duty-cycle fade is running HW
source§

impl<'a, O> ChannelHW<O> for Channel<'a, LowSpeed, O>
where O: OutputPin,

Channel HW interface for LowSpeed channels

source§

fn configure_hw(&mut self) -> Result<(), Error>

Configure Channel HW

source§

fn set_duty_hw(&self, duty: u32)

Set duty in channel HW

source§

fn start_duty_fade_hw( &self, start_duty: u32, duty_inc: bool, duty_steps: u16, cycles_per_step: u16, duty_per_cycle: u16 )

Start a duty-cycle fade HW

source§

fn configure_hw_with_pin_config(&mut self, cfg: PinConfig) -> Result<(), Error>

source§

fn is_duty_fade_running_hw(&self) -> bool

Check whether a duty-cycle fade is running HW
source§

impl<'a, S, O> ChannelIFace<'a, S, O> for Channel<'a, S, O>
where S: TimerSpeed, O: OutputPin, Channel<'a, S, O>: ChannelHW<O>,

source§

fn configure(&mut self, config: Config<'a, S>) -> Result<(), Error>

Configure channel

source§

fn set_duty(&self, duty_pct: u8) -> Result<(), Error>

Set duty % of channel

source§

fn start_duty_fade( &self, start_duty_pct: u8, end_duty_pct: u8, duration_ms: u16 ) -> Result<(), Error>

Start a duty fade from one % to another.

There’s a constraint on the combination of timer frequency, timer PWM duty resolution (the bit count), the fade “range” (abs(start-end)), and the duration:

frequency * duration / ((1<<bit_count) * abs(start-end)) < 1024

Small percentage changes, long durations, coarse PWM resolutions (that is, low bit counts), and high timer frequencies will all be more likely to fail this requirement. If it does fail, this function will return an error Result.

source§

fn is_duty_fade_running(&self) -> bool

Check whether a duty-cycle fade is running

Auto Trait Implementations§

§

impl<'a, S, O> !RefUnwindSafe for Channel<'a, S, O>

§

impl<'a, S, O> !Send for Channel<'a, S, O>

§

impl<'a, S, O> !Sync for Channel<'a, S, O>

§

impl<'a, S, O> Unpin for Channel<'a, S, O>
where O: Unpin,

§

impl<'a, S, O> !UnwindSafe for Channel<'a, S, O>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.