Skip to main content

Distance

Struct Distance 

Source
pub struct Distance<I2C> { /* private fields */ }
Expand description

Driver for the Modulino Distance module.

Implementations§

Source§

impl<I2C, E> Distance<I2C>
where I2C: I2c<Error = E>,

Source

pub fn new(i2c: I2C) -> Self

Create a new Distance instance.

Source

pub fn new_with_address(i2c: I2C, address: u8) -> Self

Create a new Distance instance with a custom address.

Source

pub fn init<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), E>

Initialize the sensor. This performs the firmware loading and tuning required by the VL53L4CD.

Source

pub fn address(&self) -> u8

Get the I2C address.

Source

pub fn set_timing_budget(&mut self, budget_ms: u16) -> Result<(), E>

Set the timing budget in milliseconds.

Source

pub fn set_inter_measurement(&mut self, period_ms: u32) -> Result<(), E>

Set the inter-measurement period in milliseconds.

Source

pub fn start_ranging(&mut self) -> Result<(), E>

Start continuous ranging.

Source

pub fn stop_ranging(&mut self) -> Result<(), E>

Stop ranging.

Source

pub fn data_ready(&mut self) -> Result<bool, E>

Check if new data is ready.

Source

pub fn clear_interrupt(&mut self) -> Result<(), E>

Clear the interrupt flag.

Source

pub fn read_distance(&mut self) -> Result<Option<u16>, E>

Read the distance measurement.

Source

pub fn read_range_status(&mut self) -> Result<u8, E>

Publicly expose range status for debugging.

Source

pub fn release(self) -> I2C

Release the I2C bus.

Auto Trait Implementations§

§

impl<I2C> Freeze for Distance<I2C>
where I2C: Freeze,

§

impl<I2C> RefUnwindSafe for Distance<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for Distance<I2C>
where I2C: Send,

§

impl<I2C> Sync for Distance<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for Distance<I2C>
where I2C: Unpin,

§

impl<I2C> UnwindSafe for Distance<I2C>
where I2C: 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>,

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.