From c662ff9fd5b18c38d76beff6e753efb74a0ee337 Mon Sep 17 00:00:00 2001 From: Rob Jauquet Date: Thu, 14 Nov 2024 11:38:44 -0500 Subject: [PATCH 1/2] add probe method --- adafruit_tca9548a.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adafruit_tca9548a.py b/adafruit_tca9548a.py index c766176..0cd2f45 100644 --- a/adafruit_tca9548a.py +++ b/adafruit_tca9548a.py @@ -98,6 +98,10 @@ def scan(self) -> List[int]: """Perform an I2C Device Scan""" return self.tca.i2c.scan() + def probe(self, address: int) -> bool: + """Check if an I2C device is at the specified address on the hub.""" + return self.tca.i2c.probe(address) + class TCA9548A: """Class which provides interface to TCA9548A I2C multiplexer.""" From a78092f93ae80944d6c09bf7521545c4a82e6493 Mon Sep 17 00:00:00 2001 From: Rob Jauquet Date: Thu, 14 Nov 2024 11:41:35 -0500 Subject: [PATCH 2/2] add backwards compatibility --- adafruit_tca9548a.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_tca9548a.py b/adafruit_tca9548a.py index 0cd2f45..cbb2fe4 100644 --- a/adafruit_tca9548a.py +++ b/adafruit_tca9548a.py @@ -100,7 +100,10 @@ def scan(self) -> List[int]: def probe(self, address: int) -> bool: """Check if an I2C device is at the specified address on the hub.""" - return self.tca.i2c.probe(address) + # backwards compatibility for circuitpython <9.2 + if hasattr(self.tca.i2c, "probe"): + return self.tca.i2c.probe(address) + return address in self.scan() class TCA9548A: