Skip to content

Commit ef5228a

Browse files
committed
Added _VL53L1X_I2C_SLAVE_DEVICE_ADDRESS const and used struct.pack to convert int to bytes
1 parent 7f764c5 commit ef5228a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_vl53l1x.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# imports__version__ = "0.0.0-auto.0"
3535
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X.git"
3636

37+
_VL53L1X_I2C_SLAVE_DEVICE_ADDRESS = const(0x0001)
3738
_VL53L1X_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND = const(0x0008)
3839
_GPIO_HV_MUX__CTRL = const(0x0030)
3940
_GPIO__TIO_HV_STATUS = const(0x0031)
@@ -309,6 +310,7 @@ def set_address(self, new_address):
309310
multiple VL53L0X sensors on the same I2C bus (SDA & SCL pins). See also the
310311
`example <examples.html#multiple-vl53l1x-on-same-i2c-bus>`_ for proper usage.
311312
"""
312-
new_addres_as_byte_string = new_address.to_bytes(1, "little")
313-
self._write_register(0x01, new_addres_as_byte_string)
313+
self._write_register(
314+
_VL53L1X_I2C_SLAVE_DEVICE_ADDRESS, struct.pack(">B", new_address)
315+
)
314316
self.i2c_device = i2c_device.I2CDevice(self._i2c, new_address)

0 commit comments

Comments
 (0)