File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -391,7 +391,7 @@ class ModulinoDistance : public Module {
391
391
tof_sensor = new VL53L4CD ((TwoWire*)getWire (), -1 );
392
392
auto ret = tof_sensor->InitSensor ();
393
393
if (ret == VL53L4CD_ERROR_NONE) {
394
- tof_sensor->VL53L4CD_SetRangeTiming (10 , 0 );
394
+ tof_sensor->VL53L4CD_SetRangeTiming (200 , 0 );
395
395
tof_sensor->VL53L4CD_StartRanging ();
396
396
return true ;
397
397
} else {
@@ -406,16 +406,15 @@ class ModulinoDistance : public Module {
406
406
if (tof_sensor == nullptr ) {
407
407
return NAN;
408
408
}
409
- VL53L4CD_Result_t results;
410
409
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
+ }
417
415
return results.distance_mm ;
418
416
}
419
417
private:
420
418
VL53L4CD* tof_sensor = nullptr ;
419
+ VL53L4CD_Result_t results;
421
420
};
You can’t perform that action at this time.
0 commit comments