Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce2bb16

Browse files
committed
test: increase ToF accurancy, return old value to prevent blocking behaviour
1 parent 5295a5f commit ce2bb16

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

‎src/Modulino.h‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class ModulinoDistance : public Module {
391391
tof_sensor = new VL53L4CD((TwoWire*)getWire(), -1);
392392
auto ret = tof_sensor->InitSensor();
393393
if (ret == VL53L4CD_ERROR_NONE) {
394-
tof_sensor->VL53L4CD_SetRangeTiming(10, 0);
394+
tof_sensor->VL53L4CD_SetRangeTiming(200, 0);
395395
tof_sensor->VL53L4CD_StartRanging();
396396
return true;
397397
} else {
@@ -406,16 +406,15 @@ class ModulinoDistance : public Module {
406406
if (tof_sensor == nullptr) {
407407
return NAN;
408408
}
409-
VL53L4CD_Result_t results;
410409
uint8_t NewDataReady = 0;
411-
uint8_t status;
412-
do {
413-
status = tof_sensor->VL53L4CD_CheckForDataReady(&NewDataReady);
414-
} while (!NewDataReady);
415-
tof_sensor->VL53L4CD_ClearInterrupt();
416-
tof_sensor->VL53L4CD_GetResult(&results);
410+
uint8_t status = tof_sensor->VL53L4CD_CheckForDataReady(&NewDataReady);
411+
if (NewDataReady) {
412+
tof_sensor->VL53L4CD_ClearInterrupt();
413+
tof_sensor->VL53L4CD_GetResult(&results);
414+
}
417415
return results.distance_mm;
418416
}
419417
private:
420418
VL53L4CD* tof_sensor = nullptr;
419+
VL53L4CD_Result_t results;
421420
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /