Skip to content

Commit f35217d

Browse files
committed
breaking: use VL53L4CD TOF for v0.2
1 parent 5c6a4de commit f35217d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/Modulino.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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 {
428428
class ModulinoDistance : public Module {
429429
public:
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
}
440447
private:
441-
VL53L1X tof_sensor;
448+
VL53L4CD* tof_sensor; ;
442449
};

0 commit comments

Comments
 (0)