From 2a1ac322799ce0ae549110ec96dbb2caa28cf6d0 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 20 Jun 2021 10:21:25 +0100 Subject: 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 diff --git a/wasp/apps/chrono.py b/wasp/apps/chrono.py index 3eae3a1..4496a83 100644 --- a/wasp/apps/chrono.py +++ b/wasp/apps/chrono.py @@ -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. diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py index 5c7854d..cdf465e 100644 --- a/wasp/apps/clock.py +++ b/wasp/apps/clock.py @@ -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. diff --git a/wasp/apps/dual_clock.py b/wasp/apps/dual_clock.py index 39bb8e0..76fea2c 100644 --- a/wasp/apps/dual_clock.py +++ b/wasp/apps/dual_clock.py @@ -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. diff --git a/wasp/apps/fibonacci_clock.py b/wasp/apps/fibonacci_clock.py index 0f9ebfd..7124ebe 100644 --- a/wasp/apps/fibonacci_clock.py +++ b/wasp/apps/fibonacci_clock.py @@ -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 diff --git a/wasp/apps/template.py b/wasp/apps/template.py index e611545..3027599 100644 --- a/wasp/apps/template.py +++ b/wasp/apps/template.py @@ -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 diff --git a/wasp/apps/word_clock.py b/wasp/apps/word_clock.py index a7f2d63..6bc3d45 100644 --- a/wasp/apps/word_clock.py +++ b/wasp/apps/word_clock.py @@ -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. -- cgit v0.10.2