1
0
Fork 0

WIP: Introduce the quick_ring

This commit is contained in:
Daniel Thompson 2020-04-12 08:59:37 +01:00
parent b649cd1b24
commit 64afea0d07
3 changed files with 36 additions and 13 deletions

View file

@ -7,4 +7,5 @@ from apps.flashlight import FlashlightApp
from apps.launcher import LauncherApp from apps.launcher import LauncherApp
from apps.pager import PagerApp, CrashApp from apps.pager import PagerApp, CrashApp
from apps.settings import SettingsApp from apps.settings import SettingsApp
from apps.stopwatch import StopwatchApp
from apps.testapp import TestApp from apps.testapp import TestApp

19
wasp/apps/stopwatch.py Normal file
View file

@ -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)

View file

@ -82,26 +82,29 @@ class Manager():
def __init__(self): def __init__(self):
self.app = None self.app = None
self.applications = [] self.quick_ring = []
self.blank_after = 15
self.charging = True
self.launcher = LauncherApp() self.launcher = LauncherApp()
self.launcher_ring = []
self.blank_after = 15
self._brightness = 2 self._brightness = 2
self._button = PinHandler(watch.button) self._button = PinHandler(watch.button)
self._charging = True
# TODO: Eventually these should move to main.py # TODO: Eventually these should move to main.py
self.register(ClockApp(), True) self.register(ClockApp(), True)
self.register(FlashlightApp(), True) self.register(StopwatchApp(), True)
self.register(SettingsApp(), True) self.register(FlashlightApp(), False)
self.register(TestApp(), True) self.register(SettingsApp(), False)
self.register(TestApp(), False)
def register(self, app, quick_ring=True): def register(self, app, quick_ring=True):
"""Register an application with the system. """Register an application with the system.
:param object app: The application to regsister :param object app: The application to regsister
""" """
self.applications.append(app) self.quick_ring.append(app)
@property @property
def brightness(self): def brightness(self):
@ -151,7 +154,7 @@ class Manager():
:param int direction: The direction of the navigation :param int direction: The direction of the navigation
""" """
app_list = self.applications app_list = self.quick_ring
if direction == EventType.LEFT: if direction == EventType.LEFT:
if self.app in app_list: if self.app in app_list:
@ -207,10 +210,10 @@ class Manager():
""" """
watch.backlight.set(0) watch.backlight.set(0)
if 'sleep' not in dir(self.app) or not self.app.sleep(): 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() self.app.sleep()
watch.display.poweroff() watch.display.poweroff()
self.charging = watch.battery.charging() self._charging = watch.battery.charging()
self.sleep_at = None self.sleep_at = None
def wake(self): def wake(self):
@ -291,8 +294,8 @@ class Manager():
else: else:
watch.rtc.update() watch.rtc.update()
charging = watch.battery.charging() if 1 == self._button.get_event() or \
if 1 == self._button.get_event() or self.charging != charging: self._charging != watch.battery.changing():
self.wake() self.wake()
def run(self, no_except=True): def run(self, no_except=True):
@ -303,7 +306,7 @@ class Manager():
can be observed interactively via the console. can be observed interactively via the console.
""" """
if not self.app: 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 # Reminder: wasptool uses this string to confirm the device has
# been set running again. # been set running again.