adafruit / Adafruit_CircuitPython_PyBadger

Badge-focused CircuitPython helper library for PyBadge, PyBadge LC, PyGamer and CLUE
MIT License
21 stars 26 forks source link

Pybadge LC compatibility #54

Closed FoamyGuy closed 2 years ago

FoamyGuy commented 2 years ago

resolves: #53

This change will run an i2c.scan() and check for the presence of the accelerometer (addresses 0x18 or 0x19) before attempting to initialize it. I believe this should make the library compatible with the PyBadge LC variant which does not have the accelerometer populated.

I tested the updated library using the simpletest with an Edge Badge to ensure that accelerometer readings are still working normally.

I don't have the LC variant of the hardware. But it would be great if someone who does can test this change on it as well to ensure there isn't something I missed still causing incompatibility.

FoamyGuy commented 2 years ago

I am going to cancel the current actions workflow for this PR because sphinx is stuck in an infinite loop due to the while statement that is trying to lock the I2C bus.

FoamyGuy commented 2 years ago

Alright. It's' passing actions checks now. I changed the try_lock() logic from an infinite loop to attempt at most 10 times and then give up.

Re-tested with the latest version on EdgeBadge and acceleration readings do still work properly on that device.