Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun VL53L1X 4m Laser Distance Sensor
version=1.2.11
version=1.2.12
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for the SparkFun Qwiic 4m Distance Sensor - VL53L1X
Expand Down
19 changes: 19 additions & 0 deletions src/SparkFun_VL53L1X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,24 @@
#include <stdlib.h>
#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;
_shutdownPin = shutdownPin;
_interruptPin = interruptPin;
_device = new VL53L1X(&i2cPort, shutdownPin, interruptPin);
}
SFEVL53L1X::~SFEVL53L1X()
{
delete (VL53L1X *)_device;
}

bool SFEVL53L1X::init()
{
Expand All @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion src/SparkFun_VL53L1X.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/st_src/vl53l1x_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,13 @@ class VL53L1X : public RangeSensor



protected:
public:

/* IO Device */
TwoWire *dev_i2c;

protected:

/* Digital out pin */
int gpio0;
int gpio1Int;
Expand Down