Struct vl53l1x_uld::VL53L1X
source · [−]Expand description
Instance of a single VL53L1X driver.
Implementations
sourceimpl<T, E> VL53L1X<T>where
E: Debug,
T: Write<Error = E> + Read<Error = E>,
impl<T, E> VL53L1X<T>where
E: Debug,
T: Write<Error = E> + Read<Error = E>,
sourcepub fn new(i2c: T, address: u8) -> VL53L1X<T>
pub fn new(i2c: T, address: u8) -> VL53L1X<T>
Create a new instance of the VL53L1X driver with the given I2C address.
Arguments
i2c
- Instance of object that implements I2C communication. Is used for further communication with the sensoraddress
- The address to use for communication with the VL53L1X.
sourcepub fn sw_version() -> SWVersion
pub fn sw_version() -> SWVersion
Get the driver version.
sourcepub const DEFAULT_CONFIG: [u8; 88] = _
pub const DEFAULT_CONFIG: [u8; 88] = _
Default configuration used during initialization.
sourcepub fn write_bytes<R>(&mut self, address: R, bytes: &[u8]) -> Result<(), Error<E>>where
R: Into<[u8; 2]>,
pub fn write_bytes<R>(&mut self, address: R, bytes: &[u8]) -> Result<(), Error<E>>where
R: Into<[u8; 2]>,
Write bytes to register at address of variable length. (Number of bytes is limited to 4 for non iterator implementations)
Arguments
address
- Address of the register to write to.iter
- Iterator of bytes that will be written at the address.
sourcepub fn read_bytes<R>(
&mut self,
address: R,
bytes: &mut [u8]
) -> Result<(), Error<E>>where
R: Into<[u8; 2]>,
pub fn read_bytes<R>(
&mut self,
address: R,
bytes: &mut [u8]
) -> Result<(), Error<E>>where
R: Into<[u8; 2]>,
Read bytes from at the address into mutable slice
Arguments
address
- Address of the register to read from.bytes
- Mutable slice that read data will be written to.
sourcepub fn set_address(&mut self, new_address: u8) -> Result<(), Error<E>>
pub fn set_address(&mut self, new_address: u8) -> Result<(), Error<E>>
Set the I2C address of the current device in case multiple devices with the same address exists on the same bus.
Arguments
new_address
- The new address to set for the current device.
sourcepub fn init(&mut self, io_config: IOVoltage) -> Result<(), Error<E>>
pub fn init(&mut self, io_config: IOVoltage) -> Result<(), Error<E>>
Load the 88 byte default values for sensor initialisation.
Arguments
io_config
- The io voltage that will be configured for the device.
sourcepub fn clear_interrupt(&mut self) -> Result<(), Error<E>>
pub fn clear_interrupt(&mut self) -> Result<(), Error<E>>
Clear the interrupt flag on the device. Should be called after reading ranging data from the device to start the next measurement.
sourcepub fn get_interrupt_polarity(&mut self) -> Result<Polarity, Error<E>>
pub fn get_interrupt_polarity(&mut self) -> Result<Polarity, Error<E>>
Get the currently set interrupt polarity.
sourcepub fn start_ranging(&mut self) -> Result<(), Error<E>>
pub fn start_ranging(&mut self) -> Result<(), Error<E>>
Start a distance ranging operation. This operation is continuous, the interrupt flag should be cleared between each interrupt to start a new distance measurement.
sourcepub fn stop_ranging(&mut self) -> Result<(), Error<E>>
pub fn stop_ranging(&mut self) -> Result<(), Error<E>>
Stop an ongoing ranging operation.
sourcepub fn is_data_ready(&mut self) -> Result<bool, Error<E>>
pub fn is_data_ready(&mut self) -> Result<bool, Error<E>>
Check if new ranging data is available by polling the device.
sourcepub fn set_timing_budget_ms(&mut self, milliseconds: u16) -> Result<(), Error<E>>
pub fn set_timing_budget_ms(&mut self, milliseconds: u16) -> Result<(), Error<E>>
Set the timing budget for a measurement operation in milliseconds.
Arguments
milliseconds
- One of the following values = 15, 20, 33, 50, 100(default), 200, 500.
sourcepub fn get_timing_budget_ms(&mut self) -> Result<u16, Error<E>>
pub fn get_timing_budget_ms(&mut self) -> Result<u16, Error<E>>
Get the currently set timing budget of the device.
sourcepub fn set_distance_mode(&mut self, mode: DistanceMode) -> Result<(), Error<E>>
pub fn set_distance_mode(&mut self, mode: DistanceMode) -> Result<(), Error<E>>
sourcepub fn get_distance_mode(&mut self) -> Result<DistanceMode, Error<E>>
pub fn get_distance_mode(&mut self) -> Result<DistanceMode, Error<E>>
Get the currently set distance mode of the device.
sourcepub fn set_inter_measurement_period_ms(
&mut self,
milliseconds: u16
) -> Result<(), Error<E>>
pub fn set_inter_measurement_period_ms(
&mut self,
milliseconds: u16
) -> Result<(), Error<E>>
Set the inter measurement period in milliseconds. This value must be greater or equal to the timing budget. This condition is not checked by this driver.
Arguments
milliseconds
- The number of milliseconds used for the inter measurement period.
sourcepub fn get_inter_measurement_period_ms(&mut self) -> Result<u16, Error<E>>
pub fn get_inter_measurement_period_ms(&mut self) -> Result<u16, Error<E>>
Get the currently set inter measurement period in milliseconds.
sourcepub fn get_sensor_id(&mut self) -> Result<u16, Error<E>>
pub fn get_sensor_id(&mut self) -> Result<u16, Error<E>>
Get the sensor id of the sensor. This id must be 0xEACC.
sourcepub fn get_distance(&mut self) -> Result<u16, Error<E>>
pub fn get_distance(&mut self) -> Result<u16, Error<E>>
Get the distance measured in millimeters.
sourcepub fn get_signal_per_spad(&mut self) -> Result<u16, Error<E>>
pub fn get_signal_per_spad(&mut self) -> Result<u16, Error<E>>
Get the returned signal per SPAD in kcps/SPAD where kcps stands for Kilo Count Per Second.
sourcepub fn get_ambient_per_spad(&mut self) -> Result<u16, Error<E>>
pub fn get_ambient_per_spad(&mut self) -> Result<u16, Error<E>>
Get the ambient signal per SPAD in kcps/SPAD where kcps stands for Kilo Count Per Second.
sourcepub fn get_signal_rate(&mut self) -> Result<u16, Error<E>>
pub fn get_signal_rate(&mut self) -> Result<u16, Error<E>>
Get the returned signal in kcps (Kilo Count Per Second).
sourcepub fn get_spad_count(&mut self) -> Result<u16, Error<E>>
pub fn get_spad_count(&mut self) -> Result<u16, Error<E>>
Get the count of currently enabled SPADs.
sourcepub fn get_ambient_rate(&mut self) -> Result<u16, Error<E>>
pub fn get_ambient_rate(&mut self) -> Result<u16, Error<E>>
Get the ambient signal in kcps (Kilo Count Per Second).
sourcepub fn get_range_status(&mut self) -> Result<RangeStatus, Error<E>>
pub fn get_range_status(&mut self) -> Result<RangeStatus, Error<E>>
Get the ranging status.
sourcepub fn get_result(&mut self) -> Result<MeasureResult, Error<E>>
pub fn get_result(&mut self) -> Result<MeasureResult, Error<E>>
Get a measurement result object which is read in a single access.
sourcepub fn set_offset(&mut self, offset: i16) -> Result<(), Error<E>>
pub fn set_offset(&mut self, offset: i16) -> Result<(), Error<E>>
Set a offset in millimeters which is aplied to the distance.
Arguments
offset
- The offset in millimeters.
sourcepub fn get_offset(&mut self) -> Result<i16, Error<E>>
pub fn get_offset(&mut self) -> Result<i16, Error<E>>
Get the current offset in millimeters.
sourcepub fn set_cross_talk(&mut self, correction: u16) -> Result<(), Error<E>>
pub fn set_cross_talk(&mut self, correction: u16) -> Result<(), Error<E>>
Set the crosstalk correction value in cps (Count Per Second).
Arguments
correction
- The number of photons reflected back from the cover glass in cps.
sourcepub fn get_cross_talk(&mut self) -> Result<u16, Error<E>>
pub fn get_cross_talk(&mut self) -> Result<u16, Error<E>>
Get the crosstalk correction value in cps.
sourcepub fn get_distance_threshold(&mut self) -> Result<Threshold, Error<E>>
pub fn get_distance_threshold(&mut self) -> Result<Threshold, Error<E>>
Get the currently set distance threshold.
sourcepub fn set_roi(&mut self, roi: ROI) -> Result<(), Error<E>>
pub fn set_roi(&mut self, roi: ROI) -> Result<(), Error<E>>
Set the region of interest of the sensor. The ROI is centered and only the size is settable. The smallest acceptable ROI size is 4.
Arguments
roi
- The ROI to apply.
sourcepub fn set_roi_center(&mut self, center: ROICenter) -> Result<(), Error<E>>
pub fn set_roi_center(&mut self, center: ROICenter) -> Result<(), Error<E>>
Set the new ROI center. If the new ROI clips out of the border this function does not return an error but only when ranging is started will an error be returned.
Arguments
center
- Tne ROI center to apply.
sourcepub fn get_roi_center(&mut self) -> Result<ROICenter, Error<E>>
pub fn get_roi_center(&mut self) -> Result<ROICenter, Error<E>>
Get the current ROI center.
sourcepub fn get_signal_threshold(&mut self) -> Result<u16, Error<E>>
pub fn get_signal_threshold(&mut self) -> Result<u16, Error<E>>
Get the currently set signal threshold.
sourcepub fn get_sigma_threshold(&mut self) -> Result<u16, Error<E>>
pub fn get_sigma_threshold(&mut self) -> Result<u16, Error<E>>
Get the currently set sigma threshold.
sourcepub fn calibrate_temperature(&mut self) -> Result<(), Error<E>>
pub fn calibrate_temperature(&mut self) -> Result<(), Error<E>>
Perform temperature calibration of the sensor. It is recommended to call this function any time the temperature might have changed by more than 8 degrees Celsius without sensor ranging activity for an extended period.
sourcepub fn calibrate_offset(
&mut self,
target_distance_mm: u16
) -> Result<i16, Error<E>>
pub fn calibrate_offset(
&mut self,
target_distance_mm: u16
) -> Result<i16, Error<E>>
Perform offset calibration. The function returns the offset value found and sets it as the new offset. Target reflectance = grey 17%
Arguments
target_distance_mm
- Distance to the target in millimeters, ST recommends 100 mm.
sourcepub fn calibrate_cross_talk(
&mut self,
target_distance_mm: u16
) -> Result<u16, Error<E>>
pub fn calibrate_cross_talk(
&mut self,
target_distance_mm: u16
) -> Result<u16, Error<E>>
Perform crosstalk calibration. The function returns the crosstalk value found and set it as the new crosstalk correction. Target reflectance = grey 17%
Arguments
target_distance_mm
- Distance to the target in millimeters, ST recommends 100 mm.