File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -406,22 +406,25 @@ class ModulinoDistance : public Module {
406
406
if (tof_sensor == nullptr ) {
407
407
return NAN;
408
408
}
409
+ float ret = internal;
409
410
uint8_t NewDataReady = 0 ;
410
411
uint8_t status = tof_sensor->VL53L4CD_CheckForDataReady (&NewDataReady);
411
412
if (NewDataReady) {
412
413
tof_sensor->VL53L4CD_ClearInterrupt ();
413
414
tof_sensor->VL53L4CD_GetResult (&results);
414
415
}
415
416
if (results.range_status == 0 ) {
416
- return results.distance_mm ;
417
+ internal = results.distance_mm ;
417
418
} else {
418
- return NAN;
419
+ internal = NAN;
419
420
}
421
+ return ret;
420
422
}
421
- bool isValid ( float distance ) {
422
- return !isnan (distance );
423
+ bool available ( ) {
424
+ return !isnan (internal );
423
425
}
424
426
private:
425
427
VL53L4CD* tof_sensor = nullptr ;
426
428
VL53L4CD_Result_t results;
429
+ float internal;
427
430
};
You can’t perform that action at this time.
0 commit comments