summaryrefslogtreecommitdiff
path: root/wasp/clock.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-02-03 19:24:09 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-02-03 19:26:08 (GMT)
commit3892f07e62fcbbac128401f183bec66361f08db1 (patch)
tree877ebbb5d856c8a3539417872f148932fedae75d /wasp/clock.py
parentfc74f7e37b3db9024d6cecf9fabdddf602b88b3c (diff)
wasp: Add simple clock app
At this point both the simulator and a PineTime will come up and show a clock (although in the case of the PineTime the clock will just come up at 12:00).
Diffstat (limited to 'wasp/clock.py')
-rw-r--r--wasp/clock.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/wasp/clock.py b/wasp/clock.py
new file mode 100644
index 0000000..95ea7da
--- /dev/null
+++ b/wasp/clock.py
@@ -0,0 +1,43 @@
+import fonts
+
+DIGITS = (
+ fonts.clock_0,
+ fonts.clock_1,
+ fonts.clock_2,
+ fonts.clock_3,
+ fonts.clock_4,
+ fonts.clock_5,
+ fonts.clock_6,
+ fonts.clock_7,
+ fonts.clock_8,
+ fonts.clock_9
+)
+
+class ClockApp(object):
+
+ def __init__(self):
+ self.on_screen = ( -1, -1 )
+
+ def draw(self, watch):
+ display = watch.display
+
+ display.fill(0)
+ display.rleblit(fonts.clock_colon, pos=(2*48, 80), fg=0xb5b6)
+ self.update(watch)
+
+ def update(self, watch):
+ now = watch.rtc.get_time()
+ if now[0] == self.on_screen[0] and now[1] == self.on_screen[1]:
+ # Avoid the redraw
+ return False
+
+ display = watch.display
+ display.rleblit(DIGITS[now[1] % 10], pos=(4*48, 80))
+ display.rleblit(DIGITS[now[1] // 10], pos=(3*48, 80), fg=0xc638)
+ display.rleblit(DIGITS[now[0] % 10], pos=(1*48, 80))
+ display.rleblit(DIGITS[now[0] // 10], pos=(0*48, 80), fg=0xc638)
+ self.on_screen = now
+
+ return True
+
+