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 1
1
#include " Wire.h"
2
2
#include < vector>
3
- #include < VL53L1X .h> // from Poulou
3
+ #include < vl53l4cd_class .h> // from stm32duino
4
4
#include " Arduino_BMI270_BMM150.h"
5
5
#include < Arduino_LPS22HB.h>
6
6
#include < Arduino_HS300x.h>
@@ -428,15 +428,22 @@ class ModulinoLight : public Module {
428
428
class ModulinoDistance : public Module {
429
429
public:
430
430
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 ();
436
435
}
437
436
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 ;
439
446
}
440
447
private:
441
- VL53L1X tof_sensor;
448
+ VL53L4CD* tof_sensor; ;
442
449
};
You can’t perform that action at this time.
0 commit comments