|
51 | 51 | if focusgroup: # on esp32 this may not be set |
52 | 52 | focusgroup.remove_all_objs() # might be better to save and restore the group for "back" actions |
53 | 53 |
|
54 | | -# Can be passed to TaskHandler, currently unused: |
| 54 | +# Custom exception handler that does not deinit() the TaskHandler because then the UI hangs: |
55 | 55 | def custom_exception_handler(e): |
56 | | - print(f"custom_exception_handler called: {e}") |
57 | | - mpos.ui.task_handler.deinit() |
| 56 | + print(f"TaskHandler's custom_exception_handler called: {e}") |
| 57 | + import sys |
| 58 | + sys.print_exception(e) # NOQA |
| 59 | + # No need to deinit() and re-init LVGL: |
| 60 | + #mpos.ui.task_handler.deinit() # default task handler does this, but then things hang |
58 | 61 | # otherwise it does focus_next and then crashes while doing lv.deinit() |
59 | | - focusgroup.remove_all_objs() |
60 | | - focusgroup.delete() |
61 | | - lv.deinit() |
| 62 | + #focusgroup.remove_all_objs() |
| 63 | + #focusgroup.delete() |
| 64 | + #lv.deinit() |
62 | 65 |
|
63 | 66 | import sys |
64 | 67 | if sys.platform == "esp32": |
65 | | - mpos.ui.task_handler = task_handler.TaskHandler(duration=5) # 1ms gives highest framerate on esp32-s3's but might have side effects? |
| 68 | + mpos.ui.task_handler = task_handler.TaskHandler(duration=5, exception_hook=custom_exception_handler) # 1ms gives highest framerate on esp32-s3's but might have side effects? |
66 | 69 | else: |
67 | | - mpos.ui.task_handler = task_handler.TaskHandler(duration=5) # 5ms is recommended for MicroPython+LVGL on desktop (less results in lower framerate) |
| 70 | + mpos.ui.task_handler = task_handler.TaskHandler(duration=5, exception_hook=custom_exception_handler) # 5ms is recommended for MicroPython+LVGL on desktop (less results in lower framerate) |
| 71 | + |
| 72 | +# Convenient for apps to be able to access these: |
| 73 | +mpos.ui.task_handler.TASK_HANDLER_STARTED = task_handler.TASK_HANDLER_STARTED |
| 74 | +mpos.ui.task_handler.TASK_HANDLER_FINISHED = task_handler.TASK_HANDLER_FINISHED |
68 | 75 |
|
69 | 76 | try: |
70 | 77 | import freezefs_mount_builtin |
|
0 commit comments