File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -412,26 +412,29 @@ class ModulinoDistance : public Module {
412
412
operator bool () {
413
413
return (tof_sensor != nullptr );
414
414
}
415
- float get () {
415
+ bool available () {
416
416
if (tof_sensor == nullptr ) {
417
- return NAN ;
417
+ return false ;
418
418
}
419
+ float ret = internal;
419
420
uint8_t NewDataReady = 0 ;
420
421
tof_sensor->VL53L4CD_CheckForDataReady (&NewDataReady);
421
422
if (NewDataReady) {
422
423
tof_sensor->VL53L4CD_ClearInterrupt ();
423
424
tof_sensor->VL53L4CD_GetResult (&results);
424
425
}
425
426
if (results.range_status == 0 ) {
426
- return results.distance_mm ;
427
+ internal = results.distance_mm ;
427
428
} else {
428
- return NAN;
429
+ internal = NAN;
429
430
}
431
+ return !isnan (internal);
430
432
}
431
- bool isValid ( float distance ) {
432
- return ! isnan (distance) ;
433
+ float get ( ) {
434
+ return internal ;
433
435
}
434
436
private:
435
437
VL53L4CD* tof_sensor = nullptr ;
436
438
VL53L4CD_Result_t results;
439
+ float internal = NAN;
437
440
};
You can’t perform that action at this time.
0 commit comments