summaryrefslogtreecommitdiff
path: root/wasp/wasp.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-11 19:14:30 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-11 19:15:02 (GMT)
commitf68eb610c5d77bb71d3952e0dc9ca70a472ebfae (patch)
treeca0b7a1174dc7e7013ce5e67fc18231d1d6ea0c3 /wasp/wasp.py
parent8cf9369efa9083cccee36e7596d52e12ace362d3 (diff)
wasp: On-device crash reporting
If an application crashes let's report it on the device so it can be distinguished from a hang (if nothing else it should mean we get better bug reports).
Diffstat (limited to 'wasp/wasp.py')
-rw-r--r--wasp/wasp.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/wasp/wasp.py b/wasp/wasp.py
index d336729..e5315a1 100644
--- a/wasp/wasp.py
+++ b/wasp/wasp.py
@@ -16,6 +16,7 @@ import widgets
from apps.clock import ClockApp
from apps.flashlight import FlashlightApp
from apps.launcher import LauncherApp
+from apps.pager import CrashApp
from apps.settings import SettingsApp
from apps.testapp import TestApp
@@ -32,6 +33,7 @@ class EventType():
TOUCH = 5
HOME = 256
+ BACK = 257
class EventMask():
"""Enumerated event masks.
@@ -179,7 +181,7 @@ class Manager():
self.switch(app_list[0])
else:
watch.vibrator.pulse()
- elif direction == EventType.HOME:
+ elif direction == EventType.HOME or direction == EventType.BACK:
if self.app != app_list[0]:
self.switch(app_list[0])
else:
@@ -298,7 +300,7 @@ class Manager():
if 1 == self._button.get_event() or self.charging != charging:
self.wake()
- def run(self):
+ def run(self, no_except=True):
"""Run the system manager synchronously.
This allows all watch management activities to handle in the
@@ -312,8 +314,21 @@ class Manager():
# been set running again.
print('Watch is running, use Ctrl-C to stop')
+ if not no_except:
+ # This is a simplified (uncommented) version of the loop
+ # below
+ while True:
+ self._tick()
+ machine.deepsleep()
+
while True:
- self._tick()
+ try:
+ self._tick()
+ except KeyboardInterrupt:
+ raise
+ except Exception as e:
+ self.switch(CrashApp(e))
+
# Currently there is no code to control how fast the system
# ticks. In other words this code will break if we improve the
# power management... we are currently relying on no being able