summaryrefslogtreecommitdiff
path: root/wasp/apps/testapp.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-03-08 20:48:48 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-03-08 20:48:48 (GMT)
commitcfffeddd774774a14cbb77ad899d047a259f16f3 (patch)
tree075b213655e1b7c82ec03408811ae9c6d52162ee /wasp/apps/testapp.py
parenta864a93706aa45e1f104b9710bc47f3b26bc4781 (diff)
wasp: testapp: Extend with a string render test
Diffstat (limited to 'wasp/apps/testapp.py')
-rw-r--r--wasp/apps/testapp.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py
index 2cf3431..f5d4de5 100644
--- a/wasp/apps/testapp.py
+++ b/wasp/apps/testapp.py
@@ -4,18 +4,20 @@ import manager
from draw565 import Draw565
-class TouchTestApp(object):
- """Simple application to visualize touch events.
+class TestApp():
+ """Simple test application.
"""
def __init__(self):
- pass
+ self.tests = ('Touch', 'String')
+ self.test = self.tests[0]
+ self.drawable = Draw565(watch.display)
def foreground(self, system, effect=None):
"""Activate the application."""
self.on_screen = ( -1, -1, -1, -1, -1, -1 )
self.draw(effect)
- system.request_event(manager.EVENT_TOUCH)
+ system.request_event(manager.EVENT_TOUCH | manager.EVENT_SWIPE_LEFTRIGHT)
def background(self):
"""De-activate the application (without losing state)."""
@@ -24,12 +26,31 @@ class TouchTestApp(object):
def sleep(self):
return False
+ def swipe(self, event):
+ tests = self.tests
+ i = tests.index(self.test) + 1
+ if i >= len(tests):
+ i = 0
+ self.test = tests[i]
+ self.draw()
+
def touch(self, event):
- draw = Draw565(watch.display)
- draw.string('({}, {})'.format(event[1], event[2]),
- 0, 180, width=240)
+ draw = self.drawable
+ if self.test == 'Touch':
+ draw.string('({}, {})'.format(event[1], event[2]),
+ 0, 180, width=240)
+ elif self.test == 'String':
+ watch.display.fill(0, 0, 30, 240, 240-30)
+ draw.string("The quick brown", 12, 24+24)
+ draw.string("fox jumped over", 12, 24+48)
+ draw.string("the lazy dog.", 12, 24+72)
+ draw.string("0123456789", 12, 24+120)
+ draw.string('!"£$%^&*()', 12, 24+144)
+
return True
def draw(self, effect=None):
"""Redraw the display from scratch."""
watch.display.fill(0)
+ self.drawable.string('{} test'.format(self.test),
+ 0, 6, width=240)