Skip to content

Commit b04a8bb

Browse files
authored
Merge pull request #7 from markus-k/reg-addr
Allow setting the I2C address register as kwarg
2 parents 1594054 + 8491940 commit b04a8bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adafruit_tlv493d.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class TLV493D:
5959
6060
:param busio.I2C i2c_bus: The I2C bus the TLV493D is connected to.
6161
:param int address: The I2C address of the TLV493D. Defaults to 0x5E.
62+
:param int addr_reg: Initial value of the I2C address register. Defaults to 0.
6263
6364
"""
6465

@@ -93,14 +94,17 @@ class TLV493D:
9394
"RES3": (3, 0x1F, 0),
9495
}
9596

96-
def __init__(self, i2c_bus, address=_TLV493D_DEFAULT_ADDRESS):
97+
def __init__(self, i2c_bus, address=_TLV493D_DEFAULT_ADDRESS, addr_reg=0):
9798
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
9899
self.read_buffer = bytearray(10)
99100
self.write_buffer = bytearray(4)
100101

101102
# read in data from sensor, including data that must be set on a write
102103
self._setup_write_buffer()
103104

105+
# write correct i2c address
106+
self._set_write_key("ADDR", addr_reg)
107+
104108
# setup MASTERCONTROLLEDMODE which takes a measurement for every read
105109
self._set_write_key("PARITY", 1)
106110
self._set_write_key("PARITY", 1)

0 commit comments

Comments
 (0)