mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-12 20:08:46 +00:00
test async/await support in homescreen layout
This commit is contained in:
parent
c8c34c875b
commit
a4d1b27541
@ -3,20 +3,20 @@ from trezor.ui.swipe import Swipe
|
|||||||
from trezor.utils import unimport_gen
|
from trezor.utils import unimport_gen
|
||||||
|
|
||||||
|
|
||||||
def swipe_to_rotate():
|
async def swipe_to_rotate():
|
||||||
while True:
|
while True:
|
||||||
degrees = yield from Swipe(absolute=True).wait()
|
degrees = await Swipe(absolute=True)
|
||||||
ui.display.orientation(degrees)
|
ui.display.orientation(degrees)
|
||||||
|
|
||||||
|
|
||||||
def animate_logo():
|
async def animate_logo():
|
||||||
def func(foreground):
|
def func(foreground):
|
||||||
ui.display.icon(0, 0, res.load('apps/homescreen/res/trezor.toig'), foreground, ui.BLACK)
|
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
|
@unimport_gen
|
||||||
def layout_homescreen(initialize_msg=None):
|
async def layout_homescreen(initialize_msg=None):
|
||||||
if initialize_msg is not None:
|
if initialize_msg is not None:
|
||||||
from trezor.messages.Features import Features
|
from trezor.messages.Features import Features
|
||||||
features = Features()
|
features = Features()
|
||||||
@ -35,7 +35,7 @@ def layout_homescreen(initialize_msg=None):
|
|||||||
features.passphrase_cached = False
|
features.passphrase_cached = False
|
||||||
features.passphrase_protection = False
|
features.passphrase_protection = False
|
||||||
features.vendor = 'bitcointrezor.com'
|
features.vendor = 'bitcointrezor.com'
|
||||||
yield from wire.write(features)
|
await wire.write(features)
|
||||||
yield loop.Wait([dispatcher.dispatch(),
|
await loop.Wait([dispatcher.dispatch(),
|
||||||
swipe_to_rotate(),
|
swipe_to_rotate(),
|
||||||
animate_logo()])
|
animate_logo()])
|
||||||
|
@ -63,7 +63,7 @@ class Swipe():
|
|||||||
self.end_pos = None
|
self.end_pos = None
|
||||||
self.end_time = 0
|
self.end_time = 0
|
||||||
|
|
||||||
def wait(self):
|
def __iter__(self):
|
||||||
while True:
|
while True:
|
||||||
event, *pos = yield loop.Select(loop.TOUCH)
|
event, *pos = yield loop.Select(loop.TOUCH)
|
||||||
result = self.send(event, pos)
|
result = self.send(event, pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user