Skip to content

Commit 10af0a9

Browse files
authored
Merge pull request #13 from MickeyDelp/wire_fix
Support alternate wire interfaces
2 parents ab804b5 + c5746fa commit 10af0a9

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

Adafruit_VL6180X.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ uint8_t Adafruit_VL6180X::read8(uint16_t address)
258258
{
259259
uint8_t data;
260260

261-
Wire.beginTransmission(_i2caddr);
262-
Wire.write(address>>8);
263-
Wire.write(address);
264-
Wire.endTransmission();
261+
_i2c->beginTransmission(_i2caddr);
262+
_i2c->write(address>>8);
263+
_i2c->write(address);
264+
_i2c->endTransmission();
265265

266-
Wire.requestFrom(_i2caddr, (uint8_t)1);
267-
data = Wire.read();
266+
_i2c->requestFrom(_i2caddr, (uint8_t)1);
267+
data = _i2c->read();
268268

269269
#if defined(I2C_DEBUG)
270270
Serial.print("\t$"); Serial.print(address, HEX); Serial.print(": 0x"); Serial.println(data, HEX);
@@ -279,27 +279,27 @@ uint16_t Adafruit_VL6180X::read16(uint16_t address)
279279
{
280280
uint16_t data;
281281

282-
Wire.beginTransmission(_i2caddr);
283-
Wire.write(address>>8);
284-
Wire.write(address);
285-
Wire.endTransmission();
282+
_i2c->beginTransmission(_i2caddr);
283+
_i2c->write(address>>8);
284+
_i2c->write(address);
285+
_i2c->endTransmission();
286286

287-
Wire.requestFrom(_i2caddr, (uint8_t)2);
288-
data = Wire.read();
287+
_i2c->requestFrom(_i2caddr, (uint8_t)2);
288+
data = _i2c->read();
289289
data <<= 8;
290-
data |= Wire.read();
290+
data |= _i2c->read();
291291

292292
return data;
293293
}
294294

295295
// write 1 byte
296296
void Adafruit_VL6180X::write8(uint16_t address, uint8_t data)
297297
{
298-
Wire.beginTransmission(_i2caddr);
299-
Wire.write(address>>8);
300-
Wire.write(address);
301-
Wire.write(data);
302-
Wire.endTransmission();
298+
_i2c->beginTransmission(_i2caddr);
299+
_i2c->write(address>>8);
300+
_i2c->write(address);
301+
_i2c->write(data);
302+
_i2c->endTransmission();
303303

304304
#if defined(I2C_DEBUG)
305305
Serial.print("\t$"); Serial.print(address, HEX); Serial.print(" = 0x"); Serial.println(data, HEX);
@@ -310,10 +310,10 @@ void Adafruit_VL6180X::write8(uint16_t address, uint8_t data)
310310
// write 2 bytes
311311
void Adafruit_VL6180X::write16(uint16_t address, uint16_t data)
312312
{
313-
Wire.beginTransmission(_i2caddr);
314-
Wire.write(address>>8);
315-
Wire.write(address);
316-
Wire.write(data>>8);
317-
Wire.write(data);
318-
Wire.endTransmission();
313+
_i2c->beginTransmission(_i2caddr);
314+
_i2c->write(address>>8);
315+
_i2c->write(address);
316+
_i2c->write(data>>8);
317+
_i2c->write(data);
318+
_i2c->endTransmission();
319319
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit_VL6180X
2-
version=1.0.5
2+
version=1.0.6
33
author=Adafruit
44
maintainer=adafruit <[email protected]>
55
sentence=Sensor driver for VL6180X Time of Flight sensor

0 commit comments

Comments
 (0)