1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 01:18:28 +00:00

test async/await support in homescreen layout

This commit is contained in:
Jan Pochyla 2016-08-05 12:34:47 +02:00 committed by Pavol Rusnak
parent c8c34c875b
commit a4d1b27541
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 8 additions and 8 deletions

View File

@ -3,20 +3,20 @@ from trezor.ui.swipe import Swipe
from trezor.utils import unimport_gen
def swipe_to_rotate():
async def swipe_to_rotate():
while True:
degrees = yield from Swipe(absolute=True).wait()
degrees = await Swipe(absolute=True)
ui.display.orientation(degrees)
def animate_logo():
async def animate_logo():
def func(foreground):
ui.display.icon(0, 0, res.load('apps/homescreen/res/trezor.toig'), foreground, ui.BLACK)
yield from ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000)
await ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000)
@unimport_gen
def layout_homescreen(initialize_msg=None):
async def layout_homescreen(initialize_msg=None):
if initialize_msg is not None:
from trezor.messages.Features import Features
features = Features()
@ -35,7 +35,7 @@ def layout_homescreen(initialize_msg=None):
features.passphrase_cached = False
features.passphrase_protection = False
features.vendor = 'bitcointrezor.com'
yield from wire.write(features)
yield loop.Wait([dispatcher.dispatch(),
await wire.write(features)
await loop.Wait([dispatcher.dispatch(),
swipe_to_rotate(),
animate_logo()])

View File

@ -63,7 +63,7 @@ class Swipe():
self.end_pos = None
self.end_time = 0
def wait(self):
def __iter__(self):
while True:
event, *pos = yield loop.Select(loop.TOUCH)
result = self.send(event, pos)