-
Notifications
You must be signed in to change notification settings - Fork 16
adding display button example #21
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
examples/asyncio_displayio_button.py
Outdated
count -= 1 | ||
|
||
|
||
async def monitor_color_button(button, button_state): |
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 any way to prevent this coroutine from reading touches on the other buttons? I think it would be better to have a single coroutine reading the touch screen events.
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.
The latest commit refactors the touch handling into a single coroutine that calls the separate handle functions for each of the button types.
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!
I tested on the PyPortal and found one weirdness that I can't explain. If I keep pressing the "invert colors" button a lot, pretty fast. Eventually the green button disappears and never returns. I suspect that it's going transparent and somehow not retriggering a "make_opaque". But an initial look in the code didn't turn up a clear answer. It's a minor issue but was strange. |
|
||
# use built-in display | ||
display = board.DISPLAY | ||
|
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.
Needed a display.rotation = 0
here or the touch position didn't match the display after being changed in a different piece of code.
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.
Ordinarily the display will default to 0
rotation but since the display stays alive after the circuitpython VM instance is gone or restarts it would keep it's rotation if it did get changed.
It would be good practice to include the explict code to set it back to 0
just in case it has been changed in the users environment. I'll add a commit now. with this change. Thanks for the suggestion.
If you don't touch anything it will eventually disappear after about 15 seconds. Recorded screen: https://youtu.be/5gCUo6tLKzg |
Thanks for the testing and feedback everyone! Much appreciated! @aioue Thanks for recording this and sharing the video. and @kmatch98 if this is the same issue you noticed. In this case the green circle intentionally disappears after a while. On line 308 in the example:
The 3rd argument indicates the number of times to run the blink action. This is set to 20, so the green circle blinks 20 times and then disappears and isn't shown again. I included this one to show an example of tasks that operate a certain number of times and then conclude. This code was originall inpspired by the LED examples in the cooperative multi-tasking guide: https://learn.adafruit.com/cooperative-multitasking-in-circuitpython-with-asyncio/concurrent-tasks#two-leds-3106214-5 which are coded with a very similar The blue circle uses
|
LGTM, keen to see this get merged and improved on - the other PyPortal UI guide doesn't use async and is somewhat laggy 😄 |
Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1106 to 1.2.3 from 1.2.2: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1106#9 from tekktrik/dev/remove-int > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1106#8 from tekktrik/dev/change-data-to-bytes > Fixed readthedocs build > Post-patch cleanup pt 2 > Post-patch cleanup > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107 to 1.5.2 from 1.5.1: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1107#13 from tekktrik/dev/change-data-to-bytes > Fixed readthedocs build > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306 to 1.5.3 from 1.5.2: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306#26 from tekktrik/dev/change-data-to-bytes > Fixed readthedocs build > Post-patch cleanup > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch to 1.4.0 from 1.3.0: > Merge pull request adafruit/Adafruit_CircuitPython_FocalTouch#25 from winneymj/main Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1322 to 1.3.1 from 1.3.0: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1322#16 from tekktrik/dev/send-bytes Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L4CD to 1.0.1 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_VL53L4CD#2 from caternuson/typo_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_asyncio to 0.5.8 from 0.5.7: > Merge pull request adafruit/Adafruit_CircuitPython_asyncio#21 from FoamyGuy/display_button_example Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.11.3 from 1.11.1: > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#67 from FoamyGuy/docs_fixes > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#66 from FoamyGuy/docs_fixes Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.11.0 from 1.10.7: > Merge pull request adafruit/Adafruit_CircuitPython_Requests#102 from dhalbert/cleanup
adds a new example that illustrates the usage of Display_Button with asyncio using some blinking vectorio.Circle objects instead of blinking LEDs and physical momentary switches.