Skip to content

Commit 878888f

Browse files
committed
provide writeto_then_readfrom only if needed
1 parent 8d211f4 commit 878888f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_tca9548a.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class TCA9548A_Channel():
5757
def __init__(self, tca, channel):
5858
self.tca = tca
5959
self.channel_switch = bytearray([1 << channel])
60+
# provide only if needed
61+
if hasattr(self.tca.i2c, 'writeto_then_readfrom'):
62+
setattr(self, 'writeto_then_readfrom', self.writeto_then_readfrom_passthru)
6063

6164
def try_lock(self):
6265
"""Pass thru for try_lock."""
@@ -82,7 +85,7 @@ def writeto(self, address, buffer, **kwargs):
8285
raise ValueError("Device address must be different than TCA9548A address.")
8386
return self.tca.i2c.writeto(address, buffer, **kwargs)
8487

85-
def writeto_then_readfrom(self, address, buffer_out, buffer_in, **kwargs):
88+
def writeto_then_readfrom_passthru(self, address, buffer_out, buffer_in, **kwargs):
8689
"""Pass thru for writeto_then_readfrom."""
8790
#In linux, at least, this is a special kernel function call
8891
if address == self.tca.address:

0 commit comments

Comments
 (0)