mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 01:18:28 +00:00
core/ui: Add offset parameter to ui.pulse() and specify the pulse rate in terms of period.
This commit is contained in:
parent
2142b37f86
commit
5cbbcd0ce7
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user