Skip to content

Commit 7ca2ae0

Browse files
authored
Merge pull request #55 from sparkfun/v1.2.12
V1.2.12
2 parents c4982b8 + 832c0b0 commit 7ca2ae0

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun VL53L1X 4m Laser Distance Sensor
2-
version=1.2.11
2+
version=1.2.12
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for the SparkFun Qwiic 4m Distance Sensor - VL53L1X

Diff for: src/SparkFun_VL53L1X.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@
3333
#include <stdlib.h>
3434
#include "SparkFun_VL53L1X.h"
3535

36+
SFEVL53L1X::SFEVL53L1X()
37+
{
38+
_i2cPort = &Wire;
39+
_shutdownPin = -1;
40+
_interruptPin = -1;
41+
_device = new VL53L1X(&Wire, -1, -1);
42+
}
3643
SFEVL53L1X::SFEVL53L1X(TwoWire &i2cPort, int shutdownPin, int interruptPin)
3744
{
3845
_i2cPort = &i2cPort;
3946
_shutdownPin = shutdownPin;
4047
_interruptPin = interruptPin;
4148
_device = new VL53L1X(&i2cPort, shutdownPin, interruptPin);
4249
}
50+
SFEVL53L1X::~SFEVL53L1X()
51+
{
52+
delete (VL53L1X *)_device;
53+
}
4354

4455
bool SFEVL53L1X::init()
4556
{
@@ -54,6 +65,14 @@ bool SFEVL53L1X::begin()
5465
return _device->VL53L1X_SensorInit();
5566
}
5667

68+
bool SFEVL53L1X::begin(TwoWire &i2cPort)
69+
{
70+
_i2cPort = &i2cPort;
71+
_device->dev_i2c = &i2cPort;
72+
73+
return begin();
74+
}
75+
5776
/*Checks the ID of the device, returns true if ID is correct*/
5877

5978
bool SFEVL53L1X::checkID()

Diff for: src/SparkFun_VL53L1X.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ struct DetectionConfig
5959
class SFEVL53L1X
6060
{
6161
public:
62-
SFEVL53L1X(TwoWire &i2cPort = Wire, int shutdownPin = -1, int interruptPin = -1); //Constructs our Distance sensor without an interrupt or shutdown pin
62+
//Constructs our Distance sensor
63+
SFEVL53L1X(); // Default to Wire. Set both pins to -1 (undefined).
64+
SFEVL53L1X(TwoWire &i2cPort, int shutdownPin = -1, int interruptPin = -1);
65+
~SFEVL53L1X();
6366
bool init(); //Deprecated version of begin
6467
bool begin(); //Initialization of sensor
68+
bool begin(TwoWire &i2cPort); //Initialization of sensor
6569
bool checkID(); //Check the ID of the sensor, returns true if ID is correct
6670
void sensorOn(); //Toggles shutdown pin to turn sensor on and off
6771
void sensorOff(); //Toggles shutdown pin to turn sensor on and off

Diff for: src/st_src/vl53l1x_class.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,13 @@ class VL53L1X : public RangeSensor
553553

554554

555555

556-
protected:
556+
public:
557557

558558
/* IO Device */
559559
TwoWire *dev_i2c;
560+
561+
protected:
562+
560563
/* Digital out pin */
561564
int gpio0;
562565
int gpio1Int;

0 commit comments

Comments
 (0)