1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00

First apps - homepage, playground

This commit is contained in:
slush0 2016-04-28 23:43:34 +02:00 committed by Pavol Rusnak
parent de83114dc7
commit f22511f036
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
7 changed files with 93 additions and 0 deletions

0
src/apps/__init__.py Normal file
View File

View File

@ -0,0 +1,15 @@
# Every application is supposed to have two entry points:
#
# boot() is called during device boot time and it should prepare
# all global things necessary to run.
#
# dispatch() is called once event subscribed in boot() is received.
def dispatch():
# Callback for HID messages
print("Dispatch homescreen")
def boot():
# Initilize app on boot time.
# This should hookup HID message types dispatcher() wants to receive.
print("Boot homescreen")

View File

@ -0,0 +1,19 @@
from trezor import ui
from trezor import loop
from trezor import layout
def layout_homescreen():
print("Homescreen layout!")
from apps import playground
loop.call_later(5 * 1000000, layout.change(playground.layout_tap_to_confirm('1BitkeyP2nDd5oa64x7AjvBbbwST54W5Zmx2', 110.126967, 'BTC')))
ui.display.bar(0, 0, 240, 240, ui.WHITE)
f = open('apps/homescreen/trezor.toig', 'r')
def func(foreground):
f.seek(0)
ui.display.icon(0, 0, f.read(), foreground, ui.BLACK)
yield from ui.animate_pulse(func, SPEED=400000, BASE_COLOR=(0xff, 0xff, 0xff), MIN_COLOR=0xaa, MAX_COLOR=0xff)

Binary file not shown.

View File

@ -0,0 +1,59 @@
from trezor import loop
from trezor import layout
from trezor import ui
from trezor.utils import unimport_func
def layout_tap_to_confirm(address, amount, currency):
from trezor.main import _main_layout
loop.call_later(5 * 1000000, layout.change(_main_layout()))
ui.display.bar(0, 0, 240, 40, ui.GREEN)
ui.display.bar(0, 40, 240, 200, ui.WHITE)
ui.display.text(10, 28, 'Sending', ui.BOLD, ui.WHITE, ui.GREEN)
ui.display.text(10, 80, '%f %s' % (amount, currency), ui.BOLD, ui.BLACK, ui.WHITE)
ui.display.text(10, 110, 'to this address:', ui.NORMAL, ui.BLACK, ui.WHITE)
ui.display.text(10, 140, address[:18], ui.MONO, ui.BLACK, ui.WHITE)
ui.display.text(10, 160, address[18:], ui.MONO, ui.BLACK, ui.WHITE)
f = open('apps/playground/tap_64.toig', 'r')
_background = ui.rgbcolor(255, 255, 255)
def func(foreground):
ui.display.text(68, 212, 'TAP TO CONFIRM', 2, foreground, _background)
f.seek(0)
ui.display.icon(3, 170, f.read(), _background, foreground)
yield from ui.animate_pulse(func) # , DELAY=10000)
@unimport_func
def zprava():
from _io import BytesIO
from trezor.messages.GetAddress import GetAddress
m = GetAddress()
m.address_n = [1, 2, 3]
m.show_display = True
print(m.__dict__)
f = BytesIO()
m.dump(f)
data = f.getvalue()
f.close()
print(data)
# m2 = GetAddress.load(BytesIO(data))
# print(m2.__dict__)
def dispatch():
# Callback for HID messages
print("Dispatch playground")
def boot():
# Initilize app on boot time.
# This should hookup HID message types dispatcher() wants to receive.
print("Boot playground")
zprava()

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

Binary file not shown.