diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-06-20 09:28:27 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-06-20 09:28:27 (GMT) |
| commit | 1a4b678b2b815884cb712244d8a1b5e50a5cbd86 (patch) | |
| tree | 87391a65edd67a3d43478d3a448f734967ebd955 /wasp/apps/faces.py | |
| parent | 2a1ac322799ce0ae549110ec96dbb2caa28cf6d0 (diff) | |
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>
Diffstat (limited to 'wasp/apps/faces.py')
| -rw-r--r-- | wasp/apps/faces.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/wasp/apps/faces.py b/wasp/apps/faces.py new file mode 100644 index 0000000..7e3ed3e --- /dev/null +++ b/wasp/apps/faces.py @@ -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() |
