Skip to content

Commit 655f08d

Browse files
committed
Fixing issue I induced when optimizing wirePort init
1 parent 06b3080 commit 655f08d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/SparkFun_TMF882X_Library.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ class SparkFun_TMF882X : public QwDevTMF882X {
7777
// wirePort optional. The Wire port. If not provided, the default port is used
7878
// address optional. I2C Address. If not provided, the default address is used.
7979
// retval true on success, false on startup failure
80+
//
81+
// Two versions - the methods is overridden
82+
//
83+
// Version 1:
84+
// User passes in an aready setup wirePort
8085

81-
bool begin(TwoWire& wirePort = Wire, uint8_t deviceAddress = kDefaultTMF882XAddress)
86+
bool begin(TwoWire& wirePort, uint8_t deviceAddress = kDefaultTMF882XAddress)
8287
{
8388
// Setup I2C object and pass into the superclass
8489
_i2cBus.init(wirePort);
@@ -88,6 +93,18 @@ class SparkFun_TMF882X : public QwDevTMF882X {
8893
return this->QwDevTMF882X::init();
8994
};
9095

96+
///////////////////////////////////////////////////////////////////////
97+
// begin()
98+
//
99+
// Version 2:
100+
//
101+
// User doesn't provide a wireport
102+
bool begin(uint8_t deviceAddress = kDefaultTMF882XAddress){
103+
104+
_i2cBus.init();
105+
setCommunicationBus(_i2cBus, deviceAddress);
106+
return this->QwDevTMF882X::init();
107+
}
91108
///////////////////////////////////////////////////////////////////////
92109
// setOutputDevice()
93110
//

0 commit comments

Comments
 (0)