2018-02-27 02:05:15 +00:00
|
|
|
from trezor import ui, res
|
2018-02-27 15:35:21 +00:00
|
|
|
from trezor.ui.swipe import Swipe, degrees
|
|
|
|
from apps.common import storage
|
2016-04-30 13:57:08 +00:00
|
|
|
|
2016-12-14 10:10:01 +00:00
|
|
|
|
2018-02-27 15:35:21 +00:00
|
|
|
async def homescreen():
|
|
|
|
while True:
|
|
|
|
await ui.backlight_slide(ui.BACKLIGHT_DIM)
|
|
|
|
display_homescreen()
|
|
|
|
await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
|
|
|
|
await swipe_to_rotate()
|
2016-05-17 16:37:26 +00:00
|
|
|
|
|
|
|
|
2018-02-19 15:50:58 +00:00
|
|
|
def display_homescreen():
|
2017-04-01 21:33:28 +00:00
|
|
|
if not storage.is_initialized():
|
2018-01-27 16:42:08 +00:00
|
|
|
label = 'Go to 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:
|
2018-02-07 14:33:22 +00:00
|
|
|
image = res.load('apps/homescreen/res/bg.toif')
|
2017-12-13 01:41:59 +00:00
|
|
|
|
2018-02-26 23:19:43 +00:00
|
|
|
if storage.is_initialized() and storage.needs_backup():
|
|
|
|
ui.display.bar(0, 0, ui.WIDTH, 30, ui.YELLOW)
|
2018-03-01 00:13:26 +00:00
|
|
|
ui.display.text_center(ui.WIDTH // 2, 22, 'NEEDS BACKUP!', ui.BOLD, ui.BLACK, ui.YELLOW)
|
2018-02-26 23:19:43 +00:00
|
|
|
ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
|
|
|
|
else:
|
|
|
|
ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
|
2018-02-19 19:36:12 +00:00
|
|
|
ui.display.avatar(48, 48 - 10, image, ui.WHITE, ui.BLACK)
|
2018-03-01 00:13:26 +00:00
|
|
|
ui.display.text_center(ui.WIDTH // 2, 220, label, ui.BOLD, ui.FG, ui.BG)
|
2016-12-14 10:10:01 +00:00
|
|
|
|
|
|
|
|
2018-02-27 15:35:21 +00:00
|
|
|
async def swipe_to_rotate():
|
|
|
|
swipe = await Swipe(absolute=True)
|
|
|
|
ui.display.orientation(degrees(swipe))
|