Ws2812Esp32RmtDriverBuilder

Struct Ws2812Esp32RmtDriverBuilder 

Source
pub struct Ws2812Esp32RmtDriverBuilder<'d> { /* private fields */ }
Expand description

Builder for Ws2812Esp32RmtDriver.

§Examples


// WS2812B timing parameters.
const WS2812_T0H_NS: Duration = Duration::from_nanos(400);
const WS2812_T0L_NS: Duration = Duration::from_nanos(850);
const WS2812_T1H_NS: Duration = Duration::from_nanos(800);
const WS2812_T1L_NS: Duration = Duration::from_nanos(450);

let driver_config = TransmitConfig::new()
    .clock_divider(1); // Required parameter.
let tx_driver = TxRmtDriver::new(channel, led_pin, &driver_config).unwrap();
let driver = Ws2812Esp32RmtDriverBuilder::new_with_rmt_driver(tx_driver).unwrap()
   .encoder_duration(&WS2812_T0H_NS, &WS2812_T0L_NS, &WS2812_T1H_NS, &WS2812_T1L_NS).unwrap()
   .build().unwrap();

Implementations§

Source§

impl<'d> Ws2812Esp32RmtDriverBuilder<'d>

Source

pub fn new<C: RmtChannel>( channel: impl Peripheral<P = C> + 'd, pin: impl Peripheral<P = impl OutputPin> + 'd, ) -> Result<Self, Ws2812Esp32RmtDriverError>

Creates a new Ws2812Esp32RmtDriverBuilder.

Source

pub fn new_with_rmt_driver( tx: TxRmtDriver<'d>, ) -> Result<Self, Ws2812Esp32RmtDriverError>

Creates a new Ws2812Esp32RmtDriverBuilder with TxRmtDriver.

Source

pub fn encoder_duration( self, t0h: &Duration, t0l: &Duration, t1h: &Duration, t1l: &Duration, ) -> Result<Self, Ws2812Esp32RmtDriverError>

Sets the encoder duration times.

§Arguments
  • clock_hz - The clock frequency.
  • t0h - T0H duration time (0 code, high voltage time)
  • t0l - T0L duration time (0 code, low voltage time)
  • t1h - T1H duration time (1 code, high voltage time)
  • t1l - T1L duration time (1 code, low voltage time)
§Errors

Returns an error if the encoder initialization failed.

Source

pub fn build( self, ) -> Result<Ws2812Esp32RmtDriver<'d>, Ws2812Esp32RmtDriverError>

Builds the Ws2812Esp32RmtDriver.

Auto Trait Implementations§

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

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>,

Source§

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

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.