1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

core/ui: Add offset parameter to ui.pulse() and specify the pulse rate in terms of period.

This commit is contained in:
Andrew Kozlik 2019-08-08 15:31:03 +02:00
parent 2142b37f86
commit 5cbbcd0ce7
2 changed files with 4 additions and 4 deletions

View File

@ -70,9 +70,9 @@ from trezor.ui import style # isort:skip
from trezor.ui.style import * # isort:skip # noqa: F401,F403
def pulse(coef: int) -> float:
def pulse(period: int, offset: int = 0) -> float:
# normalize sin from interval -1:1 to 0:1
return 0.5 + 0.5 * math.sin(utime.ticks_us() / coef)
return 0.5 + 0.5 * math.sin(2 * math.pi * (utime.ticks_us() + offset) / period)
async def click() -> Pos:

View File

@ -32,10 +32,10 @@ def render_scrollbar(pages: int, page: int) -> None:
def render_swipe_icon() -> None:
DRAW_DELAY = const(200000)
PULSE_PERIOD = const(1200000)
icon = res.load(ui.ICON_SWIPE)
t = ui.pulse(DRAW_DELAY)
t = ui.pulse(PULSE_PERIOD)
c = ui.blend(ui.GREY, ui.DARK_GREY, t)
ui.display.icon(70, 205, icon, c, ui.BG)