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>
This commit is contained in:
parent
44ba8ebd22
commit
cd97893d2c
1 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue