From 5cbbcd0ce736d4ffa42dfec755bd809391061588 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Thu, 8 Aug 2019 15:31:03 +0200 Subject: [PATCH] core/ui: Add offset parameter to ui.pulse() and specify the pulse rate in terms of period. --- core/src/trezor/ui/__init__.py | 4 ++-- core/src/trezor/ui/scroll.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/trezor/ui/__init__.py b/core/src/trezor/ui/__init__.py index e56ed71438..cffd0859b0 100644 --- a/core/src/trezor/ui/__init__.py +++ b/core/src/trezor/ui/__init__.py @@ -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: diff --git a/core/src/trezor/ui/scroll.py b/core/src/trezor/ui/scroll.py index 9015ae92d9..dd15f62871 100644 --- a/core/src/trezor/ui/scroll.py +++ b/core/src/trezor/ui/scroll.py @@ -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)