Skip to content

Commit 34cd9a2

Browse files
authored
Merge pull request #34 from adafruit/thirdparty_nunchuk
Adding workaround for third-party nunchuks and RP2040
2 parents d29bf74 + e91d484 commit 34cd9a2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adafruit_nunchuk.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ def __init__(
6161
self, i2c: I2C, address: int = 0x52, i2c_read_delay: float = 0.002
6262
) -> None:
6363
self.buffer = bytearray(8)
64+
# -| HACK |---------------------------------------------------
65+
# fixes quirk with RP2040 + 3rd party controllers
66+
while not i2c.try_lock():
67+
pass
68+
_ = i2c.scan()
69+
i2c.unlock()
70+
# ------------------------------------------------------------
6471
self.i2c_device = I2CDevice(i2c, address)
6572
self._i2c_read_delay = i2c_read_delay
6673
time.sleep(_I2C_INIT_DELAY)

0 commit comments

Comments
 (0)