-
Notifications
You must be signed in to change notification settings - Fork 25
Remove Accelerometer Init for PyBadge LC #5
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind swapping this away from try/except to reading the board name from os.uname().machine
? That will make the supported versions more explicit.
Do you happen to know what the board name returned from |
Oh, interesting! I don't know. I guess the only thing I'd suggest is putting the try/except as nested as possible. |
Ok cool, I wasn't aware you could nest them. |
Sorry, that's not what I meant. The RuntimeError try/except should be as nested as possible so that it only catches exceptions from board.I2C(). IE, it should be inside the if. Having it at this outer level risks catching other exceptions and is generally harder to read than proactive code. In general, exceptions shouldn't be caught when the code can be written to know ahead of time. For example, the second try/catch could be replaced by an i2c scan to determine the address prior to calling the device constructor. Doing so would deduplicate the call to the constructor and clarify things. |
Ok, maybe this is closer to what you meant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! Looks good. Thank you.
Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.1.0 from 3.0.5: > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#45 from brentru/pygamer-pybadge-compat > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#44 from brentru/patch-restclient-method Updating https://github.com/adafruit/Adafruit_CircuitPython_PyBadger to 0.9.1 from 0.9.0: > Merge pull request adafruit/Adafruit_CircuitPython_PyBadger#5 from makermelissa/master Updating https://github.com/adafruit/Adafruit_CircuitPython_ to 2.0.1 from 2.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_#12 from brentru/patch-pyportal-compat
I don't have a PyBadge LC, but hopefully this fixes #4 which is the issue with the PyBadge LC not having an accelerometer. PLEASE TEST before approving. Thanks