pub struct Pulse {
pub ticks: PulseTicks,
pub pin_state: PinState,
}Expand description
A Pulse defines for how long the output pin should be high or low.
The duration is defined through the PulseTicks type.
The conversion from
ticks to real time depends on the selected resolution of the RMT channel.
§Example
let pulse = Pulse::new(PinState::High, PulseTicks::new(32));You can create a Pulse with a Duration by using Pulse::new_with_duration:
use esp_idf_hal::rmt::{Pulse, PinState, PulseTicks};
use esp_idf_hal::units::FromValueType;
let ticks = 1_000_000.Hz(); // 1 MHz
let pulse = Pulse::new_with_duration(1_000_000.Hz(), PinState::High, Duration::from_nanos(300))?;Fields§
§ticks: PulseTicks§pin_state: PinStateImplementations§
Source§impl Pulse
impl Pulse
Sourcepub const fn new(pin_state: PinState, ticks: PulseTicks) -> Self
pub const fn new(pin_state: PinState, ticks: PulseTicks) -> Self
Create a Pulse using a pin state and a tick count.
Sourcepub const fn new_with_duration(
resolution: Hertz,
pin_state: PinState,
duration: Duration,
) -> Result<Self, EspError>
pub const fn new_with_duration( resolution: Hertz, pin_state: PinState, duration: Duration, ) -> Result<Self, EspError>
Create a Pulse using a [Duration].
To convert the duration into ticks, the resolution (clock ticks) set for the
RMT channel must be provided (TxChannelConfig::resolution).
§Errors
If the duration is too long to be represented as ticks with the given resolution,
an error with the code [ERR_EOVERFLOW] or ESP_ERR_INVALID_ARG will be returned.
Trait Implementations§
impl Copy for Pulse
impl Eq for Pulse
impl StructuralPartialEq for Pulse
Auto Trait Implementations§
impl Freeze for Pulse
impl RefUnwindSafe for Pulse
impl Send for Pulse
impl Sync for Pulse
impl Unpin for Pulse
impl UnsafeUnpin for Pulse
impl UnwindSafe for Pulse
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)