esp_hal::ledc::channel

Struct Channel

Source
pub struct Channel<'a, S: TimerSpeed> { /* private fields */ }
Available on crate feature unstable only.
Expand description

Channel struct

Implementations§

Source§

impl<'a, S: TimerSpeed> Channel<'a, S>

Source

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

Return a new channel

Trait Implementations§

Source§

impl<S> ChannelHW for Channel<'_, S>
where S: TimerSpeed,

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>

Configure the hardware for the channel with a specific pin configuration.
Source§

fn is_duty_fade_running_hw(&self) -> bool

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

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

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
Source§

impl<S: TimerSpeed> ErrorType for Channel<'_, S>

Source§

type Error = Error

Error type
Source§

impl<'a, S: TimerSpeed> SetDutyCycle for Channel<'a, S>
where Channel<'a, S>: ChannelHW,

Source§

fn max_duty_cycle(&self) -> u16

Get the maximum duty cycle value. Read more
Source§

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

Set the duty cycle to duty / max_duty. Read more
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. Read more
Source§

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

Set the duty cycle to percent / 100 Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for Channel<'a, S>

§

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

§

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

§

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

§

impl<'a, S> Unpin for Channel<'a, S>

§

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

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.