1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-03 11:20:59 +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.""" """Task that is waiting for the user input."""
touch = loop.wait(io.TOUCH) touch = loop.wait(io.TOUCH)
while True: while True:
# Using `yield` instead of `await` to avoid allocations.
event, x, y = yield touch event, x, y = yield touch
self.dispatch(event, x, y) self.dispatch(event, x, y)
# We dispatch a render event right after the touch. Quick and dirty # We dispatch a render event right after the touch. Quick and dirty
@ -314,7 +315,7 @@ class Layout(Component):
while True: while True:
# Wait for a couple of ms and render the layout again. Because # Wait for a couple of ms and render the layout again. Because
# components use re-paint marking, they do not really draw on the # 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 # TODO: remove the busy loop
yield sleep yield sleep
self.dispatch(RENDER, 0, 0) self.dispatch(RENDER, 0, 0)