1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-24 06:11:06 +00:00

core/ui: add note on yield usage

This commit is contained in:
Tomas Susanka 2019-08-21 15:14:25 +02:00
parent c9a78d7bcb
commit ba7b5c7232

View File

@ -289,6 +289,7 @@ class Layout(Component):
"""Task that is waiting for the user input."""
touch = loop.wait(io.TOUCH)
while True:
# Using `yield` instead of `await` to avoid allocations.
event, x, y = yield touch
self.dispatch(event, x, y)
# We dispatch a render event right after the touch. Quick and dirty
@ -314,7 +315,7 @@ class Layout(Component):
while True:
# Wait for a couple of ms and render the layout again. Because
# components use re-paint marking, they do not really draw on the
# display needlessly.
# display needlessly. Using `yield` instead of `await` to avoid allocations.
# TODO: remove the busy loop
yield sleep
self.dispatch(RENDER, 0, 0)