2016-09-21 12:21:18 +00:00
|
|
|
from trezor import ui, loop, res
|
2016-09-26 14:11:38 +00:00
|
|
|
from trezor.utils import unimport
|
2016-04-30 13:57:08 +00:00
|
|
|
|
2016-12-14 10:10:01 +00:00
|
|
|
|
2016-08-05 10:34:47 +00:00
|
|
|
async def swipe_to_rotate():
|
2017-09-26 09:54:07 +00:00
|
|
|
from trezor.ui.swipe import Swipe, degrees
|
2016-09-26 14:11:38 +00:00
|
|
|
|
2017-09-26 09:54:07 +00:00
|
|
|
swipe = await Swipe(absolute=True)
|
|
|
|
ui.display.orientation(degrees(swipe))
|
2016-05-17 16:37:26 +00:00
|
|
|
|
|
|
|
|
2016-10-08 09:47:28 +00:00
|
|
|
async def dim_screen():
|
2017-09-16 13:00:31 +00:00
|
|
|
await loop.sleep(5 * 1000000)
|
2017-03-30 15:35:15 +00:00
|
|
|
await ui.backlight_slide(ui.BACKLIGHT_DIM)
|
|
|
|
while True:
|
2017-10-09 14:38:04 +00:00
|
|
|
await loop.sleep(10000000)
|
2016-05-25 12:27:22 +00:00
|
|
|
|
2016-12-14 10:10:01 +00:00
|
|
|
|
2017-11-03 10:49:41 +00:00
|
|
|
@ui.layout
|
|
|
|
async def display_homescreen():
|
2016-12-14 10:10:01 +00:00
|
|
|
from apps.common import storage
|
|
|
|
|
2017-04-01 21:33:28 +00:00
|
|
|
if not storage.is_initialized():
|
2018-01-24 17:28:10 +00:00
|
|
|
label = 'Open trezor.io/start'
|
2017-12-13 01:41:59 +00:00
|
|
|
image = None
|
2017-04-01 21:33:28 +00:00
|
|
|
else:
|
2017-11-03 10:49:41 +00:00
|
|
|
label = storage.get_label() or 'My TREZOR'
|
2017-12-13 01:41:59 +00:00
|
|
|
image = storage.get_homescreen()
|
|
|
|
|
|
|
|
if not image:
|
|
|
|
image = res.load('apps/homescreen/res/homescreen.toif')
|
|
|
|
|
|
|
|
ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG)
|
|
|
|
ui.display.avatar((ui.SCREEN - 144) // 2, (ui.SCREEN - 144) // 2 - 10, image, ui.WHITE, ui.BLACK)
|
2017-10-24 15:19:38 +00:00
|
|
|
ui.display.text_center(ui.SCREEN // 2, ui.SCREEN - 20, label, ui.BOLD, ui.FG, ui.BG)
|
2016-12-14 10:10:01 +00:00
|
|
|
|
2017-11-03 10:49:41 +00:00
|
|
|
await dim_screen()
|
|
|
|
|
2016-12-14 10:10:01 +00:00
|
|
|
|
|
|
|
@unimport
|
|
|
|
async def layout_homescreen():
|
2017-01-20 15:07:33 +00:00
|
|
|
while True:
|
2017-11-03 10:49:41 +00:00
|
|
|
await loop.wait(swipe_to_rotate(), display_homescreen())
|