Reworked homescreen (no blinking, only diming)

Added ui.alert()
pull/25/head
slush0 8 years ago
parent 313b5f92e8
commit cf38b58a73

@ -1,7 +1,6 @@
from trezor import ui, loop, res
from trezor.utils import unimport
async def swipe_to_rotate():
from trezor.ui.swipe import Swipe
@ -10,14 +9,32 @@ async def swipe_to_rotate():
ui.display.orientation(degrees)
'''
async def animate_logo():
image = res.load('apps/homescreen/res/trezor.toig')
def render(fg):
ui.display.icon(0, 0, image, fg, ui.BLACK)
await ui.animate_pulse(render, ui.WHITE, ui.DARK_GREY, speed=400000)
await ui.animate_pulse(render, ui.WHITE, ui.DARK_GREY, speed=800000)
'''
async def dim_screen():
current = ui.display.backlight()
await loop.Sleep(5*1000000)
await ui.backlight_slide(ui.BACKLIGHT_DIM)
try:
while True:
await loop.Sleep(1000000)
except:
# Return back to original brightness
ui.display.backlight(current)
@unimport
async def layout_homescreen():
await loop.Wait([swipe_to_rotate(), animate_logo()])
image = res.load('apps/homescreen/res/trezor.toig')
ui.display.icon(0, 0, image, ui.WHITE, ui.BLACK)
ui.display.backlight(ui.BACKLIGHT_NORMAL)
await loop.Wait([swipe_to_rotate(), dim_screen()])

@ -45,6 +45,10 @@ MONO = Display.FONT_MONO
NORMAL = Display.FONT_NORMAL
BOLD = Display.FONT_BOLD
BACKLIGHT_NORMAL = const(127)
BACKLIGHT_DIM = const(70)
BACKLIGHT_MAX = const(255)
# icons
ICON_RESET = 'trezor/res/reset.toig'
ICON_WIPE = 'trezor/res/wipe.toig'
@ -66,6 +70,25 @@ def blend(ca: int, cb: int, t: float) -> int:
lerpi((ca << 3) & 0xF8, (cb << 3) & 0xF8, t))
def alert(count=3):
current = display.backlight()
for i in range(count*2):
if i % 2 == 0:
display.backlight(BACKLIGHT_MAX)
yield loop.Sleep(20000)
else:
display.backlight(BACKLIGHT_NORMAL)
yield loop.Sleep(80000)
display.backlight(current)
def backlight_slide(val, speed=20000):
current = display.backlight()
for i in range(current, val, -1 if current > val else 1):
display.backlight(i)
await loop.Sleep(speed)
def animate_pulse(func, ca, cb, speed=200000, delay=30000):
while True:
# normalize sin from interval -1:1 to 0:1

Loading…
Cancel
Save