From 4b7cf885767e94b3a212d18bdcb4d76be519d547 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Fri, 31 Dec 2021 19:16:12 +0100 Subject: [PATCH] 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 --- README.rst | 4 ++++ docs/apps.rst | 2 ++ res/WeekClkApp.png | Bin 0 -> 6225 bytes wasp/apps/clock.py | 15 +++++++++------ wasp/apps/faces.py | 1 + wasp/apps/week_clock.py | 30 ++++++++++++++++++++++++++++++ wasp/boards/manifest_240x240.py | 1 + 7 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 res/WeekClkApp.png create mode 100644 wasp/apps/week_clock.py 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 0000000000000000000000000000000000000000..517ac09d5efcde06d38f286cb2b876e67ad652b2 GIT binary patch literal 6225 zcmc(khgTEPx9=0MAWcN+2nZOOBoHAYN|D|{q)7=agkGfgqJlsGMWlmBZ_=bgD1tN* zBM=C^2!ar*q1QLO_Yb^vfA_ANwX!mEX3dEtfk98@P#`)kIEaFd1#~Hr8bqdW1q9|M4+X`8WkY*GT(bXD zm$?|mK6Ll=z>ru8X=!OV{CB{7GSuu}i$=RL@GBW~RI}MtS67EXAnNMtA0QA%NZ;p2 zYipmIh64QkwK65Wj&@e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&}#47@2dfhG}-$RgchJ^ovi;V*Z;YdsT8q_2IVISlMA z1M_7j^=iai^+!}d3qRiD zXgyjbR@H2Fh1taT)uZTE0?_n_e8 zgM;%q?4Yle9I~d>=mDI}`P#-m{^UYF_r|Fz>z*HMPMEIWz)CgefQk?Ru3Az=q)U0P zr4aiCrn3eE=fbYivP)P5-@8SbcZE*w^z?L8h>iBPWDRz<+TM4eipTp?9soS^yVnV<|HqKC!_GI?&!6R#*VosRK3IIJ z1A+s9N4x33PTg|6(abU1^j91%rkS3Z8MHfMxW75;dOEc01p#5xJ!cct0{gUbA|O1pI1a$=%|OR7I5_w)wyC&yW#O$%@V`F3pw!o{ z@!9sq=H|0|>yx;QhtKvxVjZ7)nk`>3Xoq$4yo?pP(;rv)VxjxG^g%mLJqsPAFPIp| zA+@^w9SWM64%lol58MuKqY3o(9>pOeigow{0f?szAViNP4Uzh+{9$|26AoDl2FlB% z7XfN_>7#l$0@fOrKL!A^>x)qWNQ9M@_2>wAfqN`a literal 0 HcmV?d00001 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',