You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/src/trezor/pin.py

58 lines
1.3 KiB

from trezor import ui
if False:
from typing import Any
def pin_to_int(pin: str) -> int:
6 years ago
return int("1" + pin)
7 years ago
_previous_progress = None
keepalive_callback = None # type: Any
def show_pin_timeout(seconds: int, progress: int, message: str) -> bool:
global _previous_progress
if callable(keepalive_callback):
keepalive_callback()
if progress == 0:
if progress != _previous_progress:
# avoid overdraw in case of repeated progress calls
ui.display.clear()
6 years ago
ui.display.text_center(
ui.WIDTH // 2, 37, message, ui.BOLD, ui.FG, ui.BG, ui.WIDTH
6 years ago
)
ui.display.loader(progress, False, 0, ui.FG, ui.BG)
if seconds == 0:
6 years ago
ui.display.text_center(
ui.WIDTH // 2, ui.HEIGHT - 22, "Done", ui.BOLD, ui.FG, ui.BG, ui.WIDTH
)
elif seconds == 1:
6 years ago
ui.display.text_center(
ui.WIDTH // 2,
ui.HEIGHT - 22,
"1 second left",
ui.BOLD,
ui.FG,
ui.BG,
ui.WIDTH,
)
else:
6 years ago
ui.display.text_center(
ui.WIDTH // 2,
ui.HEIGHT - 22,
"%d seconds left" % seconds,
ui.BOLD,
ui.FG,
ui.BG,
ui.WIDTH,
)
ui.display.refresh()
_previous_progress = progress
return False