summaryrefslogtreecommitdiff
path: root/wasp/manager.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/manager.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/manager.py')
-rw-r--r--wasp/manager.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/wasp/manager.py b/wasp/manager.py
new file mode 100644
index 0000000..ae6c60d
--- /dev/null
+++ b/wasp/manager.py
@@ -0,0 +1,42 @@
+import clock
+import gc
+import machine
+
+class Manager(object):
+ def __init__(self, watch):
+ self.watch = watch
+ self.switch(clock.ClockApp())
+ self.sleep_at = watch.rtc.uptime + 90
+
+ def switch(self, app):
+ self.app = app
+ app.draw(self.watch)
+
+ def tick(self):
+ if self.sleep_at:
+ if self.watch.rtc.update():
+ self.app.update(self.watch)
+
+ if self.watch.button.value():
+ self.sleep_at = self.watch.rtc.uptime + 15
+
+ if self.watch.rtc.uptime > self.sleep_at:
+ self.watch.backlight.set(0)
+ self.watch.display.poweroff()
+ self.sleep_at = None
+ else:
+ self.watch.rtc.update()
+
+ if self.watch.button.value():
+ self.watch.display.poweron()
+ self.app.update(self.watch)
+ self.watch.backlight.set(2)
+
+ self.sleep_at = self.watch.rtc.uptime + 15
+
+ gc.collect()
+
+ def run(self):
+ while True:
+ self.tick()
+ machine.deepsleep()