1
0
Fork 0

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>
pull/63/head
Daniel Thompson 2020-08-15 20:43:22 +01:00
parent 44ba8ebd22
commit cd97893d2c
1 changed files with 12 additions and 1 deletions

View File

@ -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