diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-12 07:59:37 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-12 07:59:37 (GMT) |
| commit | 64afea0d0700edde10723bd243c2a4193d41063d (patch) | |
| tree | 314e40f01af4b87c18f79085ce4a792135c02e26 | |
| parent | b649cd1b2424fd8492cfecbc6034649ad4c2f376 (diff) | |
WIP: Introduce the quick_ring
| -rw-r--r-- | wasp/apps/__init__.py | 1 | ||||
| -rw-r--r-- | wasp/apps/stopwatch.py | 19 | ||||
| -rw-r--r-- | wasp/wasp.py | 29 |
3 files changed, 36 insertions, 13 deletions
diff --git a/wasp/apps/__init__.py b/wasp/apps/__init__.py index 222ceb7..a5ab777 100644 --- a/wasp/apps/__init__.py +++ b/wasp/apps/__init__.py @@ -7,4 +7,5 @@ from apps.flashlight import FlashlightApp from apps.launcher import LauncherApp from apps.pager import PagerApp, CrashApp from apps.settings import SettingsApp +from apps.stopwatch import StopwatchApp from apps.testapp import TestApp diff --git a/wasp/apps/stopwatch.py b/wasp/apps/stopwatch.py new file mode 100644 index 0000000..60c0f9f --- /dev/null +++ b/wasp/apps/stopwatch.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# Copyright (C) 2020 Daniel Thompson + +import wasp +import icons + +class StopwatchApp(): + NAME = 'Stopwatch' + ICON = icons.app + + def foreground(self): + """Activate the application.""" + self._draw() + + def _draw(self): + """Draw the display from scratch.""" + draw = wasp.watch.drawable + draw.fill() + draw.string(self.NAME, 0, 6, width=240) diff --git a/wasp/wasp.py b/wasp/wasp.py index e32e914..7f88cdf 100644 --- a/wasp/wasp.py +++ b/wasp/wasp.py @@ -82,26 +82,29 @@ class Manager(): def __init__(self): self.app = None - self.applications = [] - self.blank_after = 15 - self.charging = True + self.quick_ring = [] self.launcher = LauncherApp() + self.launcher_ring = [] + + self.blank_after = 15 self._brightness = 2 self._button = PinHandler(watch.button) + self._charging = True # TODO: Eventually these should move to main.py self.register(ClockApp(), True) - self.register(FlashlightApp(), True) - self.register(SettingsApp(), True) - self.register(TestApp(), True) + self.register(StopwatchApp(), True) + self.register(FlashlightApp(), False) + self.register(SettingsApp(), False) + self.register(TestApp(), False) def register(self, app, quick_ring=True): """Register an application with the system. :param object app: The application to regsister """ - self.applications.append(app) + self.quick_ring.append(app) @property def brightness(self): @@ -151,7 +154,7 @@ class Manager(): :param int direction: The direction of the navigation """ - app_list = self.applications + app_list = self.quick_ring if direction == EventType.LEFT: if self.app in app_list: @@ -207,10 +210,10 @@ class Manager(): """ watch.backlight.set(0) if 'sleep' not in dir(self.app) or not self.app.sleep(): - self.switch(self.applications[0]) + self.switch(self.quick_ring[0]) self.app.sleep() watch.display.poweroff() - self.charging = watch.battery.charging() + self._charging = watch.battery.charging() self.sleep_at = None def wake(self): @@ -291,8 +294,8 @@ class Manager(): else: watch.rtc.update() - charging = watch.battery.charging() - if 1 == self._button.get_event() or self.charging != charging: + if 1 == self._button.get_event() or \ + self._charging != watch.battery.changing(): self.wake() def run(self, no_except=True): @@ -303,7 +306,7 @@ class Manager(): can be observed interactively via the console. """ if not self.app: - self.switch(self.applications[0]) + self.switch(self.quick_ring[0]) # Reminder: wasptool uses this string to confirm the device has # been set running again. |
