1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 01:18:28 +00:00

minor api changes

This commit is contained in:
Jan Pochyla 2016-12-08 16:18:58 +01:00
parent e0dfc2ef03
commit a4f103755b
4 changed files with 13 additions and 14 deletions

View File

@ -20,14 +20,14 @@ from micropython import const
from streams import StreamReader, BufferWriter
def build_protobuf_message(msg_type, callback=None, *args):
def build_message(msg_type, callback=None, *args):
msg = msg_type()
try:
while True:
field, fvalue = yield
fname, ftype, fflags = field
if issubclass(ftype, MessageType):
fvalue = yield from build_protobuf_message(ftype)
fvalue = yield from build_message(ftype)
if fflags & FLAG_REPEATED:
prev_value = getattr(msg, fname, [])
prev_value.append(fvalue)

View File

@ -26,12 +26,11 @@ msg.set_interfaces([0xFF00, 0xFF01, 0xF1D0])
for i, up in enumerate(msg.get_interfaces()):
print("iface %d: usage_page 0x%04x" % (i + 1, up))
# Initialize the wire codec pipeline
wire.setup()
wire.setup(0xFF00)
# Load default homescreen
from apps.homescreen.layout_homescreen import layout_homescreen
from apps.homescreen.homescreen import layout_homescreen
# Run main even loop and specify, which screen is default
# Run main even loop and specify which screen is default
trezor.main.run(default_workflow=layout_homescreen)

View File

@ -72,10 +72,10 @@ def run_task(task, value):
ui.display.refresh()
def handle_message(message):
def handle_message(m):
if not paused_tasks:
return
iface, *value = message
iface, *value = m
tasks = paused_tasks.pop(iface, ())
for task in tasks:
run_task(task, value)
@ -101,9 +101,9 @@ def run_forever():
# add current delay to ring buffer for performance stats
log_delay_rb[log_delay_pos] = delay
log_delay_pos = (log_delay_pos + 1) % log_delay_rb_len
message = msg.select(delay)
if message:
handle_message(message)
m = msg.select(delay)
if m:
handle_message(m)
else:
handle_timeout()

View File

@ -21,15 +21,15 @@ def close_default():
_default = None
def start_workflow(workflow):
def start(workflow):
if _default is not None:
close_default()
_started.append(workflow)
log.info(__name__, 'start %s', workflow)
loop.schedule_task(_watch_workflow(workflow))
loop.schedule_task(_watch(workflow))
async def _watch_workflow(workflow):
async def _watch(workflow):
try:
return await workflow
finally: