File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 11#include " Wire.h"
22#include < vector>
3- #include < VL53L1X .h> // from Poulou
3+ #include < vl53l4cd_class .h> // from stm32duino
44#include " Arduino_BMI270_BMM150.h"
55#include < Arduino_LPS22HB.h>
66#include < Arduino_HS300x.h>
@@ -428,15 +428,22 @@ class ModulinoLight : public Module {
428428class ModulinoDistance : public Module {
429429public:
430430 bool begin () {
431- tof_sensor.setBus ((TwoWire*)getWire ());
432- tof_sensor.init ();
433- tof_sensor.setDistanceMode (VL53L1X::Short);
434- tof_sensor.setMeasurementTimingBudget (50000 );
435- tof_sensor.startContinuous (50 );
431+ tof_sensor = new VL53L4CD ((TwoWire*)getWire (), -1 );
432+ tof_sensor->InitSensor ();
433+ tof_sensor->VL53L4CD_SetRangeTiming (10 , 0 );
434+ tof_sensor->VL53L4CD_StartRanging ();
436435 }
437436 float get () {
438- return tof_sensor.read ();
437+ VL53L4CD_Result_t results;
438+ uint8_t NewDataReady = 0 ;
439+ uint8_t status;
440+ do {
441+ status = tof_sensor->VL53L4CD_CheckForDataReady (&NewDataReady);
442+ } while (!NewDataReady);
443+ tof_sensor->VL53L4CD_ClearInterrupt ();
444+ tof_sensor->VL53L4CD_GetResult (&results);
445+ return results.distance_mm ;
439446 }
440447private:
441- VL53L1X tof_sensor;
448+ VL53L4CD* tof_sensor; ;
442449};
You can’t perform that action at this time.
0 commit comments