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 Binary files /dev/null and b/res/WeekClkApp.png 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',