diff --git a/src/apps/playground/tap_64.png b/assets/tap_64.png similarity index 100% rename from src/apps/playground/tap_64.png rename to assets/tap_64.png diff --git a/src/apps/playground/tap_64.toig b/assets/tap_64.toig similarity index 100% rename from src/apps/playground/tap_64.toig rename to assets/tap_64.toig diff --git a/src/apps/homescreen/layout_homescreen.py b/src/apps/homescreen/layout_homescreen.py index 6359b5a01e..f2add3cf1c 100644 --- a/src/apps/homescreen/layout_homescreen.py +++ b/src/apps/homescreen/layout_homescreen.py @@ -1,6 +1,7 @@ from trezor import ui from trezor.ui.swipe import Swipe from trezor import loop +from trezor.res import loadres def swipe_to_change_orientation(): @@ -12,11 +13,8 @@ def swipe_to_change_orientation(): def layout_homescreen(): print("Homescreen layout!") - f = open('apps/homescreen/trezor.toig', 'rb') - def func(foreground): - f.seek(0) - ui.display.icon(0, 0, f.read(), foreground, ui.BLACK) + ui.display.icon(0, 0, loadres('apps/homescreen/res/trezor.toig'), foreground, ui.BLACK) orientation = swipe_to_change_orientation() animation = ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000) diff --git a/src/apps/homescreen/trezor.toig b/src/apps/homescreen/res/trezor.toig similarity index 100% rename from src/apps/homescreen/trezor.toig rename to src/apps/homescreen/res/trezor.toig diff --git a/src/apps/playground/__init__.py b/src/apps/playground/__init__.py index 9a82855e9b..12ac00c896 100644 --- a/src/apps/playground/__init__.py +++ b/src/apps/playground/__init__.py @@ -3,6 +3,7 @@ from trezor import ui from trezor import msg from trezor.ui.pin import PinDialog, PIN_CONFIRMED, PIN_CANCELLED from trezor.utils import unimport_func +from trezor.res import loadres @unimport_func @@ -17,14 +18,12 @@ def layout_tap_to_confirm(address, amount, currency): # 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', 'rb') # bg = ui.WHITE # style = ui.NORMAL # def func(fg): # ui.display.text(68, 212, 'TAP TO CONFIRM', style, fg, bg) - # f.seek(0) - # ui.display.icon(3, 170, f.read(), bg, fg) + # ui.display.icon(3, 170, loadres('apps/playground/res/tap_64.toig'), bg, fg) # animation = ui.animate_pulse(func, ui.BLACK, ui.GREY, speed=200000) diff --git a/src/apps/playground/res/tap_64.toig b/src/apps/playground/res/tap_64.toig new file mode 100644 index 0000000000..1bd987bd00 Binary files /dev/null and b/src/apps/playground/res/tap_64.toig differ diff --git a/src/apps/playground_stick/layout_homescreen.py b/src/apps/playground_stick/layout_homescreen.py index 6a325af4f6..bb5da342aa 100644 --- a/src/apps/playground_stick/layout_homescreen.py +++ b/src/apps/playground_stick/layout_homescreen.py @@ -1,7 +1,7 @@ from trezor import ui from trezor import loop +from trezor.res import loadres -f = open('apps/playground_stick/fingerprint.toig', 'rb') c = ui.rgbcolor(0x20, 0x98, 0xD1) def layout_homescreen(): @@ -12,8 +12,7 @@ def layout_homescreen(): p = 0 def func(foreground): - f.seek(0) - ui.display.loader(p, c, 0, f.read(), foreground) + ui.display.loader(p, c, 0, loadres('apps/playground_stick/res/fingerprint.toig'), foreground) p = (p + 10) % 1000 animation = ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000) diff --git a/src/apps/playground_stick/fingerprint.toig b/src/apps/playground_stick/res/fingerprint.toig similarity index 100% rename from src/apps/playground_stick/fingerprint.toig rename to src/apps/playground_stick/res/fingerprint.toig diff --git a/src/trezor/res/__init__.py b/src/trezor/res/__init__.py new file mode 100644 index 0000000000..f05651be90 --- /dev/null +++ b/src/trezor/res/__init__.py @@ -0,0 +1,3 @@ +def loadres(name): + with open(name, 'rb') as f: + return f.read()