Skip to content

Commit e8746a8

Browse files
authored
Merge pull request #49 from jimtng/set-distancemode
Fix setThresholdConfig and distance mode definitions
2 parents 77f5656 + 5481a09 commit e8746a8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/SparkFun_VL53L1X.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ uint16_t SFEVL53L1X::getTimingBudgetInMs()
164164

165165
void SFEVL53L1X::setDistanceModeLong()
166166
{
167-
_device->VL53L1X_SetDistanceMode(2);
167+
_device->VL53L1X_SetDistanceMode(DISTANCE_LONG);
168168
}
169169

170170
void SFEVL53L1X::setDistanceModeShort()
171171
{
172-
_device->VL53L1X_SetDistanceMode(1);
172+
_device->VL53L1X_SetDistanceMode(DISTANCE_SHORT);
173173
}
174174

175175
uint8_t SFEVL53L1X::getDistanceMode()
@@ -368,9 +368,9 @@ void SFEVL53L1X::calibrateXTalk(uint16_t targetDistanceInMm)
368368

369369
bool SFEVL53L1X::setThresholdConfig(DetectionConfig *config)
370370
{
371-
VL53L1X_ERROR error = _device->VL53L1X_SetDistanceThreshold(config->thresholdLow, config->thresholdHigh,
372-
(uint8_t)config->windowMode, (uint8_t)config->IntOnNoTarget);
373-
return (error == VL53L1_ERROR_NONE);
371+
return _device->VL53L1X_SetDistanceMode(config->distanceMode) == VL53L1_ERROR_NONE &&
372+
_device->VL53L1X_SetDistanceThreshold(config->thresholdLow, config->thresholdHigh,
373+
(uint8_t)config->windowMode, (uint8_t)config->IntOnNoTarget) == VL53L1_ERROR_NONE;
374374
}
375375

376376
bool SFEVL53L1X::getThresholdConfig(DetectionConfig *config)

src/SparkFun_VL53L1X.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "vl53l1_error_codes.h"
3131
#include "vl53l1x_class.h"
3232

33-
#define DISTANCE_SHORT 0
34-
#define DISTANCE_LONG 1
33+
#define DISTANCE_SHORT 1
34+
#define DISTANCE_LONG 2
3535
#define WINDOW_BELOW 0
3636
#define WINDOW_ABOVE 1
3737
#define WINDOW_OUT 2

0 commit comments

Comments
 (0)