summaryrefslogtreecommitdiff
path: root/wasp/apps/testapp.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-11-14 20:36:41 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-11-14 20:36:41 (GMT)
commite105c8bb68fa630159363e3c206ffe5535ea8f92 (patch)
tree92bb9ab878b22ca2fa44cddffdb90d766f233bcd /wasp/apps/testapp.py
parentaeda73ad90df3688d364a646bd75873a3355f5e2 (diff)
apps: testapp: Add an alarm test
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/apps/testapp.py')
-rw-r--r--wasp/apps/testapp.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py
index 4c90109..69cb1a3 100644
--- a/wasp/apps/testapp.py
+++ b/wasp/apps/testapp.py
@@ -9,6 +9,8 @@ import machine
import wasp
import icons
+from apps.pager import PagerApp
+
class TestApp():
"""Simple test application.
@@ -21,7 +23,7 @@ class TestApp():
ICON = icons.app
def __init__(self):
- self.tests = ('Button', 'Crash', 'Colours', 'Fill', 'Fill-H', 'Fill-V', 'Notifications', 'RLE', 'String', 'Touch', 'Wrap')
+ self.tests = ('Alarm', 'Button', 'Crash', 'Colours', 'Fill', 'Fill-H', 'Fill-V', 'Notifications', 'RLE', 'String', 'Touch', 'Wrap')
self.test = self.tests[0]
self.scroll = wasp.widgets.ScrollIndicator()
@@ -41,7 +43,9 @@ class TestApp():
def press(self, button, state):
draw = wasp.watch.drawable
- if self.test == 'Button':
+ if self.test == 'Alarm':
+ self._test_alarm()
+ elif self.test == 'Button':
draw.string('{}: {}'.format(button, state), 0, 108, width=240)
elif self.test == 'Crash':
self.crash()
@@ -98,6 +102,20 @@ class TestApp():
elif self.test == 'Wrap':
self._benchmark_wrap()
+ def _alarm(self):
+ wasp.system.wake()
+ wasp.system.switch(PagerApp('Alarm triggered'))
+
+ def _test_alarm(self):
+ def nop():
+ pass
+ now = wasp.watch.rtc.time()
+ wasp.system.set_alarm(now + 30, self._alarm)
+ wasp.system.set_alarm(now + 30, nop)
+ if not wasp.system.cancel_alarm(now + 30, nop):
+ bug()
+ wasp.watch.drawable.string("Done.", 12, 24+80)
+
def _benchmark_rle(self):
draw = wasp.watch.drawable
draw.fill(0, 0, 30, 240, 240-30)
@@ -177,6 +195,9 @@ class TestApp():
draw.string('{} test'.format(self.test),
0, 6, width=240)
+ if self.test == 'Alarm':
+ draw.string("Press button to", 12, 24+24)
+ draw.string("set alarm.", 12, 24+48)
if self.test == 'Crash':
draw.string("Press button to", 12, 24+24)
draw.string("throw exception.", 12, 24+48)