mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-19 04:48:12 +00:00
Handle exceptions in better way, enable to return to main screen many times.
This commit is contained in:
parent
ab9141dd95
commit
92eeac3612
@ -1,4 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
import utime
|
||||||
|
|
||||||
_new_layout = None
|
_new_layout = None
|
||||||
_current_layout = None
|
_current_layout = None
|
||||||
@ -15,17 +16,18 @@ def set_main(main_layout):
|
|||||||
global _new_layout
|
global _new_layout
|
||||||
global _current_layout
|
global _current_layout
|
||||||
|
|
||||||
_current_layout = main_layout
|
_current_layout = main_layout()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
_current_layout = yield from _current_layout
|
_current_layout = yield from _current_layout
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.print_exception(e)
|
sys.print_exception(e)
|
||||||
sys.exit()
|
utime.sleep(1) # Don't produce wall of exceptions
|
||||||
# if _current_layout == main_layout:
|
# if _current_layout == main_layout:
|
||||||
# # Main layout thrown exception, what to do?
|
# # Main layout thrown exception, what to do?
|
||||||
# _current_layout = main_layout
|
# sys.exit()
|
||||||
# continue
|
_current_layout = main_layout()
|
||||||
|
continue
|
||||||
|
|
||||||
if _new_layout != None:
|
if _new_layout != None:
|
||||||
print("Switching to new layout %s" % _new_layout)
|
print("Switching to new layout %s" % _new_layout)
|
||||||
|
Loading…
Reference in New Issue
Block a user