Skip to content

Commit 2ae39a1

Browse files
authored
Merge pull request #41 from josephduchesne/master
Added One-Shot Ranging trigger
2 parents ce448e7 + 28ae87e commit 2ae39a1

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/SparkFun_VL53L1X.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ void SFEVL53L1X::startRanging()
133133
_device->VL53L1X_StartRanging();
134134
}
135135

136+
void SFEVL53L1X::startOneshotRanging() {
137+
_device->VL53L1X_StartOneshotRanging();
138+
}
139+
136140
void SFEVL53L1X::stopRanging()
137141
{
138142
_device->VL53L1X_StopRanging();

src/SparkFun_VL53L1X.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class SFEVL53L1X
6363
void setInterruptPolarityLow(); //Set the polarity of an active interrupt to Low
6464
uint8_t getInterruptPolarity(); //get the current interrupt polarity
6565
void startRanging(); //Begins taking measurements
66+
void startOneshotRanging(); // Start one-shot ranging
6667
void stopRanging(); //Stops taking measurements
6768
bool checkForDataReady(); //Checks the to see if data is ready
6869
void setTimingBudgetInMs(uint16_t timingBudget); //Set the timing budget for a measurement

src/vl53l1x_class.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,19 @@ VL53L1X_ERROR VL53L1X::VL53L1X_GetInterruptPolarity(uint8_t *pInterruptPolarity)
223223
VL53L1X_ERROR VL53L1X::VL53L1X_StartRanging()
224224
{
225225
VL53L1X_ERROR status = 0;
226-
226+
// Consider: maybe also VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01); /* clear interrupt trigger */
227227
status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x40); /* Enable VL53L1X */
228228
return status;
229229
}
230230

231+
VL53L1X_ERROR VL53L1X::VL53L1X_StartOneshotRanging()
232+
{
233+
VL53L1X_ERROR status = 0;
234+
VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01); /* clear interrupt trigger */
235+
status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x10); /* Enable VL53L1X one-shot ranging */
236+
return status;
237+
}
238+
231239
VL53L1X_ERROR VL53L1X::VL53L1X_StopRanging()
232240
{
233241
VL53L1X_ERROR status = 0;

src/vl53l1x_class.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ class VL53L1X : public RangeSensor
304304
*/
305305
VL53L1X_ERROR VL53L1X_StartRanging();
306306

307+
/**
308+
* @brief This function starts a one-shot ranging distance operation\n
309+
*/
310+
VL53L1X_ERROR VL53L1X_StartOneshotRanging();
311+
307312
/**
308313
* @brief This function stops the ranging.
309314
*/

0 commit comments

Comments
 (0)