summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-08-15 19:43:22 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-08-15 19:43:22 (GMT)
commitcd97893d2c400d7682fb763f6fd21224608b87ff (patch)
treed04fb248ca79a9e54b460d98850d3da0e1cba98d
parent44ba8ebd22d525e8a8e9fdfe1d6c99a6965e06e2 (diff)
apps: stopwatch: Add NEXT support
On a device with NEXT support we need to make sure we reset the stopwatch when switching away from it (if it is not running) since there may not be any other way to reset it. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
-rw-r--r--wasp/apps/stopwatch.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/wasp/apps/stopwatch.py b/wasp/apps/stopwatch.py
index ac29999..c2f756b 100644
--- a/wasp/apps/stopwatch.py
+++ b/wasp/apps/stopwatch.py
@@ -21,7 +21,8 @@ class StopwatchApp():
self._draw()
wasp.system.request_tick(97)
wasp.system.request_event(wasp.EventMask.TOUCH |
- wasp.EventMask.BUTTON)
+ wasp.EventMask.BUTTON |
+ wasp.EventMask.NEXT)
def sleep(self):
return True
@@ -29,6 +30,16 @@ class StopwatchApp():
def wake(self):
self._update()
+ def swipe(self, event):
+ """Handle NEXT events by augmenting the default processing by resetting
+ the count if we are not currently timing something.
+
+ No other swipe event is possible for this application.
+ """
+ if not self._started_at:
+ self._reset()
+ return True # Request system default handling
+
def press(self, button, state):
if not state:
return