apps: alarm: Adopt the checkbox widget
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
parent
632ec713a4
commit
b47298d446
|
@ -15,6 +15,7 @@ An application to set a vibration alarm. All settings can be accessed from the W
|
||||||
|
|
||||||
import wasp
|
import wasp
|
||||||
import time
|
import time
|
||||||
|
import widgets
|
||||||
|
|
||||||
# 2-bit RLE, generated from res/alarm_icon.png, 285 bytes
|
# 2-bit RLE, generated from res/alarm_icon.png, 285 bytes
|
||||||
icon = (
|
icon = (
|
||||||
|
@ -49,7 +50,7 @@ class AlarmApp():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the application."""
|
"""Initialize the application."""
|
||||||
|
|
||||||
self.active = False
|
self.active = widgets.Checkbox(104, 194)
|
||||||
self.ringing = False
|
self.ringing = False
|
||||||
self.hours = 0
|
self.hours = 0
|
||||||
self.minutes = 0
|
self.minutes = 0
|
||||||
|
@ -65,7 +66,7 @@ class AlarmApp():
|
||||||
|
|
||||||
def background(self):
|
def background(self):
|
||||||
"""De-activate the application."""
|
"""De-activate the application."""
|
||||||
if self.active:
|
if self.active.state:
|
||||||
self._set_current_alarm()
|
self._set_current_alarm()
|
||||||
wasp.system.set_alarm(self.current_alarm, self._alert)
|
wasp.system.set_alarm(self.current_alarm, self._alert)
|
||||||
if self.ringing:
|
if self.ringing:
|
||||||
|
@ -87,8 +88,8 @@ class AlarmApp():
|
||||||
self._draw()
|
self._draw()
|
||||||
mute(False)
|
mute(False)
|
||||||
|
|
||||||
elif event[1] in range(90, 150) and event[2] in range(180,240):
|
elif self.active.touch(event):
|
||||||
self.active = not self.active
|
pass
|
||||||
|
|
||||||
elif event[1] in range(30,90):
|
elif event[1] in range(30,90):
|
||||||
if event[2] in range(40,100):
|
if event[2] in range(40,100):
|
||||||
|
@ -128,7 +129,7 @@ class AlarmApp():
|
||||||
draw.string("+", posx, 60, width=40)
|
draw.string("+", posx, 60, width=40)
|
||||||
draw.string("-", posx, 140, width=40)
|
draw.string("-", posx, 140, width=40)
|
||||||
|
|
||||||
draw.fill(0xffff, 100, 190, 40, 40)
|
self.active.draw()
|
||||||
|
|
||||||
self._update()
|
self._update()
|
||||||
else:
|
else:
|
||||||
|
@ -139,10 +140,6 @@ class AlarmApp():
|
||||||
def _update(self):
|
def _update(self):
|
||||||
"""Update the dynamic parts of the application display."""
|
"""Update the dynamic parts of the application display."""
|
||||||
draw = wasp.watch.drawable
|
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:
|
if self.hours < 10:
|
||||||
draw.string("0"+str(self.hours), 10, 100, width=100)
|
draw.string("0"+str(self.hours), 10, 100, width=100)
|
||||||
|
|
Loading…
Reference in a new issue