def show_pin_timeout(seconds: int, progress: int, message: str) -> bool: global _previous_progress global _previous_seconds if callable(keepalive_callback): keepalive_callback() if progress == 0: if progress != _previous_progress: # avoid overdraw in case of repeated progress calls ui.display.clear() _previous_seconds = None ui.display.text_center(ui.WIDTH // 2, 37, message, ui.BOLD, ui.FG, ui.BG, ui.WIDTH) if not utils.DISABLE_ANIMATION: ui.display.loader(progress, False, 0, ui.FG, ui.BG) if seconds != _previous_seconds: if seconds == 0: remaining = "Done" elif seconds == 1: remaining = "1 second left" else: remaining = "%d seconds left" % seconds ui.display.text_center(ui.WIDTH // 2, ui.HEIGHT - 22, remaining, ui.BOLD, ui.FG, ui.BG, ui.WIDTH) _previous_seconds = seconds ui.refresh() _previous_progress = progress return False
def _start_progress() -> None: # Because we are drawing to the screen manually, without a layout, we # should make sure that no other layout is running. At this point, only # the homescreen should be on, so shut it down. workflow.kill_default() ui.backlight_fade(ui.BACKLIGHT_DIM) ui.display.clear() ui.header("Please wait") ui.refresh() ui.backlight_fade(ui.BACKLIGHT_NORMAL)
def _render_progress(progress: int, total: int) -> None: p = 1000 * progress // total ui.display.loader(p, False, 18, ui.WHITE, ui.BG) ui.refresh()