mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-15 09:50:57 +00:00
add experimental animation with async for
This commit is contained in:
parent
3eaf001eef
commit
312859ba71
@ -10,9 +10,14 @@ async def swipe_to_rotate():
|
||||
|
||||
|
||||
async def animate_logo():
|
||||
def func(foreground):
|
||||
ui.display.icon(0, 0, res.load('apps/homescreen/res/trezor.toig'), foreground, ui.BLACK)
|
||||
await ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000)
|
||||
# def func(foreground):
|
||||
# ui.display.icon(0, 0, res.load(
|
||||
# 'apps/homescreen/res/trezor.toig'), foreground, ui.BLACK)
|
||||
# await ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000)
|
||||
|
||||
async for fg in ui.pulse_animation(ui.WHITE, ui.GREY, speed=400000):
|
||||
icon = res.load('apps/homescreen/res/trezor.toig')
|
||||
ui.display.icon(0, 0, icon, fg, ui.BLACK)
|
||||
|
||||
|
||||
@unimport_gen
|
||||
|
@ -76,6 +76,25 @@ def animate_pulse(func, ca, cb, speed=200000, delay=30000):
|
||||
yield loop.Sleep(delay)
|
||||
|
||||
|
||||
class pulse_animation:
|
||||
|
||||
def __init__(self, color_a, color_b, speed=200000, delay=30000):
|
||||
self.color_a = color_a
|
||||
self.color_b = color_b
|
||||
self.speed = speed
|
||||
self.delay = delay
|
||||
|
||||
async def __aiter__(self):
|
||||
return self
|
||||
|
||||
async def __anext__(self):
|
||||
# normalize sin from interval -1:1 to 0:1
|
||||
y = 0.5 + 0.5 * math.sin(utime.ticks_us() / self.speed)
|
||||
c = blend(self.color_a, self.color_b, y)
|
||||
await loop.Sleep(self.delay)
|
||||
return c
|
||||
|
||||
|
||||
def rotate_coords(pos: tuple) -> tuple:
|
||||
r = display.orientation()
|
||||
if r == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user