1
0
Fork 0

wasp: manager: Wake up on a change of charging state

This commit is contained in:
Daniel Thompson 2020-02-04 08:49:10 +00:00
parent 2d0df5aed5
commit b48df32eb1

View file

@ -7,6 +7,7 @@ class Manager(object):
self.watch = watch
self.switch(clock.ClockApp())
self.sleep_at = watch.rtc.uptime + 90
self.charging = True
def switch(self, app):
self.app = app
@ -23,13 +24,15 @@ class Manager(object):
if self.watch.rtc.uptime > self.sleep_at:
self.watch.backlight.set(0)
self.watch.display.poweroff()
self.charging = self.watch.battery.charging()
self.sleep_at = None
gc.collect()
else:
self.watch.rtc.update()
if self.watch.button.value():
charging = self.watch.battery.charging()
if self.watch.button.value() or self.charging != charging:
self.watch.display.poweron()
self.app.update(self.watch)
self.watch.backlight.set(2)