From ca991fdde630b4e44442c29156bcfc5c041bbefd Mon Sep 17 00:00:00 2001 From: slush0 Date: Thu, 28 Apr 2016 23:49:45 +0200 Subject: [PATCH] Main Trezor even loops starts here --- src/trezor/main.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/trezor/main.py diff --git a/src/trezor/main.py b/src/trezor/main.py new file mode 100644 index 00000000..29a8635e --- /dev/null +++ b/src/trezor/main.py @@ -0,0 +1,38 @@ +import sys +sys.path.append('lib') + +import gc + +from trezor import loop +from trezor import layout + +if __debug__: + import logging + logging.basicConfig(level=logging.INFO) + +def perf_info(): + while True: + queue = [str(x[2]).split("'")[1] for x in loop.q] + mem_alloc = gc.mem_alloc() + gc.collect() + print("mem_alloc: %s/%s, last_sleep: %d, queue: %s" % \ + (mem_alloc, gc.mem_alloc(), loop.last_sleep, ', '.join(queue))) + + yield loop.Sleep(1000000) + +_main_layout = None + +def run(main_layout): + # ui.touch.start(lambda x, y: print('touch start %d %d\n' % (x, y))) + # ui.touch.move(lambda x, y: print('touch move %d %d\n' % (x, y))) + # ui.touch.end(lambda x, y: print('touch end %d %d\n' % (x, y))) + + if __debug__: + loop.call_soon(perf_info()) + + global _main_layout + _main_layout = main_layout + loop.call_soon(layout.set_main(_main_layout)) + + loop.run_forever() + loop.close()