1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +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 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() msg = msg_type()
try: try:
while True: while True:
field, fvalue = yield field, fvalue = yield
fname, ftype, fflags = field fname, ftype, fflags = field
if issubclass(ftype, MessageType): if issubclass(ftype, MessageType):
fvalue = yield from build_protobuf_message(ftype) fvalue = yield from build_message(ftype)
if fflags & FLAG_REPEATED: if fflags & FLAG_REPEATED:
prev_value = getattr(msg, fname, []) prev_value = getattr(msg, fname, [])
prev_value.append(fvalue) prev_value.append(fvalue)

View File

@ -26,12 +26,11 @@ msg.set_interfaces([0xFF00, 0xFF01, 0xF1D0])
for i, up in enumerate(msg.get_interfaces()): for i, up in enumerate(msg.get_interfaces()):
print("iface %d: usage_page 0x%04x" % (i + 1, up)) print("iface %d: usage_page 0x%04x" % (i + 1, up))
# Initialize the wire codec pipeline # Initialize the wire codec pipeline
wire.setup() wire.setup(0xFF00)
# Load default homescreen # 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) trezor.main.run(default_workflow=layout_homescreen)

View File

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

View File

@ -21,15 +21,15 @@ def close_default():
_default = None _default = None
def start_workflow(workflow): def start(workflow):
if _default is not None: if _default is not None:
close_default() close_default()
_started.append(workflow) _started.append(workflow)
log.info(__name__, 'start %s', 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: try:
return await workflow return await workflow
finally: finally: