all clocks: Add a preview() method ready for a watch face chooser

One benefit from wasp-os' dirt simple drawing model is that it is very
easy for apps to provide full screen previews of themselves. Add this
for all clocks ready for us to add a watch face chooser application.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2021-06-20 10:21:25 +01:00
parent 3ea061508f
commit 2a1ac32279
6 changed files with 37 additions and 0 deletions

View file

@ -50,6 +50,11 @@ class ChronoApp():
"""Periodic callback to update the display."""
self._draw()
def preview(self):
"""Provide a preview for the watch face selection."""
wasp.system.bar.clock = False
self._draw(True)
def _draw(self, redraw=False):
"""Draw or lazily update the display.

View file

@ -59,6 +59,11 @@ class ClockApp():
"""Periodic callback to update the display."""
self._draw()
def preview(self):
"""Provide a preview for the watch face selection."""
wasp.system.bar.clock = False
self._draw(True)
def _draw(self, redraw=False):
"""Draw or lazily update the display.

View file

@ -82,6 +82,11 @@ class DualClockApp():
"""Periodic callback to update the display."""
self._draw()
def preview(self):
"""Provide a preview for the watch face selection."""
wasp.system.bar.clock = False
self._draw(True)
def _draw(self, redraw=False):
"""Draw or lazily update the display.

View file

@ -76,6 +76,11 @@ class FibonacciClockApp():
def tick(self, ticks):
self._draw()
def preview(self):
"""Provide a preview for the watch face selection."""
wasp.system.bar.clock = False
self._draw(True)
def _draw(self, redraw=False):
"""Draw or lazily update the display."""
draw = wasp.watch.drawable

View file

@ -63,6 +63,18 @@ class TemplateApp():
"""Notify the application the device is waking up."""
pass
def preview(self):
"""Provide a preview for the watch face selection.
preview() must be implemented by watch face applications because it
is called by the watch face selector. When called the application should
redraw the screen as through it was the foreground() application. The
application will not be active after the preview.
Other applications should not implement this entry point.
"""
pass
def press(self, button, state):
"""Notify the application of a button-press event."""
draw = wasp.watch.drawable

View file

@ -55,6 +55,11 @@ class WordClockApp():
"""Periodic callback to update the display."""
self._draw()
def preview(self):
"""Provide a preview for the watch face selection."""
wasp.system.bar.clock = False
self._draw(True)
def _draw(self, redraw=False):
"""Draw or lazily update the display.