mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 11:28:14 +00:00
First apps - homepage, playground
This commit is contained in:
parent
de83114dc7
commit
f22511f036
0
src/apps/__init__.py
Normal file
0
src/apps/__init__.py
Normal file
15
src/apps/homescreen/__init__.py
Normal file
15
src/apps/homescreen/__init__.py
Normal 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")
|
19
src/apps/homescreen/layout_homescreen.py
Normal file
19
src/apps/homescreen/layout_homescreen.py
Normal 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)
|
BIN
src/apps/homescreen/trezor.toig
Normal file
BIN
src/apps/homescreen/trezor.toig
Normal file
Binary file not shown.
59
src/apps/playground/__init__.py
Normal file
59
src/apps/playground/__init__.py
Normal 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()
|
BIN
src/apps/playground/tap_64.png
Normal file
BIN
src/apps/playground/tap_64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 887 B |
BIN
src/apps/playground/tap_64.toig
Normal file
BIN
src/apps/playground/tap_64.toig
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user