From 98791d07c308a199fe9c8ea0518633accfe909af Mon Sep 17 00:00:00 2001 From: Daan Steenbergen Date: Mon, 25 Jul 2022 16:16:37 +0200 Subject: [PATCH 1/2] fix: stop blocking when not able to lock --- adafruit_tca9548a.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adafruit_tca9548a.py b/adafruit_tca9548a.py index 4034a2a..af77456 100644 --- a/adafruit_tca9548a.py +++ b/adafruit_tca9548a.py @@ -29,6 +29,7 @@ """ +import time from micropython import const _DEFAULT_ADDRESS = const(0x70) @@ -49,6 +50,7 @@ def __init__(self, tca, channel): def try_lock(self): """Pass through for try_lock.""" while not self.tca.i2c.try_lock(): + time.sleep(0) pass self.tca.i2c.writeto(self.tca.address, self.channel_switch) return True From 48516aaab0200e4772ef0239a154e31527932444 Mon Sep 17 00:00:00 2001 From: Daan Steenbergen Date: Mon, 25 Jul 2022 16:34:22 +0200 Subject: [PATCH 2/2] refactor: remove unnecessary pass statement --- adafruit_tca9548a.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_tca9548a.py b/adafruit_tca9548a.py index af77456..f4d9aca 100644 --- a/adafruit_tca9548a.py +++ b/adafruit_tca9548a.py @@ -51,7 +51,6 @@ def try_lock(self): """Pass through for try_lock.""" while not self.tca.i2c.try_lock(): time.sleep(0) - pass self.tca.i2c.writeto(self.tca.address, self.channel_switch) return True