Hi there,
I am looking for a good event-driven architecture to develop GUI on ESP32 board. My basic task is to, for example, react on touch screen and other interrupts without writing much code. The payload I am looking into may run for a while so I am probably looking at uasyncio. Can anybody point at a good library/example?
Event construction in micropython
Re: Event construction in micropython
The second one is a monster library compared to my expectations. It looks like it polls touch hardware in a loop: pin_irq is not even used! Besides, it is hard-nailed to pyboard.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Event construction in micropython
This GUI repo for the official display is capable of running on an ESP32. It uses uasyncio internally: applications can use it if required or simply respond to callbacks. For larger displays there is this one which is also designed for portability.
Polling touch hardware actually works well. IRQ's are great when you need sub-millisecond response times but touch GUI's simply aren't in that category. You simply require a visibly quick response.
As for size, any GUI is likely to involve a significant amount of code. This one has been designed as a Python package so you only import what you need: this minimises RAM use.
Polling touch hardware actually works well. IRQ's are great when you need sub-millisecond response times but touch GUI's simply aren't in that category. You simply require a visibly quick response.
As for size, any GUI is likely to involve a significant amount of code. This one has been designed as a Python package so you only import what you need: this minimises RAM use.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Event construction in micropython
I have appended this section to the uasyncio tutorial to justify the use of polling in such applications.
tl;dr With a cooperative scheduler, if you want to trigger a coroutine from a hardware change, interrupts offer no performance gain compared to polling the hardware.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Event construction in micropython
Yes, 100% agree. Great explanation.pythoncoder wrote: ↑Mon Oct 26, 2020 3:59 pmI have appended this section to the uasyncio tutorial to justify the use of polling in such applications.
tl;dr With a cooperative scheduler, if you want to trigger a coroutine from a hardware change, interrupts offer no performance gain compared to polling the hardware.
Re: Event construction in micropython
I have to admit I ended up with the same kind of an infinite loop polling event queue. Events are added via interrupts. I also have to admit that having a single event slot per type instead of a queue seems to be a reasonable choice for touch events at least.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Event construction in micropython
I have updated the touch GUI for the official display to simplify deployment to the ESP32, and also added new widgets.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.