Skip to main content

Symbol

Struct Symbol 

Source
pub struct Symbol(/* private fields */);
Expand description

A Symbol constists of two Pulses, where each pulse defines a level of the pin (high or low) and a duration (PulseTicks).

The Pulses can be the same level (e.g., both high) and must not necessarily be different levels.

This is just a newtype over the IDF’s rmt_item32_t or rmt_symbol_word_t type.

Implementations§

Source§

impl Symbol

Source

pub fn new(level0: Pulse, level1: Pulse) -> Self

Create a symbol from a pair of half-cycles.

Source

pub fn new_with( resolution: Hertz, level0: PinState, duration0: Duration, level1: PinState, duration1: Duration, ) -> Result<Self, EspError>

Constructs a symbol from the given levels and durations.

This is a convenience function that combines Pulse::new_with_duration and Symbol::new.

Source

pub fn new_half_split( resolution: Hertz, level0: PinState, level1: PinState, duration: Duration, ) -> Result<Self, EspError>

Constructs a new symbol where the duration is split evenly between the two levels.

It is guaranteed that the combined duration of the two levels adds up to the given duration. If the duration is odd, the first level might be a bit shorter than the second level.

Source

pub fn repeat_for( &self, resolution: Hertz, duration: Duration, ) -> impl Iterator<Item = Self>

Repeats the symbol to have the returned sequence of symbols last for exactly the given duration.

There is an upper limit for how long a single symbol can be (PulseTicks::max). To create a symbol that lasts longer than that, it is split into multiple symbols. The returned iterator yields as many symbols as necessary to reach the desired duration.

If the given duration is not a multiple of the symbol duration, the last symbol will be adjusted to occupy the remaining time.

§Panics

If self has a duration of zero.

Source

pub fn level0(&self) -> Pulse

Returns the first half-cycle (pulse) of this symbol.

Source

pub fn level1(&self) -> Pulse

Returns the second half-cycle (pulse) of this symbol.

Source

pub fn duration(&self, resolution: Hertz) -> Duration

Returns the combined duration of both half-cycles of this symbol.

Source

pub fn update(&mut self, level0: Pulse, level1: Pulse)

Mutate this symbol to store a different pair of half-cycles.

Trait Implementations§

Source§

impl Clone for Symbol

Source§

fn clone(&self) -> Symbol

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Symbol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Symbol

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Symbol> for rmt_symbol_word_t

Source§

fn from(value: Symbol) -> Self

Converts to this type from the input type.
Source§

impl From<rmt_symbol_word_t> for Symbol

Source§

fn from(value: rmt_symbol_word_t) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Symbol

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Symbol

Source§

impl Eq for Symbol

Auto Trait Implementations§

§

impl Freeze for Symbol

§

impl RefUnwindSafe for Symbol

§

impl Send for Symbol

§

impl Sync for Symbol

§

impl Unpin for Symbol

§

impl UnsafeUnpin for Symbol

§

impl UnwindSafe for Symbol

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> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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.