Struct Vl53l1x

Source
pub struct Vl53l1x<I2C, X> { /* private fields */ }
Expand description

A VL53L1X driver. Use the new function to create a new instance, then call range to get the current range, if available.

Implementations§

Source§

impl<I2C, X, EI2C, EX> Vl53l1x<I2C, X>
where I2C: I2c<Error = EI2C>, X: OutputPin<Error = EX>,

Source

pub fn new( i2c: I2C, x_shut: X, address: u8, delay: &mut impl DelayNs, ) -> Result<Self, InitialisationError<EI2C, EX>>

Create a new instance of the VL53L1X driver. This performs a reset of the device and may fail if the device is not present. This will use the x_shut pin to select the device to be reset, then it will change that devices’ address to the provided address.

If these sensors are being used in an array, set all the xshut pins low prior to calling this function which will allow this to only initialize a single sensor.

§Errors

Forwards any errors from the I2C bus and xshut pin, as well as any initialisation errors from the device itself.

Source

pub fn try_read(&mut self) -> Result<Option<u16>, EI2C>

Poll the device for a new range value. Returns None if the device is still measuring.

The range is returned in millimeters.

§Errors

Forwards any errors from the I2C bus.

Auto Trait Implementations§

§

impl<I2C, X> Freeze for Vl53l1x<I2C, X>
where I2C: Freeze, X: Freeze,

§

impl<I2C, X> RefUnwindSafe for Vl53l1x<I2C, X>

§

impl<I2C, X> Send for Vl53l1x<I2C, X>
where I2C: Send, X: Send,

§

impl<I2C, X> Sync for Vl53l1x<I2C, X>
where I2C: Sync, X: Sync,

§

impl<I2C, X> Unpin for Vl53l1x<I2C, X>
where I2C: Unpin, X: Unpin,

§

impl<I2C, X> UnwindSafe for Vl53l1x<I2C, X>
where I2C: UnwindSafe, X: 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.