Skip to content

make TCA work for slaves with same address or even in general #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions adafruit_tca9548a.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,22 @@ def readfrom_into(self, address, buffer, **kwargs):
"""Pass through for readfrom_into."""
if address == self.tca.address:
raise ValueError("Device address must be different than TCA9548A address.")
self.tca.i2c.writeto(self.tca.address, self.channel_switch)
return self.tca.i2c.readfrom_into(address, buffer, **kwargs)

def writeto(self, address, buffer, **kwargs):
"""Pass through for writeto."""
if address == self.tca.address:
raise ValueError("Device address must be different than TCA9548A address.")
self.tca.i2c.writeto(self.tca.address, self.channel_switch)
return self.tca.i2c.writeto(address, buffer, **kwargs)

def writeto_then_readfrom(self, address, buffer_out, buffer_in, **kwargs):
"""Pass through for writeto_then_readfrom."""
# In linux, at least, this is a special kernel function call
if address == self.tca.address:
raise ValueError("Device address must be different than TCA9548A address.")
self.tca.i2c.writeto(self.tca.address, self.channel_switch)
return self.tca.i2c.writeto_then_readfrom(
address, buffer_out, buffer_in, **kwargs
)
Expand Down