From cd97893d2c400d7682fb763f6fd21224608b87ff Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sat, 15 Aug 2020 20:43:22 +0100 Subject: 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 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 -- cgit v0.10.2