Skip to content

Modify so the device results level can be set by the user #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions vl53l1x-st-api/vl53l1_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static VL53L1_Error VL53L1_read_nvm_raw_data(

}

static VL53L1_Error SingleTargetXTalkCalibration(VL53L1_DEV Dev)
static VL53L1_Error SingleTargetXTalkCalibration(VL53L1_DEV Dev, uint8_t deviceResultsLevel)
{
VL53L1_Error Status = VL53L1_ERROR_NONE;

Expand Down Expand Up @@ -441,7 +441,7 @@ static VL53L1_Error SingleTargetXTalkCalibration(VL53L1_DEV Dev)
total_count = 0;
for (xtalk_meas = 0; xtalk_meas < xtalk_measmax; xtalk_meas++) {
VL53L1_WaitMeasurementDataReady(Dev);
VL53L1_GetRangingMeasurementData(Dev, &RMData);
VL53L1_GetRangingMeasurementData(Dev, &RMData, deviceResultsLevel);
VL53L1_ClearInterruptAndStartMeasurement(Dev);
if (RMData.RangeStatus == VL53L1_RANGESTATUS_RANGE_VALID) {
sum_ranging += RMData.RangeMilliMeter;
Expand Down Expand Up @@ -2160,7 +2160,7 @@ static VL53L1_Error SetSimpleData(VL53L1_DEV Dev,


VL53L1_Error VL53L1_GetRangingMeasurementData(VL53L1_DEV Dev,
VL53L1_RangingMeasurementData_t *pRangingMeasurementData)
VL53L1_RangingMeasurementData_t *pRangingMeasurementData, uint8_t deviceResultsLevel)
{
VL53L1_Error Status = VL53L1_ERROR_NONE;
VL53L1_range_results_t results;
Expand All @@ -2177,7 +2177,7 @@ VL53L1_Error VL53L1_GetRangingMeasurementData(VL53L1_DEV Dev,
/* Get Ranging Data */
Status = VL53L1_get_device_results(
Dev,
VL53L1_DEVICERESULTSLEVEL_FULL,
deviceResultsLevel,
presults);

if (Status == VL53L1_ERROR_NONE) {
Expand Down Expand Up @@ -2365,7 +2365,7 @@ VL53L1_Error VL53L1_GetXTalkCompensationEnable(VL53L1_DEV Dev,
}

VL53L1_Error VL53L1_PerformSingleTargetXTalkCalibration(VL53L1_DEV Dev,
int32_t CalDistanceMilliMeter)
int32_t CalDistanceMilliMeter, uint8_t deviceResultsLevel)
{
VL53L1_Error Status = VL53L1_ERROR_NONE;

Expand All @@ -2374,7 +2374,7 @@ VL53L1_Error VL53L1_PerformSingleTargetXTalkCalibration(VL53L1_DEV Dev,
if (CalDistanceMilliMeter > 0) {
BDTable[VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM] =
CalDistanceMilliMeter;
Status = SingleTargetXTalkCalibration(Dev);
Status = SingleTargetXTalkCalibration(Dev, deviceResultsLevel);
} else
Status = VL53L1_ERROR_INVALID_PARAMS;

Expand Down Expand Up @@ -2458,7 +2458,7 @@ VL53L1_Error VL53L1_PerformOffsetCalibration(VL53L1_DEV Dev,
#endif

VL53L1_Error VL53L1_PerformOffsetSimpleCalibration(VL53L1_DEV Dev,
int32_t CalDistanceMilliMeter)
int32_t CalDistanceMilliMeter, uint8_t deviceResultsLevel)
{
VL53L1_Error Status = VL53L1_ERROR_NONE;
int32_t sum_ranging;
Expand Down Expand Up @@ -2494,7 +2494,7 @@ VL53L1_Error VL53L1_PerformOffsetSimpleCalibration(VL53L1_DEV Dev,
Status = VL53L1_WaitMeasurementDataReady(Dev);
if (Status == VL53L1_ERROR_NONE)
Status = VL53L1_GetRangingMeasurementData(Dev,
&RangingMeasurementData);
&RangingMeasurementData, deviceResultsLevel);
if (Status == VL53L1_ERROR_NONE)
Status = VL53L1_ClearInterruptAndStartMeasurement(Dev);
/* offset calibration main loop */
Expand All @@ -2505,7 +2505,7 @@ VL53L1_Error VL53L1_PerformOffsetSimpleCalibration(VL53L1_DEV Dev,
Status = VL53L1_WaitMeasurementDataReady(Dev);
if (Status == VL53L1_ERROR_NONE)
Status = VL53L1_GetRangingMeasurementData(Dev,
&RangingMeasurementData);
&RangingMeasurementData, deviceResultsLevel);
goodmeas = (RangingMeasurementData.RangeStatus ==
VL53L1_RANGESTATUS_RANGE_VALID);
if ((Status == VL53L1_ERROR_NONE) && goodmeas) {
Expand Down
6 changes: 3 additions & 3 deletions vl53l1x-st-api/vl53l1_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ VL53L1_Error VL53L1_WaitMeasurementDataReady(VL53L1_DEV Dev);
* @return "Other error code" See ::VL53L1_Error
*/
VL53L1_Error VL53L1_GetRangingMeasurementData(VL53L1_DEV Dev,
VL53L1_RangingMeasurementData_t *pRangingMeasurementData);
VL53L1_RangingMeasurementData_t *pRangingMeasurementData, uint8_t deviceResultLevel);



Expand Down Expand Up @@ -996,7 +996,7 @@ VL53L1_Error VL53L1_GetXTalkCompensationEnable(VL53L1_DEV Dev,
* @return "Other error code" See ::VL53L1_Error
*/
VL53L1_Error VL53L1_PerformSingleTargetXTalkCalibration(VL53L1_DEV Dev,
int32_t CalDistanceMilliMeter);
int32_t CalDistanceMilliMeter, uint8_t deviceResultLevel);


/**
Expand Down Expand Up @@ -1067,7 +1067,7 @@ VL53L1_Error VL53L1_PerformOffsetCalibration(VL53L1_DEV Dev,
* @return "Other error code" See ::VL53L1_Error
*/
VL53L1_Error VL53L1_PerformOffsetSimpleCalibration(VL53L1_DEV Dev,
int32_t CalDistanceMilliMeter);
int32_t CalDistanceMilliMeter, uint8_t deviceResultLevel);

/**
* @brief Sets the Calibration Data.
Expand Down
2 changes: 1 addition & 1 deletion vl53l1x-st-api/vl53l1x-st-api.ino
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void printRangingData()
{
static VL53L1_RangingMeasurementData_t RangingData;

status = VL53L1_GetRangingMeasurementData(Dev, &RangingData);
status = VL53L1_GetRangingMeasurementData(Dev, &RangingData, VL53L1_DEVICERESULTSLEVEL_FULL);
if(!status)
{
Serial.print(RangingData.RangeStatus);
Expand Down