Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 7 commits into from
Jul 23, 2019

Conversation

makermelissa
Copy link
Collaborator

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

@makermelissa makermelissa requested a review from a team July 22, 2019 20:51
Copy link
Member

@tannewt tannewt left a 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.

@makermelissa
Copy link
Collaborator Author

Do you happen to know what the board name returned from os.uname().machine is for the PyBadge LC? In the boards directory, there's only pybadge and not pybadge_lc or similar.

@tannewt
Copy link
Member

tannewt commented Jul 22, 2019

Oh, interesting! I don't know.

I guess the only thing I'd suggest is putting the try/except as nested as possible.

@makermelissa
Copy link
Collaborator Author

Ok cool, I wasn't aware you could nest them.

@tannewt
Copy link
Member

tannewt commented Jul 22, 2019

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.

@makermelissa
Copy link
Collaborator Author

Ok, maybe this is closer to what you meant.

@makermelissa makermelissa changed the title First attempts at PyBadge LC fix (Untested) Remove Accelerometer Init for PyBadge LC (Untested) Jul 22, 2019
@makermelissa makermelissa changed the title Remove Accelerometer Init for PyBadge LC (Untested) Remove Accelerometer Init for PyBadge LC Jul 23, 2019
Copy link
Member

@tannewt tannewt left a 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.

@tannewt tannewt merged commit e666724 into adafruit:master Jul 23, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 24, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throws I2C Exception on PyBadge LC
3 participants