apps: FacesApp: Add a watch face chooser
This app is enabled by default and allows users to select a watch face based on a fullscreen preview of how the app will draw the screen. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
parent
2a1ac32279
commit
1a4b678b2b
7 changed files with 78 additions and 6 deletions
|
@ -9,6 +9,8 @@ Application Library
|
|||
Watch faces
|
||||
-----------
|
||||
|
||||
.. automodule:: apps.faces
|
||||
|
||||
.. automodule:: apps.clock
|
||||
|
||||
.. automodule:: apps.chrono
|
||||
|
|
BIN
res/FacesApp.png
Normal file
BIN
res/FacesApp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
69
wasp/apps/faces.py
Normal file
69
wasp/apps/faces.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# Copyright (C) 2020 Daniel Thompson
|
||||
"""Watch Face Chooser
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A tool to select a suitable watch face.
|
||||
|
||||
.. figure:: res/FacesApp.png
|
||||
:width: 179
|
||||
|
||||
The app is intended to be enabled by default and has, therefore, been carefully
|
||||
structured to minimize memory usage when the app is not active.
|
||||
"""
|
||||
|
||||
import wasp
|
||||
import icons
|
||||
|
||||
class FacesApp():
|
||||
"""Choose a default watch face."""
|
||||
NAME = 'Faces'
|
||||
ICON = icons.clock
|
||||
|
||||
def foreground(self):
|
||||
"""Activate the application."""
|
||||
choices = []
|
||||
choices.append(('clock', 'Clock'))
|
||||
choices.append(('chrono', 'Chrono'))
|
||||
choices.append(('dual_clock', 'DualClock'))
|
||||
choices.append(('fibonacci_clock', 'FibonacciClock'))
|
||||
choices.append(('word_clock', 'WordClock'))
|
||||
|
||||
self.choices = choices
|
||||
self.choice = 0
|
||||
self.si = wasp.widgets.ScrollIndicator()
|
||||
|
||||
self._update()
|
||||
wasp.system.request_event(wasp.EventMask.SWIPE_UPDOWN)
|
||||
|
||||
def background(self):
|
||||
del self.choices
|
||||
del self.choice
|
||||
del self.si
|
||||
|
||||
# When the watch face redraws then the change to the scrolling indicator
|
||||
# is a little subtle. Let's provide some haptic feedback too so the user
|
||||
# knows something has happened.
|
||||
wasp.watch.vibrator.pulse()
|
||||
|
||||
def swipe(self, event):
|
||||
"""Notify the application of a touchscreen swipe event."""
|
||||
choice = self.choice
|
||||
if event[0] == wasp.EventType.DOWN:
|
||||
choice = choice - 1 if choice > 0 else len(self.choices)-1
|
||||
if event[0] == wasp.EventType.UP:
|
||||
choice = choice + 1 if choice < len(self.choices)-1 else 0
|
||||
self.choice = choice
|
||||
|
||||
mute = wasp.watch.display.mute
|
||||
mute(True)
|
||||
self._update()
|
||||
mute(False)
|
||||
|
||||
def _update(self):
|
||||
"""Draw the display from scratch."""
|
||||
wasp.watch.drawable.fill()
|
||||
(module, label) = self.choices[self.choice]
|
||||
wasp.system.register('apps.{}.{}App'.format(module, label), watch_face=True)
|
||||
wasp.system.quick_ring[0].preview()
|
||||
self.si.draw()
|
|
@ -39,9 +39,7 @@ class SoftwareApp():
|
|||
db = []
|
||||
db.append(('alarm', factory('Alarm')))
|
||||
db.append(('calc', factory('Calculator')))
|
||||
db.append(('chrono', factory('Chrono')))
|
||||
db.append(('dual_clock', factory('Dual Clock')))
|
||||
db.append(('fibonacci_clock', factory('Fibonacci Clock')))
|
||||
db.append(('faces', factory('Faces')))
|
||||
db.append(('gameoflife', factory('Game Of Life')))
|
||||
db.append(('musicplayer', factory('Music Player')))
|
||||
db.append(('play2048', factory('Play 2048')))
|
||||
|
@ -50,7 +48,6 @@ class SoftwareApp():
|
|||
db.append(('testapp', factory('Test')))
|
||||
db.append(('timer', factory('Timer')))
|
||||
db.append(('weather', factory('Weather')))
|
||||
db.append(('word_clock', factory('Word Clock')))
|
||||
|
||||
# Get the initial state for the checkboxes
|
||||
for _, checkbox in db:
|
||||
|
|
|
@ -8,6 +8,7 @@ manifest = (
|
|||
'apps/clock.py',
|
||||
'apps/chrono.py',
|
||||
'apps/dual_clock.py',
|
||||
'apps/faces.py',
|
||||
'apps/fibonacci_clock.py',
|
||||
'apps/flashlight.py',
|
||||
'apps/gameoflife.py',
|
||||
|
|
|
@ -3,7 +3,7 @@ import wasp
|
|||
import importlib
|
||||
import os
|
||||
|
||||
EXCLUDE = ('Notifications', 'Template', 'Demo')
|
||||
EXCLUDE = ('Notifications', 'Template', 'Demo', 'Faces')
|
||||
|
||||
def test_README(constructor):
|
||||
if constructor.NAME in EXCLUDE:
|
||||
|
|
|
@ -23,6 +23,7 @@ import watch
|
|||
import widgets
|
||||
|
||||
from apps.clock import ClockApp
|
||||
from apps.faces import FacesApp
|
||||
from apps.heart import HeartApp
|
||||
from apps.launcher import LauncherApp
|
||||
from apps.pager import PagerApp, CrashApp, NotificationApp
|
||||
|
@ -153,8 +154,10 @@ class Manager():
|
|||
(StepCounterApp, True),
|
||||
(StopwatchApp, True),
|
||||
(HeartApp, True),
|
||||
(FacesApp, False),
|
||||
(SettingsApp, False),
|
||||
(SoftwareApp, False),
|
||||
(SettingsApp, False) ):
|
||||
):
|
||||
try:
|
||||
a = app()
|
||||
|
||||
|
|
Loading…
Reference in a new issue