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>
This commit is contained in:
parent
1c3a835448
commit
4b7cf88576
7 changed files with 47 additions and 6 deletions
|
@ -246,6 +246,10 @@ application (and the "blank" white screen is a torch application):
|
||||||
:alt: Weather application running in the wasp-os simulator
|
:alt: Weather application running in the wasp-os simulator
|
||||||
:width: 179
|
:width: 179
|
||||||
|
|
||||||
|
.. image:: res/WeekClkApp.png
|
||||||
|
:alt: Digital clock application, including the week day
|
||||||
|
:width: 179
|
||||||
|
|
||||||
.. image:: res/WordClkApp.png
|
.. image:: res/WordClkApp.png
|
||||||
:alt: Shows a time as words in the wasp-os simulator
|
:alt: Shows a time as words in the wasp-os simulator
|
||||||
:width: 179
|
:width: 179
|
||||||
|
|
|
@ -19,6 +19,8 @@ Watch faces
|
||||||
|
|
||||||
.. automodule:: apps.fibonacci_clock
|
.. automodule:: apps.fibonacci_clock
|
||||||
|
|
||||||
|
.. automodule:: apps.week_clock
|
||||||
|
|
||||||
.. automodule:: apps.word_clock
|
.. automodule:: apps.word_clock
|
||||||
|
|
||||||
Built-in
|
Built-in
|
||||||
|
|
BIN
res/WeekClkApp.png
Normal file
BIN
res/WeekClkApp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
|
@ -62,6 +62,14 @@ class ClockApp():
|
||||||
wasp.system.bar.clock = False
|
wasp.system.bar.clock = False
|
||||||
self._draw(True)
|
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):
|
def _draw(self, redraw=False):
|
||||||
"""Draw or lazily update the display.
|
"""Draw or lazily update the display.
|
||||||
|
|
||||||
|
@ -93,18 +101,13 @@ class ClockApp():
|
||||||
# Skip the update
|
# Skip the update
|
||||||
return
|
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 the changeable parts of the watch face
|
||||||
draw.blit(DIGITS[now[4] % 10], 4*48, 80, fg=hi)
|
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[4] // 10], 3*48, 80, fg=lo)
|
||||||
draw.blit(DIGITS[now[3] % 10], 1*48, 80, fg=hi)
|
draw.blit(DIGITS[now[3] % 10], 1*48, 80, fg=hi)
|
||||||
draw.blit(DIGITS[now[3] // 10], 0*48, 80, fg=lo)
|
draw.blit(DIGITS[now[3] // 10], 0*48, 80, fg=lo)
|
||||||
draw.set_color(hi)
|
draw.set_color(hi)
|
||||||
draw.string('{} {} {}'.format(now[2], month, now[0]),
|
draw.string(self._day_string(now), 0, 180, width=240)
|
||||||
0, 180, width=240)
|
|
||||||
|
|
||||||
# Record the minute that is currently being displayed
|
# Record the minute that is currently being displayed
|
||||||
self._min = now[4]
|
self._min = now[4]
|
||||||
|
|
|
@ -24,6 +24,7 @@ class FacesApp():
|
||||||
"""Activate the application."""
|
"""Activate the application."""
|
||||||
choices = []
|
choices = []
|
||||||
choices.append(('clock', 'Clock'))
|
choices.append(('clock', 'Clock'))
|
||||||
|
choices.append(('week_clock', 'WeekClock'))
|
||||||
choices.append(('chrono', 'Chrono'))
|
choices.append(('chrono', 'Chrono'))
|
||||||
choices.append(('dual_clock', 'DualClock'))
|
choices.append(('dual_clock', 'DualClock'))
|
||||||
choices.append(('fibonacci_clock', 'FibonacciClock'))
|
choices.append(('fibonacci_clock', 'FibonacciClock'))
|
||||||
|
|
30
wasp/apps/week_clock.py
Normal file
30
wasp/apps/week_clock.py
Normal file
|
@ -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])
|
|
@ -28,6 +28,7 @@ manifest = (
|
||||||
'apps/testapp.py',
|
'apps/testapp.py',
|
||||||
'apps/timer.py',
|
'apps/timer.py',
|
||||||
'apps/weather.py',
|
'apps/weather.py',
|
||||||
|
'apps/week_clock.py',
|
||||||
'apps/word_clock.py',
|
'apps/word_clock.py',
|
||||||
'fonts/__init__.py',
|
'fonts/__init__.py',
|
||||||
'fonts/clock.py',
|
'fonts/clock.py',
|
||||||
|
|
Loading…
Reference in a new issue