summaryrefslogtreecommitdiff
path: root/wasp/apps/template.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-12 07:41:31 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-12 07:41:31 (GMT)
commitb649cd1b2424fd8492cfecbc6034649ad4c2f376 (patch)
tree7bdadf0298bafe7cfbdc7678b7603298e4f49245 /wasp/apps/template.py
parent80d518b75b46dc2e1780f59c19d3c03a5410542a (diff)
wasp: template: Implement optional application methods
Diffstat (limited to 'wasp/apps/template.py')
-rw-r--r--wasp/apps/template.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/wasp/apps/template.py b/wasp/apps/template.py
index 9e9ea1c..515b055 100644
--- a/wasp/apps/template.py
+++ b/wasp/apps/template.py
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
+"""Template application implementing all application method calls.
+"""
import wasp
import icons
@@ -11,6 +13,7 @@ class TemplateApp():
ICON = icons.app
def __init__(self):
+ """Initialize the application."""
pass
def foreground(self):
@@ -19,19 +22,39 @@ class TemplateApp():
wasp.system.request_event(wasp.EventMask.TOUCH |
wasp.EventMask.SWIPE_UPDOWN |
wasp.EventMask.BUTTON)
+ wasp.system.request_tick(1000)
+
+ def background(self):
+ """De-activate the application."""
+ pass
+
+ def sleep(self):
+ """Notify the application the device is about to sleep."""
+ return False
+
+ def wake(self):
+ """Notify the application the device is waking up."""
+ pass
def press(self, button, state):
+ """Notify the application of a button-press event."""
draw = wasp.watch.drawable
draw.string('Button', 0, 108, width=240)
def swipe(self, event):
+ """Notify the application of a touchscreen swipe event."""
draw = wasp.watch.drawable
if event[0] == wasp.EventType.UP:
draw.string('Swipe up', 0, 108, width=240)
else:
draw.string('Swipe down', 0, 108, width=240)
+ def tick(self, ticks):
+ """Notify the application that its periodic tick is due."""
+ pass
+
def touch(self, event):
+ """Notify the application of a touchscreen touch event."""
draw = wasp.watch.drawable
wasp.watch.drawable.string('({}, {})'.format(
event[1], event[2]), 0, 108, width=240)
@@ -40,4 +63,9 @@ class TemplateApp():
"""Draw the display from scratch."""
draw = wasp.watch.drawable
draw.fill()
- draw.string('Template', 0, 6, width=240)
+ draw.string(self.NAME, 0, 6, width=240)
+ self._update()
+
+ def _update(self):
+ """Update the dynamic parts of the application display
+ pass