mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 14:58:09 +00:00
adapt rest of code to touch changes, example works
This commit is contained in:
parent
b6caad6b9b
commit
71b89c748a
@ -4,7 +4,7 @@ from trezor.utils import unimport_gen
|
|||||||
from trezor.res import loadres
|
from trezor.res import loadres
|
||||||
from trezor import dispatcher
|
from trezor import dispatcher
|
||||||
from trezor import loop
|
from trezor import loop
|
||||||
from trezor import msg
|
from trezor import wire
|
||||||
|
|
||||||
|
|
||||||
def swipe_to_rotate():
|
def swipe_to_rotate():
|
||||||
@ -39,7 +39,7 @@ def layout_homescreen(initialize_msg=None):
|
|||||||
features.passphrase_cached = False
|
features.passphrase_cached = False
|
||||||
features.passphrase_protection = False
|
features.passphrase_protection = False
|
||||||
features.vendor = 'bitcointrezor.com'
|
features.vendor = 'bitcointrezor.com'
|
||||||
msg.write_msg(features)
|
wire.write_msg(features)
|
||||||
yield loop.Wait([dispatcher.dispatch(),
|
yield loop.Wait([dispatcher.dispatch(),
|
||||||
swipe_to_rotate(),
|
swipe_to_rotate(),
|
||||||
animate_logo()])
|
animate_logo()])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from trezor import msg
|
from trezor import wire
|
||||||
from trezor import ui
|
from trezor import ui
|
||||||
from trezor.ui.button import Button, CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
|
from trezor.ui.button import Button, CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
|
||||||
from trezor.ui.pin import PinDialog
|
from trezor.ui.pin import PinDialog
|
||||||
@ -23,4 +23,4 @@ def layout_get_public_key(message):
|
|||||||
pubkey.node.fingerprint = 0
|
pubkey.node.fingerprint = 0
|
||||||
pubkey.node.chain_code = 'deadbeef'
|
pubkey.node.chain_code = 'deadbeef'
|
||||||
pubkey.node.public_key = 'deadbeef'
|
pubkey.node.public_key = 'deadbeef'
|
||||||
msg.write_msg(pubkey)
|
wire.write_msg(pubkey)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from . import msg
|
from . import wire
|
||||||
from . import layout
|
from . import layout
|
||||||
|
|
||||||
|
|
||||||
@ -15,6 +15,6 @@ def unregister(message_type):
|
|||||||
|
|
||||||
def dispatch():
|
def dispatch():
|
||||||
mtypes = message_handlers.keys()
|
mtypes = message_handlers.keys()
|
||||||
message = yield from msg.read_msg(*mtypes)
|
message = yield from wire.read_msg(*mtypes)
|
||||||
handler = message_handlers[message.message_type]
|
handler = message_handlers[message.message_type]
|
||||||
layout.change(handler(message))
|
layout.change(handler(message))
|
||||||
|
@ -16,7 +16,7 @@ if __debug__:
|
|||||||
TOUCH = const(256) # 0-255 is reserved for USB interfaces
|
TOUCH = const(256) # 0-255 is reserved for USB interfaces
|
||||||
TOUCH_START = const(1)
|
TOUCH_START = const(1)
|
||||||
TOUCH_MOVE = const(2)
|
TOUCH_MOVE = const(2)
|
||||||
TOUCH_END = const(3)
|
TOUCH_END = const(4)
|
||||||
|
|
||||||
msg_handlers = {} # Interface -> generator
|
msg_handlers = {} # Interface -> generator
|
||||||
time_queue = []
|
time_queue = []
|
||||||
@ -138,8 +138,7 @@ def run_forever():
|
|||||||
message = msg.select(delay)
|
message = msg.select(delay)
|
||||||
if message:
|
if message:
|
||||||
# Run interrupt handler right away, they have priority
|
# Run interrupt handler right away, they have priority
|
||||||
iface = message[0]
|
iface, *data = message
|
||||||
data = message
|
|
||||||
gen = msg_handlers.pop(iface, None)
|
gen = msg_handlers.pop(iface, None)
|
||||||
if not gen:
|
if not gen:
|
||||||
log.info(__name__, 'No handler for message: %s', iface)
|
log.info(__name__, 'No handler for message: %s', iface)
|
||||||
|
@ -96,9 +96,7 @@ class Button():
|
|||||||
def wait(self):
|
def wait(self):
|
||||||
while True:
|
while True:
|
||||||
self.render()
|
self.render()
|
||||||
event, *pos = yield loop.Select(loop.TOUCH_START,
|
event, *pos = yield loop.Select(loop.TOUCH)
|
||||||
loop.TOUCH_MOVE,
|
|
||||||
loop.TOUCH_END)
|
|
||||||
result = self.send(event, pos)
|
result = self.send(event, pos)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
return result
|
return result
|
||||||
|
@ -65,7 +65,7 @@ class Swipe():
|
|||||||
|
|
||||||
def wait(self):
|
def wait(self):
|
||||||
while True:
|
while True:
|
||||||
event, *pos = yield loop.Select(loop.TOUCH_START, loop.TOUCH_END)
|
event, *pos = yield loop.Select(loop.TOUCH)
|
||||||
result = self.send(event, pos)
|
result = self.send(event, pos)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
return result
|
return result
|
||||||
|
@ -10,7 +10,7 @@ HEADER_MAGIC = const(35) #
|
|||||||
|
|
||||||
|
|
||||||
def read_report():
|
def read_report():
|
||||||
_, rep = yield loop.Select(IFACE)
|
rep, = yield loop.Select(IFACE)
|
||||||
assert rep[0] == REPORT_NUM, 'Report number malformed'
|
assert rep[0] == REPORT_NUM, 'Report number malformed'
|
||||||
return rep
|
return rep
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user