Struct gihex_hc_sr04::HcSR04

source ·
pub struct HcSR04<OUT, DELAY, COUNTER> { /* private fields */ }
Expand description

Struct HC-SR04 sensor object

Implementations§

source§

impl<OUT, DELAY, COUNTER> HcSR04<OUT, DELAY, COUNTER>
where OUT: OutputPin, DELAY: DelayUs<u8>, COUNTER: TickerUs,

source

pub fn hc_sr04_new( pin_trigger: OUT, delay: &mut DELAY, timer: &mut COUNTER ) -> Self

Create new HC-SR04 object.

source

pub fn set_temperature(&mut self, temp: f32)

Set temperature of environment. Temperature value must be in Celsius unit.
This function only available if feature "temperature" or "humidity" enabled.

source

pub fn set_humidity(&mut self, humidity: u8)

Set relative humidity of environment.
This function only available if feature "humidity" enabled.

source

pub fn get_distance<T>(&mut self, unit: DistanceUnit) -> Result<T, HsError>
where T: NumCast,

Measure distance. where T is numb variants.

source

pub fn get_last_length_echo_time<T>(&mut self, unit: TimeUnit) -> T
where T: NumCast,

Get last lenght of time soundwave detected back by sensor. Where T is number variants.

source

pub fn send_ping_force(&mut self)

Send ulrasonic sundwave.

source

pub fn on_echo_pulse(&mut self) -> Result<(), HsError>

Update state of HC-SR04 sensor. This function must called inside external interrupt (EXTI) callback.

Trait Implementations§

source§

impl<OUT, DELAY, COUNTER> Send for HcSR04<OUT, DELAY, COUNTER>

Auto Trait Implementations§

§

impl<OUT, DELAY, COUNTER> RefUnwindSafe for HcSR04<OUT, DELAY, COUNTER>
where COUNTER: RefUnwindSafe, DELAY: RefUnwindSafe, OUT: RefUnwindSafe,

§

impl<OUT, DELAY, COUNTER> !Sync for HcSR04<OUT, DELAY, COUNTER>

§

impl<OUT, DELAY, COUNTER> Unpin for HcSR04<OUT, DELAY, COUNTER>
where COUNTER: Unpin, OUT: Unpin,

§

impl<OUT, DELAY, COUNTER> UnwindSafe for HcSR04<OUT, DELAY, COUNTER>
where COUNTER: UnwindSafe + RefUnwindSafe, DELAY: RefUnwindSafe, OUT: UnwindSafe,

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.