-
Notifications
You must be signed in to change notification settings - Fork 25
Refactor to include CLUE #23
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
merge badge changes into clue adaptation
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.
lgtm but did not test on hardware!
Want to update the |
@caternuson Yes. I missed that. The example? Or is there more that needs to be updated. |
@kattni the sentence in the introduction section could mention CLUE along with pybadge and pygamers as devices the library is made to be used with. |
@FoamyGuy Already fixed, thanks! |
@makermelissa Thank you so much for thorough testing! |
You're welcome. I know it didn't get tested as thoroughly the first time we did PyBadger. |
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.
Code looks good to me. Tested on PyBadge, EdgeBadge, CLUE, and PyGamer.
@FoamyGuy Made a valid point regarding leaving in the d-pad treatment of the joystick on PyGamer. He's going to test this refactor tonight with a game example he wrote for PyBadge/PyGamer and let me know if it's worth keeping in. I removed it as it seemed redundant, but it allows for programs using the d-pad functionality to work on PyBadge and PyGamer with no changes, something I had not considered. He will reply here to let me know, and I may add that back in, meaning it will need to be tested again on PyGamer. @makermelissa I will ping you as well if I make the change. |
@kattni, are you saying we would add the joystick d-pad functionality back in, and retain the analog joystick function? I hope that's what you're saying, as I think having both would be very useful. |
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.
Looks great! Nice job!
@makermelissa Yes, both would remain in. |
adafruit_pybadger/pygamer.py
Outdated
|
||
from adafruit_pybadger import PyBadger | ||
|
||
pybadger = PyBadger() |
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.
I think some of the comments still have the old style example usage instead of the new way:
from adafruit_pybadger import pybadger
pybadge and clue files have some as well this way.
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.
Nice catch
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.
Good catch! Thank you!
I do think it's worth having the joystick to D-pad buttons treatment. I tested this out with my game example on EdgeBadge and PyGamer, and it does break with the current code on the PyGamer. Users could implement this logic in the application layer like inside my game, but I do think it's nicer to have one simple interface across the PyGamer and PyBadge devices so potential app and game developers don't have to worry about the difference if they aren't using the joystick in a more analog way. |
@FoamyGuy Please test the changes I pushed. Thanks! |
@kattni I'm getting this error on PyGamer now:
|
@FoamyGuy I'll look into it. |
@kattni took a peek myself as well. Looks like it needs this:
I added that back in and it's working now. |
@FoamyGuy Already pushed :) |
testing the new one now |
@kattni working perfectly now :) thank you! |
@makermelissa If you could test the update as well, I'd appreciate it. Thanks! |
Sure thing @kattni |
It seems to be working great. |
@makermelissa Thank you very much! |
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.
One question and one minor nit, otherwise LGTM 👍
digitalio.DigitalInOut(board.BUTTON_OUT), | ||
digitalio.DigitalInOut(board.BUTTON_LATCH)) | ||
|
||
self._light_sensor = analogio.AnalogIn(board.A7) |
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.
Is there a way to check if the light sensor isn't present, like for the pybadge LC?
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.
PyBadge LC has a light sensor. It's at the top, next to the reset button, with a hole over it to pass the front of the sensor through to the front of the board. From the back, it is white with a green symbol printed on it.
The lack of a light sensor would only be detectable in very specific situations (depending on whether the pin is connected to something else, has pull up or down, etc), and is a complicated process to do so. Knowing that the CLUE doesn't have the same light sensor, I included it in the unsupported
list within the CLUE module. In the case of PyBadge vs. PyBadge LC, there's no way to tell the difference as they use the same CircuitPython build - there is no separate pin definition for PyBadge LC.
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.
D'oh, I meant the accelerometer, not the light sensor.
If it's possible to auto detect that, then this line from the example could be modified or removed to make the experience on a PyBadge LC a little nicer.
pybadger.auto_dim_display(delay=10) # Remove or comment out this line if you have the PyBadge LC |
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.
Try checking what pybadger.acceleration
returns on the LC. I think it might end up as None
on there but I don't have one to check with.
Along the same idea of improving the auto_dim: what if pressing any button would reset the dim timer. That would help all of the boards and allow for at least one type of auto_dim on the LC device.
Updating https://github.com/adafruit/Adafruit_CircuitPython_HT16K33 to 3.2.2 from 3.2.1: > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#60 from geekguy-wy/adding_demos_and_tests Updating https://github.com/adafruit/Adafruit_CircuitPython_PyBadger to 2.0.0 from 1.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_PyBadger#23 from kattni/clue-adaptation
THIS IS A BREAKING CHANGE. Import is no longer the same and the library no longer requires instantiation. It is now:
All code beyond import and instantiation should function the same if library was instantiated as
pybadger
. To use features, simply include them aspybadger.foo
, e.g.:Updates:
Tested on PyBadge/LC, PyGamer and CLUE.
@nnja Feel free to test this with your code.