diff --git a/library.properties b/library.properties index c3e0e97..36652fc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun VL53L1X 4m Laser Distance Sensor -version=1.2.11 +version=1.2.12 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for the SparkFun Qwiic 4m Distance Sensor - VL53L1X diff --git a/src/SparkFun_VL53L1X.cpp b/src/SparkFun_VL53L1X.cpp index b540436..4ea1cb4 100644 --- a/src/SparkFun_VL53L1X.cpp +++ b/src/SparkFun_VL53L1X.cpp @@ -33,6 +33,13 @@ #include #include "SparkFun_VL53L1X.h" +SFEVL53L1X::SFEVL53L1X() +{ + _i2cPort = &Wire; + _shutdownPin = -1; + _interruptPin = -1; + _device = new VL53L1X(&Wire, -1, -1); +} SFEVL53L1X::SFEVL53L1X(TwoWire &i2cPort, int shutdownPin, int interruptPin) { _i2cPort = &i2cPort; @@ -40,6 +47,10 @@ SFEVL53L1X::SFEVL53L1X(TwoWire &i2cPort, int shutdownPin, int interruptPin) _interruptPin = interruptPin; _device = new VL53L1X(&i2cPort, shutdownPin, interruptPin); } +SFEVL53L1X::~SFEVL53L1X() +{ + delete (VL53L1X *)_device; +} bool SFEVL53L1X::init() { @@ -54,6 +65,14 @@ bool SFEVL53L1X::begin() return _device->VL53L1X_SensorInit(); } +bool SFEVL53L1X::begin(TwoWire &i2cPort) +{ + _i2cPort = &i2cPort; + _device->dev_i2c = &i2cPort; + + return begin(); +} + /*Checks the ID of the device, returns true if ID is correct*/ bool SFEVL53L1X::checkID() diff --git a/src/SparkFun_VL53L1X.h b/src/SparkFun_VL53L1X.h index 20fb682..fbb940a 100644 --- a/src/SparkFun_VL53L1X.h +++ b/src/SparkFun_VL53L1X.h @@ -59,9 +59,13 @@ struct DetectionConfig class SFEVL53L1X { public: - SFEVL53L1X(TwoWire &i2cPort = Wire, int shutdownPin = -1, int interruptPin = -1); //Constructs our Distance sensor without an interrupt or shutdown pin + //Constructs our Distance sensor + SFEVL53L1X(); // Default to Wire. Set both pins to -1 (undefined). + SFEVL53L1X(TwoWire &i2cPort, int shutdownPin = -1, int interruptPin = -1); + ~SFEVL53L1X(); bool init(); //Deprecated version of begin bool begin(); //Initialization of sensor + bool begin(TwoWire &i2cPort); //Initialization of sensor bool checkID(); //Check the ID of the sensor, returns true if ID is correct void sensorOn(); //Toggles shutdown pin to turn sensor on and off void sensorOff(); //Toggles shutdown pin to turn sensor on and off diff --git a/src/st_src/vl53l1x_class.h b/src/st_src/vl53l1x_class.h index 458014b..0af5eea 100644 --- a/src/st_src/vl53l1x_class.h +++ b/src/st_src/vl53l1x_class.h @@ -553,10 +553,13 @@ class VL53L1X : public RangeSensor - protected: + public: /* IO Device */ TwoWire *dev_i2c; + + protected: + /* Digital out pin */ int gpio0; int gpio1Int;