summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2021-12-31 18:16:12 (GMT)
committerDaniel Thompson <daniel.thompson@linaro.org>2022-02-02 12:18:27 (GMT)
commit4b7cf885767e94b3a212d18bdcb4d76be519d547 (patch)
treea6a6abeb8c84bd7208ca201731080c9c0e50b8e5
parent1c3a835448dcff6b182e120a1e135185943c21ff (diff)
Add watchface with weekday
* Allow overriding of date string in clock.py * Override it to display the weekday in week_clock.py Signed-off-by: Francesco Gazzetta <fgaz@fgaz.me>
-rw-r--r--README.rst4
-rw-r--r--docs/apps.rst2
-rw-r--r--res/WeekClkApp.pngbin0 -> 6225 bytes
-rw-r--r--wasp/apps/clock.py15
-rw-r--r--wasp/apps/faces.py1
-rw-r--r--wasp/apps/week_clock.py30
-rw-r--r--wasp/boards/manifest_240x240.py1
7 files changed, 47 insertions, 6 deletions
diff --git a/README.rst b/README.rst
index 1051621..a64baa8 100644
--- a/README.rst
+++ b/README.rst
@@ -246,6 +246,10 @@ application (and the "blank" white screen is a torch application):
:alt: Weather application running in the wasp-os simulator
:width: 179
+.. image:: res/WeekClkApp.png
+ :alt: Digital clock application, including the week day
+ :width: 179
+
.. image:: res/WordClkApp.png
:alt: Shows a time as words in the wasp-os simulator
:width: 179
diff --git a/docs/apps.rst b/docs/apps.rst
index 74dca13..9ea6f6f 100644
--- a/docs/apps.rst
+++ b/docs/apps.rst
@@ -19,6 +19,8 @@ Watch faces
.. automodule:: apps.fibonacci_clock
+.. automodule:: apps.week_clock
+
.. automodule:: apps.word_clock
Built-in
diff --git a/res/WeekClkApp.png b/res/WeekClkApp.png
new file mode 100644
index 0000000..517ac09
--- /dev/null
+++ b/res/WeekClkApp.png
Binary files differ
diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py
index d9e489f..6270999 100644
--- a/wasp/apps/clock.py
+++ b/wasp/apps/clock.py
@@ -62,6 +62,14 @@ class ClockApp():
wasp.system.bar.clock = False
self._draw(True)
+ def _day_string(self, now):
+ """Produce a string representing the current day"""
+ # Format the month as text
+ month = now[1] - 1
+ month = MONTH[month*3:(month+1)*3]
+
+ return '{} {} {}'.format(now[2], month, now[0])
+
def _draw(self, redraw=False):
"""Draw or lazily update the display.
@@ -93,18 +101,13 @@ class ClockApp():
# Skip the update
return
- # Format the month as text
- month = now[1] - 1
- month = MONTH[month*3:(month+1)*3]
-
# Draw the changeable parts of the watch face
draw.blit(DIGITS[now[4] % 10], 4*48, 80, fg=hi)
draw.blit(DIGITS[now[4] // 10], 3*48, 80, fg=lo)
draw.blit(DIGITS[now[3] % 10], 1*48, 80, fg=hi)
draw.blit(DIGITS[now[3] // 10], 0*48, 80, fg=lo)
draw.set_color(hi)
- draw.string('{} {} {}'.format(now[2], month, now[0]),
- 0, 180, width=240)
+ draw.string(self._day_string(now), 0, 180, width=240)
# Record the minute that is currently being displayed
self._min = now[4]
diff --git a/wasp/apps/faces.py b/wasp/apps/faces.py
index 9ce8083..1079417 100644
--- a/wasp/apps/faces.py
+++ b/wasp/apps/faces.py
@@ -24,6 +24,7 @@ class FacesApp():
"""Activate the application."""
choices = []
choices.append(('clock', 'Clock'))
+ choices.append(('week_clock', 'WeekClock'))
choices.append(('chrono', 'Chrono'))
choices.append(('dual_clock', 'DualClock'))
choices.append(('fibonacci_clock', 'FibonacciClock'))
diff --git a/wasp/apps/week_clock.py b/wasp/apps/week_clock.py
new file mode 100644
index 0000000..99d3c41
--- /dev/null
+++ b/wasp/apps/week_clock.py
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2022 Francesco Gazzetta
+
+"""Digital clock with weekday
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Shows a time (as HH:MM) together with a battery meter, the date, and the weekday.
+
+.. figure:: res/WeekClkApp.png
+ :width: 179
+"""
+
+from apps.clock import ClockApp, MONTH
+
+WDAY = 'MonTueWedThuFriSatSun'
+
+class WeekClockApp(ClockApp):
+ NAME = 'WeekClk'
+
+ def _day_string(self, now):
+ """Produce a string representing the current day"""
+ # Format the month as text
+ month = now[1] - 1
+ month = MONTH[month*3:(month+1)*3]
+
+ # Format the weekday as text
+ wday = now[6]
+ wday = WDAY[wday*3:(wday+1)*3]
+
+ return '{} {} {} {}'.format(wday, now[2], month, now[0])
diff --git a/wasp/boards/manifest_240x240.py b/wasp/boards/manifest_240x240.py
index 48fe577..8dd9110 100644
--- a/wasp/boards/manifest_240x240.py
+++ b/wasp/boards/manifest_240x240.py
@@ -28,6 +28,7 @@ manifest = (
'apps/testapp.py',
'apps/timer.py',
'apps/weather.py',
+ 'apps/week_clock.py',
'apps/word_clock.py',
'fonts/__init__.py',
'fonts/clock.py',