wasp: manager: Wake up on a change of charging state
This commit is contained in:
parent
2d0df5aed5
commit
b48df32eb1
1 changed files with 4 additions and 1 deletions
|
@ -7,6 +7,7 @@ class Manager(object):
|
||||||
self.watch = watch
|
self.watch = watch
|
||||||
self.switch(clock.ClockApp())
|
self.switch(clock.ClockApp())
|
||||||
self.sleep_at = watch.rtc.uptime + 90
|
self.sleep_at = watch.rtc.uptime + 90
|
||||||
|
self.charging = True
|
||||||
|
|
||||||
def switch(self, app):
|
def switch(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
@ -23,13 +24,15 @@ class Manager(object):
|
||||||
if self.watch.rtc.uptime > self.sleep_at:
|
if self.watch.rtc.uptime > self.sleep_at:
|
||||||
self.watch.backlight.set(0)
|
self.watch.backlight.set(0)
|
||||||
self.watch.display.poweroff()
|
self.watch.display.poweroff()
|
||||||
|
self.charging = self.watch.battery.charging()
|
||||||
self.sleep_at = None
|
self.sleep_at = None
|
||||||
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
else:
|
else:
|
||||||
self.watch.rtc.update()
|
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.watch.display.poweron()
|
||||||
self.app.update(self.watch)
|
self.app.update(self.watch)
|
||||||
self.watch.backlight.set(2)
|
self.watch.backlight.set(2)
|
||||||
|
|
Loading…
Reference in a new issue