Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/SparkFun_VL53L1X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ void SFEVL53L1X::startRanging()
_device->VL53L1X_StartRanging();
}

void SFEVL53L1X::startOneshotRanging() {
_device->VL53L1X_StartOneshotRanging();
}

void SFEVL53L1X::stopRanging()
{
_device->VL53L1X_StopRanging();
Expand Down
1 change: 1 addition & 0 deletions src/SparkFun_VL53L1X.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SFEVL53L1X
void setInterruptPolarityLow(); //Set the polarity of an active interrupt to Low
uint8_t getInterruptPolarity(); //get the current interrupt polarity
void startRanging(); //Begins taking measurements
void startOneshotRanging(); // Start one-shot ranging
void stopRanging(); //Stops taking measurements
bool checkForDataReady(); //Checks the to see if data is ready
void setTimingBudgetInMs(uint16_t timingBudget); //Set the timing budget for a measurement
Expand Down
10 changes: 9 additions & 1 deletion src/vl53l1x_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,19 @@ VL53L1X_ERROR VL53L1X::VL53L1X_GetInterruptPolarity(uint8_t *pInterruptPolarity)
VL53L1X_ERROR VL53L1X::VL53L1X_StartRanging()
{
VL53L1X_ERROR status = 0;

// Consider: maybe also VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01); /* clear interrupt trigger */
status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x40); /* Enable VL53L1X */
return status;
}

VL53L1X_ERROR VL53L1X::VL53L1X_StartOneshotRanging()
{
VL53L1X_ERROR status = 0;
VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01); /* clear interrupt trigger */
status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x10); /* Enable VL53L1X one-shot ranging */
return status;
}

VL53L1X_ERROR VL53L1X::VL53L1X_StopRanging()
{
VL53L1X_ERROR status = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/vl53l1x_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ class VL53L1X : public RangeSensor
*/
VL53L1X_ERROR VL53L1X_StartRanging();

/**
* @brief This function starts a one-shot ranging distance operation\n
*/
VL53L1X_ERROR VL53L1X_StartOneshotRanging();

/**
* @brief This function stops the ranging.
*/
Expand Down