summaryrefslogtreecommitdiff
path: root/wasp/wasp.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-05 08:43:26 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-06 21:04:20 (GMT)
commit83cc56969e13d1e0e3ea4b2a6b8c9c6875110688 (patch)
treec2b6558cc7f55368d2d4e57efd2357937c3b6c4c /wasp/wasp.py
parent6a6e393d1fc389102733fe182ea41b803bd05755 (diff)
wasp: manager: make sleep() and background() callbacks optional
Making callbacks optional reduces pointless boilerplate in applications.
Diffstat (limited to 'wasp/wasp.py')
-rw-r--r--wasp/wasp.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/wasp/wasp.py b/wasp/wasp.py
index a49948b..a18c466 100644
--- a/wasp/wasp.py
+++ b/wasp/wasp.py
@@ -115,7 +115,8 @@ class Manager():
"""Switch to the requested application.
"""
if self.app:
- self.app.background()
+ if 'background' in dir(self.app):
+ self.app.background()
else:
# System start up...
watch.display.poweron()
@@ -186,7 +187,7 @@ class Manager():
"""Enter the deepest sleep state possible.
"""
watch.backlight.set(0)
- if not self.app.sleep():
+ if 'sleep' not in dir(self.app) or not self.app.sleep():
self.switch(self.applications[0])
self.app.sleep()
watch.display.poweroff()