File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 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 {
412412 operator bool () {
413413 return (tof_sensor != nullptr );
414414 }
415- float get () {
415+ bool available () {
416416 if (tof_sensor == nullptr ) {
417- return NAN ;
417+ return false ;
418418 }
419+ float ret = internal;
419420 uint8_t NewDataReady = 0 ;
420421 tof_sensor->VL53L4CD_CheckForDataReady (&NewDataReady);
421422 if (NewDataReady) {
422423 tof_sensor->VL53L4CD_ClearInterrupt ();
423424 tof_sensor->VL53L4CD_GetResult (&results);
424425 }
425426 if (results.range_status == 0 ) {
426- return results.distance_mm ;
427+ internal = results.distance_mm ;
427428 } else {
428- return NAN;
429+ internal = NAN;
429430 }
431+ return !isnan (internal);
430432 }
431- bool isValid ( float distance ) {
432- return ! isnan (distance) ;
433+ float get ( ) {
434+ return internal ;
433435 }
434436private:
435437 VL53L4CD* tof_sensor = nullptr ;
436438 VL53L4CD_Result_t results;
439+ float internal = NAN;
437440};
You can’t perform that action at this time.
0 commit comments