1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-01 11:01:00 +00:00
trezor-firmware/src/apps/homescreen/homescreen.py

44 lines
1.0 KiB
Python
Raw Normal View History

from trezor import ui, loop, res
from trezor.utils import unimport
2016-04-30 13:57:08 +00:00
2016-12-14 10:10:01 +00:00
async def swipe_to_rotate():
from trezor.ui.swipe import Swipe
2016-05-17 16:37:26 +00:00
while True:
degrees = await Swipe(absolute=True)
2016-05-17 16:37:26 +00:00
ui.display.orientation(degrees)
async def dim_screen():
current = ui.display.backlight()
2016-12-14 10:10:01 +00:00
await loop.Sleep(5 * 1000000)
await ui.backlight_slide(ui.BACKLIGHT_DIM)
try:
while True:
await loop.Sleep(1000000)
2016-12-14 10:10:01 +00:00
finally:
# Return back to original brightness
ui.display.backlight(current)
2016-12-14 10:10:01 +00:00
def display_homescreen():
from apps.common import storage
image = res.load('apps/homescreen/res/trezor.toig')
ui.display.icon(0, 0, image, ui.WHITE, ui.BLACK)
2016-12-14 10:10:01 +00:00
ui.display.bar(0, 180, 240, 240, ui.BLACK)
label = storage.get_label() or 'My TREZOR'
ui.display.text_center(120, 210, label, ui.BOLD, ui.WHITE, ui.BLACK)
@unimport
async def layout_homescreen():
display_homescreen()
ui.display.backlight(ui.BACKLIGHT_NORMAL)
2016-12-14 10:10:01 +00:00
await loop.Wait([swipe_to_rotate(), dim_screen()])