From d759522b0881237ea5ed17407bfcc40610888d5e Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Wed, 21 Jun 2023 16:49:13 +0100 Subject: [PATCH] Adjust clock.py Clock now uses smaller font so it fits on the screen --- micropython/examples/stellar_unicorn/README.md | 2 ++ micropython/examples/stellar_unicorn/clock.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/micropython/examples/stellar_unicorn/README.md b/micropython/examples/stellar_unicorn/README.md index 33900798..ec977769 100644 --- a/micropython/examples/stellar_unicorn/README.md +++ b/micropython/examples/stellar_unicorn/README.md @@ -50,6 +50,8 @@ The easiest way to start displaying cool stuff on Stellar Unicorn is using our S Clock example with (optional) NTP synchronization. You can adjust the brightness with LUX + and -, and resync the time by pressing A. +This examples uses a custom tiny bitmap font, find 3x5.bitmapfont in [fonts](../../fonts) and copy it to your Pico W. + ### Eighties Super Computer [eighties_super_computer.py](eighties_super_computer.py) diff --git a/micropython/examples/stellar_unicorn/clock.py b/micropython/examples/stellar_unicorn/clock.py index 20339f1d..63fa9dd4 100644 --- a/micropython/examples/stellar_unicorn/clock.py +++ b/micropython/examples/stellar_unicorn/clock.py @@ -8,6 +8,8 @@ # WIFI_PASSWORD = "Your WiFi password" # # Clock synchronizes time on start, and resynchronizes if you press the A button +# +# This example uses a custom tiny font - find 3x5.bitmapfont in pimoroni-pico/fonts import time import math @@ -193,7 +195,7 @@ def redraw_display_if_reqd(): gradient_background(hue, sat, val, hue + HUE_OFFSET, sat, val) - clock = "{:02}:{:02}:{:02}".format(hour, minute, second) + clock = "{:02} {:02}".format(hour, minute) # calculate text position so that it is centred w = graphics.measure_text(clock, 1) @@ -206,7 +208,7 @@ def redraw_display_if_reqd(): # set the font -graphics.set_font("bitmap6") +graphics.set_font(open("3x5.bitmapfont", "rb").read()) su.set_brightness(0.5) sync_time()