summaryrefslogtreecommitdiff
path: root/wasp/apps/alarm.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-29 12:33:05 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-29 12:33:05 (GMT)
commitb47298d4463dec0dbe071caa99b3517ba5115c84 (patch)
tree151e77bd97d2a416243de9d932c85c8154b14d15 /wasp/apps/alarm.py
parent632ec713a40f204aabf4779a6eda83974878e66c (diff)
apps: alarm: Adopt the checkbox widget
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/apps/alarm.py')
-rw-r--r--wasp/apps/alarm.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/wasp/apps/alarm.py b/wasp/apps/alarm.py
index 9b666ff..dfeea6a 100644
--- a/wasp/apps/alarm.py
+++ b/wasp/apps/alarm.py
@@ -15,6 +15,7 @@ An application to set a vibration alarm. All settings can be accessed from the W
import wasp
import time
+import widgets
# 2-bit RLE, generated from res/alarm_icon.png, 285 bytes
icon = (
@@ -49,7 +50,7 @@ class AlarmApp():
def __init__(self):
"""Initialize the application."""
- self.active = False
+ self.active = widgets.Checkbox(104, 194)
self.ringing = False
self.hours = 0
self.minutes = 0
@@ -65,7 +66,7 @@ class AlarmApp():
def background(self):
"""De-activate the application."""
- if self.active:
+ if self.active.state:
self._set_current_alarm()
wasp.system.set_alarm(self.current_alarm, self._alert)
if self.ringing:
@@ -87,8 +88,8 @@ class AlarmApp():
self._draw()
mute(False)
- elif event[1] in range(90, 150) and event[2] in range(180,240):
- self.active = not self.active
+ elif self.active.touch(event):
+ pass
elif event[1] in range(30,90):
if event[2] in range(40,100):
@@ -128,7 +129,7 @@ class AlarmApp():
draw.string("+", posx, 60, width=40)
draw.string("-", posx, 140, width=40)
- draw.fill(0xffff, 100, 190, 40, 40)
+ self.active.draw()
self._update()
else:
@@ -139,10 +140,6 @@ class AlarmApp():
def _update(self):
"""Update the dynamic parts of the application display."""
draw = wasp.watch.drawable
- if self.active:
- draw.fill(0x001f, 102, 192, 36, 36)
- else:
- draw.fill(0x0000, 102, 192, 36, 36)
if self.hours < 10:
draw.string("0"+str(self.hours), 10, 100, width=100)