Adafruit Library
Public Types | Public Member Functions | Public Attributes | List of all members
Adafruit_VL53L0X Class Reference

Class that stores state and functions for interacting with VL53L0X time-of-flight sensor chips. More...

#include <Adafruit_VL53L0X.h>

Public Types

enum  VL53L0X_Sense_config_t { VL53L0X_SENSE_DEFAULT = 0, VL53L0X_SENSE_LONG_RANGE, VL53L0X_SENSE_HIGH_SPEED, VL53L0X_SENSE_HIGH_ACCURACY }
 

Public Member Functions

boolean begin (uint8_t i2c_addr=VL53L0X_I2C_ADDR, boolean debug=false, TwoWire *i2c=&Wire, VL53L0X_Sense_config_t vl_config=VL53L0X_SENSE_DEFAULT)
 Setups the I2C interface and hardware. More...
 
boolean setAddress (uint8_t newAddr)
 Change the I2C address of the sensor. More...
 
VL53L0X_Error rangingTest (VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, boolean debug=false)
 get a ranging measurement from the device More...
 
VL53L0X_Error getSingleRangingMeasurement (VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, boolean debug=false)
 get a ranging measurement from the device More...
 
void printRangeStatus (VL53L0X_RangingMeasurementData_t *pRangingMeasurementData)
 print a ranging measurement out via Serial.print in a human-readable format More...
 
VL53L0X_Error getRangingMeasurement (VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, boolean debug=false)
 get a ranging measurement from the device More...
 
VL53L0X_Error startMeasurement (boolean debug=false)
 Start the ranging measurement from the device. More...
 
VL53L0X_Error stopMeasurement (boolean debug=false)
 Stop ranging measurement from the device. More...
 
VL53L0X_Error getLimitCheckCurrent (uint8_t LimitCheckId, FixPoint1616_t *pLimitCheckCurrent, boolean debug=false)
 Stop ranging measurement from the device. More...
 
VL53L0X_Error getDeviceMode (VL53L0X_DeviceModes *pDeviceMode, boolean debug=false)
 Get current new device mode. More...
 
VL53L0X_Error setDeviceMode (VL53L0X_DeviceModes DeviceMode, boolean debug=false)
 Set a new device mode. More...
 
VL53L0X_Error setInterruptThresholds (FixPoint1616_t ThresholdLow, FixPoint1616_t ThresholdHigh, boolean debug=false)
 Set low and high Interrupt thresholds. More...
 
VL53L0X_Error getInterruptThresholds (FixPoint1616_t *pThresholdLow, FixPoint1616_t *pThresholdHigh, boolean debug=false)
 Get high and low Interrupt thresholds. More...
 
VL53L0X_Error clearInterruptMask (boolean debug=false)
 Clear system interrupt condition. More...
 
VL53L0X_Error getGpioConfig (VL53L0X_DeviceModes *pDeviceMode, VL53L0X_GpioFunctionality *pFunctionality, VL53L0X_InterruptPolarity *pPolarity, boolean debug=false)
 Get current configuration for GPIO pin 0. More...
 
VL53L0X_Error setGpioConfig (VL53L0X_DeviceModes DeviceMode, VL53L0X_GpioFunctionality Functionality, VL53L0X_InterruptPolarity Polarity, boolean debug=false)
 Set the configuration of GPIO pin 0. More...
 
uint16_t readRange (void)
 Single shot ranging. Be sure to check the return of readRangeStatus to before using the return value! More...
 
uint8_t readRangeStatus (void)
 Request ranging success/error message (retrieve after ranging) More...
 
boolean startRange (void)
 Start a range operation. More...
 
boolean isRangeComplete (void)
 Checks to see if a range operation has completed. More...
 
boolean waitRangeComplete (void)
 Wait until Range operation has completed. More...
 
uint16_t readRangeResult (void)
 Return the range in mm for the last operation. More...
 
boolean startRangeContinuous (uint16_t period_ms=50)
 Start a continuous range operation. More...
 
void stopRangeContinuous (void)
 Stop a continuous ranging operation.
 
boolean timeoutOccurred (void)
 timeout status More...
 
boolean configSensor (VL53L0X_Sense_config_t vl_config)
 Configure the sensor for one of the ways the example ST sketches configure the sensors for different usages. More...
 
boolean setMeasurementTimingBudgetMicroSeconds (uint32_t budget_us)
 Wrapper to ST library code to budget how long a measurement should take. More...
 
uint32_t getMeasurementTimingBudgetMicroSeconds (void)
 Wrapper to ST library code to budget how long a measurement should take. More...
 
boolean setVcselPulsePeriod (VL53L0X_VcselPeriod VcselPeriodType, uint8_t VCSELPulsePeriod)
 Sets the VCSEL pulse period. More...
 
uint8_t getVcselPulsePeriod (VL53L0X_VcselPeriod VcselPeriodType)
 Gets the VCSEL pulse period. More...
 
boolean setLimitCheckEnable (uint16_t LimitCheckId, uint8_t LimitCheckEnable)
 Enable/Disable a specific limit check. More...
 
uint8_t getLimitCheckEnable (uint16_t LimitCheckId)
 Get specific limit check enable state. More...
 
boolean setLimitCheckValue (uint16_t LimitCheckId, FixPoint1616_t LimitCheckValue)
 Set a specific limit check value. More...
 
FixPoint1616_t getLimitCheckValue (uint16_t LimitCheckId)
 Get a specific limit check value. More...
 

Public Attributes

VL53L0X_Error Status
 

Detailed Description

Class that stores state and functions for interacting with VL53L0X time-of-flight sensor chips.

Member Enumeration Documentation

◆ VL53L0X_Sense_config_t

Sensor configurations

Member Function Documentation

◆ begin()

boolean Adafruit_VL53L0X::begin ( uint8_t  i2c_addr = VL53L0X_I2C_ADDR,
boolean  debug = false,
TwoWire *  i2c = &Wire,
VL53L0X_Sense_config_t  vl_config = VL53L0X_SENSE_DEFAULT 
)

Setups the I2C interface and hardware.

Parameters
i2c_addrOptional I2C address the sensor can be found on. Default is 0x29
debugOptional debug flag. If true, debug information will print out via Serial.print during setup. Defaults to false.
i2cOptional I2C bus the sensor is located on. Default is Wire
vl_configSensor configuration
Returns
True if device is set up, false on any failure

◆ setAddress()

boolean Adafruit_VL53L0X::setAddress ( uint8_t  newAddr)

Change the I2C address of the sensor.

Parameters
newAddrthe new address to set the sensor to
Returns
True if address was set successfully, False otherwise

◆ rangingTest()

VL53L0X_Error Adafruit_VL53L0X::rangingTest ( VL53L0X_RangingMeasurementData_t *  pRangingMeasurementData,
boolean  debug = false 
)
inline

get a ranging measurement from the device

Parameters
pRangingMeasurementDatathe pointer to the struct the data will be stored in
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
True if address was set successfully, False otherwise

◆ getSingleRangingMeasurement()

VL53L0X_Error Adafruit_VL53L0X::getSingleRangingMeasurement ( VL53L0X_RangingMeasurementData_t *  RangingMeasurementData,
boolean  debug = false 
)

get a ranging measurement from the device

Parameters
RangingMeasurementDatathe pointer to the struct the data will be stored in
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
True if address was set successfully, False otherwise

◆ printRangeStatus()

void Adafruit_VL53L0X::printRangeStatus ( VL53L0X_RangingMeasurementData_t *  pRangingMeasurementData)

print a ranging measurement out via Serial.print in a human-readable format

Parameters
pRangingMeasurementDataa pointer to the ranging measurement data

◆ getRangingMeasurement()

VL53L0X_Error Adafruit_VL53L0X::getRangingMeasurement ( VL53L0X_RangingMeasurementData_t *  RangingMeasurementData,
boolean  debug = false 
)

get a ranging measurement from the device

Parameters
RangingMeasurementDatathe pointer to the struct the data will be stored in
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
VL53L0X_ERROR_NONE or Error if one occured

◆ startMeasurement()

VL53L0X_Error Adafruit_VL53L0X::startMeasurement ( boolean  debug = false)

Start the ranging measurement from the device.

Parameters
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ stopMeasurement()

VL53L0X_Error Adafruit_VL53L0X::stopMeasurement ( boolean  debug = false)

Stop ranging measurement from the device.

Parameters
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ getLimitCheckCurrent()

VL53L0X_Error Adafruit_VL53L0X::getLimitCheckCurrent ( uint8_t  LimitCheckId,
FixPoint1616_t *  pLimitCheckCurrent,
boolean  debug = false 
)

Stop ranging measurement from the device.

Parameters
LimitCheckIdLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
pLimitCheckCurrentPointer to current Value for a given LimitCheckId.
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ getDeviceMode()

VL53L0X_Error Adafruit_VL53L0X::getDeviceMode ( VL53L0X_DeviceModes *  pDeviceMode,
boolean  debug = false 
)

Get current new device mode.

Parameters
pDeviceModePointer to current apply mode value
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ setDeviceMode()

VL53L0X_Error Adafruit_VL53L0X::setDeviceMode ( VL53L0X_DeviceModes  DeviceMode,
boolean  debug = false 
)

Set a new device mode.

Parameters
DeviceModeNew device mode to apply Valid values are: VL53L0X_DEVICEMODE_SINGLE_RANGING VL53L0X_DEVICEMODE_CONTINUOUS_RANGING VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY VL53L0X_HISTOGRAMMODE_RETURN_ONLY VL53L0X_HISTOGRAMMODE_BOTH
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ setInterruptThresholds()

VL53L0X_Error Adafruit_VL53L0X::setInterruptThresholds ( FixPoint1616_t  ThresholdLow,
FixPoint1616_t  ThresholdHigh,
boolean  debug = false 
)

Set low and high Interrupt thresholds.

Parameters
ThresholdLowLow threshold (mm, lux ..., depending on the mode)
ThresholdHighHigh threshold (mm, lux ..., depending on the mode)
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ getInterruptThresholds()

VL53L0X_Error Adafruit_VL53L0X::getInterruptThresholds ( FixPoint1616_t *  pThresholdLow,
FixPoint1616_t *  pThresholdHigh,
boolean  debug = false 
)

Get high and low Interrupt thresholds.

Parameters
pThresholdLowLow threshold (mm, lux ..., depending on the mode)
pThresholdHighHigh threshold (mm, lux ..., depending on the mode)
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ clearInterruptMask()

VL53L0X_Error Adafruit_VL53L0X::clearInterruptMask ( boolean  debug = false)

Clear system interrupt condition.

Parameters
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ getGpioConfig()

VL53L0X_Error Adafruit_VL53L0X::getGpioConfig ( VL53L0X_DeviceModes *  pDeviceMode,
VL53L0X_GpioFunctionality *  pFunctionality,
VL53L0X_InterruptPolarity *  pPolarity,
boolean  debug = false 
)

Get current configuration for GPIO pin 0.

Parameters
pDeviceModePointer to Device Mode associated to the Gpio.
pFunctionalityPointer to Pin functionality.
pPolarityPointer to interrupt polarity. Active high or active low.
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ setGpioConfig()

VL53L0X_Error Adafruit_VL53L0X::setGpioConfig ( VL53L0X_DeviceModes  DeviceMode,
VL53L0X_GpioFunctionality  Functionality,
VL53L0X_InterruptPolarity  Polarity,
boolean  debug = false 
)

Set the configuration of GPIO pin 0.

Parameters
DeviceModeDevice Mode associated to the Gpio.
FunctionalitySelect Pin functionality.
PolaritySet interrupt polarity. Active high or active low.
debugOptional debug flag. If true debug information will print via Serial.print during execution. Defaults to false.
Returns
status code

◆ readRange()

uint16_t Adafruit_VL53L0X::readRange ( void  )

Single shot ranging. Be sure to check the return of readRangeStatus to before using the return value!

Returns
Distance in millimeters if valid

◆ readRangeStatus()

uint8_t Adafruit_VL53L0X::readRangeStatus ( void  )

Request ranging success/error message (retrieve after ranging)

Returns
One of possible VL6180X_ERROR_* values

◆ startRange()

boolean Adafruit_VL53L0X::startRange ( void  )

Start a range operation.

Returns
true if range operation successfully started.

◆ isRangeComplete()

boolean Adafruit_VL53L0X::isRangeComplete ( void  )

Checks to see if a range operation has completed.

Returns
true if range operation completed or an error has happened

◆ waitRangeComplete()

boolean Adafruit_VL53L0X::waitRangeComplete ( void  )

Wait until Range operation has completed.

Returns
true if range operation completed, false if error.

◆ readRangeResult()

uint16_t Adafruit_VL53L0X::readRangeResult ( void  )

Return the range in mm for the last operation.

Returns
Range in mm.

◆ startRangeContinuous()

boolean Adafruit_VL53L0X::startRangeContinuous ( uint16_t  period_ms = 50)

Start a continuous range operation.

Parameters
period_msinter measurement period in milliseconds
Returns
True if successful, false otherwise

◆ timeoutOccurred()

boolean Adafruit_VL53L0X::timeoutOccurred ( void  )
inline

timeout status

Returns
True if timeout has occurred, False otherwise

◆ configSensor()

boolean Adafruit_VL53L0X::configSensor ( VL53L0X_Sense_config_t  vl_config)

Configure the sensor for one of the ways the example ST sketches configure the sensors for different usages.

Parameters
vl_configWhich configureation you are trying to configure for It should be one of the following VL53L0X_SENSE_DEFAULT VL53L0X_SENSE_LONG_RANGE VL53L0X_SENSE_HIGH_SPEED, VL53L0X_SENSE_HIGH_ACCURACY
Returns
True if address was set successfully, False otherwise

◆ setMeasurementTimingBudgetMicroSeconds()

boolean Adafruit_VL53L0X::setMeasurementTimingBudgetMicroSeconds ( uint32_t  budget_us)

Wrapper to ST library code to budget how long a measurement should take.

Parameters
budget_usthe new budget
Returns
True if success

◆ getMeasurementTimingBudgetMicroSeconds()

uint32_t Adafruit_VL53L0X::getMeasurementTimingBudgetMicroSeconds ( void  )

Wrapper to ST library code to budget how long a measurement should take.

Returns
the current budget time in microseconds.

◆ setVcselPulsePeriod()

boolean Adafruit_VL53L0X::setVcselPulsePeriod ( VL53L0X_VcselPeriod  VcselPeriodType,
uint8_t  VCSELPulsePeriod 
)

Sets the VCSEL pulse period.

Parameters
VcselPeriodTypeVCSEL period identifier (pre-range|final).
VCSELPulsePeriodVCSEL period value
Returns
True if success

◆ getVcselPulsePeriod()

uint8_t Adafruit_VL53L0X::getVcselPulsePeriod ( VL53L0X_VcselPeriod  VcselPeriodType)

Gets the VCSEL pulse period.

Parameters
VcselPeriodTypeVCSEL period identifier (pre-range|final).
Returns
the current pulse peried for the given type.

◆ setLimitCheckEnable()

boolean Adafruit_VL53L0X::setLimitCheckEnable ( uint16_t  LimitCheckId,
uint8_t  LimitCheckEnable 
)

Enable/Disable a specific limit check.

Parameters
LimitCheckIdLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
LimitCheckEnableif 1 the check limit corresponding to LimitCheckId is Enabled if 0 the check limit corresponding to LimitCheckId is disabled
Returns
true if succeeded

◆ getLimitCheckEnable()

uint8_t Adafruit_VL53L0X::getLimitCheckEnable ( uint16_t  LimitCheckId)

Get specific limit check enable state.

Parameters
LimitCheckIdLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
Returns
current state of limit enabled

◆ setLimitCheckValue()

boolean Adafruit_VL53L0X::setLimitCheckValue ( uint16_t  LimitCheckId,
FixPoint1616_t  LimitCheckValue 
)

Set a specific limit check value.

Parameters
LimitCheckIdLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). LimitCheckId
LimitCheckValueLimit Check Value
Returns
true if succeeded.

◆ getLimitCheckValue()

FixPoint1616_t Adafruit_VL53L0X::getLimitCheckValue ( uint16_t  LimitCheckId)

Get a specific limit check value.

Parameters
LimitCheckIdLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
Returns
limit check value in FixPoint1616

Member Data Documentation

◆ Status

VL53L0X_Error Adafruit_VL53L0X::Status
Initial value:
=
VL53L0X_ERROR_NONE

indicates whether or not the sensor has encountered an error


The documentation for this class was generated from the following files: