summaryrefslogtreecommitdiff
path: root/wasp/apps/clock.py
diff options
context:
space:
mode:
authorkozova1 <mug66kk@gmail.com>2020-12-05 18:27:55 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-13 16:51:07 (GMT)
commit2624a6e998f7b5a78a38fa98be15bf3d25ed81a9 (patch)
tree932437f9d64c3ca21745deacce570224c240a8de /wasp/apps/clock.py
parent784c9bb36d29457ddb3a5ef5af55918e1f4cd93c (diff)
Added basic theming engine.
This theming engine uses a bytestring (but supports anything indexable, as long as the index results are a byte long), stored as `wasp.system._theme`. It has a default value, which should not change anything about the way this looks currently. The theme can be set via `wasp.system.set_theme`, but this should *ONLY* be used in `main.py`. `wasp.system.set_theme` will return True if it was successful, or False if the theme is of an old format. Using an old format theme will *not* crash the watch, but will use the default theme instead. To theme this, one has to use tools/themer.py (use flag -h for complete explanation) to generate a bytestring that's added in main.py (see diff). The bytestring is then loaded into 'wasp.system._theme'. Theme values can be looked up by apps by using `wasp.system.theme("theme-key")`. Theme keys appear in the function body of `wasp.system.theme()`. I've took the liberty of converting existing apps to use this method, and it seems to work well. A test theme is provided in `tools/test_theme.py` Signed-off-by: kozova1 <mug66kk@gmail.com>
Diffstat (limited to 'wasp/apps/clock.py')
-rw-r--r--wasp/apps/clock.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py
index 106e712..c062d3e 100644
--- a/wasp/apps/clock.py
+++ b/wasp/apps/clock.py
@@ -76,7 +76,8 @@ class ClockApp():
# Clear the display and draw that static parts of the watch face
draw.fill()
- draw.rleblit(digits.clock_colon, pos=(2*48, 80), fg=0xb5b6)
+ draw.rleblit(digits.clock_colon, pos=(2*48, 80),
+ fg=wasp.system.theme('accent-mid'))
# Redraw the status bar
wasp.system.bar.draw()
@@ -95,10 +96,14 @@ class ClockApp():
month = MONTH[month*3:(month+1)*3]
# Draw the changeable parts of the watch face
- draw.rleblit(DIGITS[now[4] % 10], pos=(4*48, 80))
- draw.rleblit(DIGITS[now[4] // 10], pos=(3*48, 80), fg=0xbdb6)
- draw.rleblit(DIGITS[now[3] % 10], pos=(1*48, 80))
- draw.rleblit(DIGITS[now[3] // 10], pos=(0*48, 80), fg=0xbdb6)
+ draw.rleblit(DIGITS[now[4] % 10], pos=(4*48, 80),
+ fg=wasp.system.theme('accent-hi'))
+ draw.rleblit(DIGITS[now[4] // 10], pos=(3*48, 80),
+ fg=wasp.system.theme('accent-lo'))
+ draw.rleblit(DIGITS[now[3] % 10], pos=(1*48, 80),
+ fg=wasp.system.theme('accent-hi'))
+ draw.rleblit(DIGITS[now[3] // 10], pos=(0*48, 80),
+ fg=wasp.system.theme('accent-lo'))
draw.string('{} {} {}'.format(now[2], month, now[0]),
0, 180, width=240)