Update fonts to PCF, minor buglet fixes

Convert fonts to PCF, add font licenses, fix '...' on last-update time, remove non-working battery status from NextBus
This commit is contained in:
Phillip Burgess 2020-12-23 14:13:45 -08:00
parent 82c1d65a8e
commit 0d9d4fc9f8
15 changed files with 37 additions and 9808 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -60,9 +60,6 @@ try:
except:
TIME_ZONE = None # Use IP geolocation
# Battery level to indicate near-empty, time to recharge.
LOW_BATT_VOLTAGE = 2.45
# SOME UTILITY FUNCTIONS ---------------------------------------------------
@ -150,12 +147,11 @@ NETWORK = Network(status_neopixel=None)
GRAPHICS = Graphics(auto_refresh=False)
DISPLAY = GRAPHICS.display
FONT_SMALL = bitmap_font.load_font('/fonts/Impact-16.bdf')
FONT_MEDIUM = bitmap_font.load_font('/fonts/Impact-24.bdf')
FONT_LARGE = bitmap_font.load_font('/fonts/Impact-30.bdf')
FONT_SMALL = bitmap_font.load_font('/fonts/Impact-16.pcf')
FONT_MEDIUM = bitmap_font.load_font('/fonts/Impact-24.pcf')
FONT_LARGE = bitmap_font.load_font('/fonts/Impact-30.pcf')
# Two displayio groups are created. First is the "main" group which holds
# all the labels for the stops and predictions...
# displayio group holds all the labels for the stops and predictions...
GROUP = displayio.Group(max_size=14)
GROUP.append(fillrect(0, 0, DISPLAY.width, DISPLAY.height, 0xFFFFFF))
# Clear the screen ASAP before populating rest of group (erase any old
@ -164,32 +160,6 @@ DISPLAY.show(GROUP)
DISPLAY.refresh()
time.sleep(5) # Don't allow another refresh() too soon
# Second group is the low battery display. Populate this one now,
# then we'll get back to the main group with the stop data in a moment...
BATT_GROUP = displayio.Group(max_size=3)
BATT_GROUP.append(fillrect(0, 0, DISPLAY.width, DISPLAY.height, 0xFFFFFF))
try:
# Attempt loading low-battery icon, centered on screen
# pylint: disable=no-member
FILE = open('bitmaps/lowbatt.bmp', 'rb')
BATT_BITMAP = displayio.OnDiskBitmap(FILE)
BATT_ICON_TILEGRID = displayio.TileGrid(
BATT_BITMAP, pixel_shader=displayio.ColorConverter())
BATT_ICON_TILEGRID.x = (DISPLAY.width - BATT_BITMAP.width + 1) // 2
BATT_ICON_TILEGRID.y = (DISPLAY.height - BATT_BITMAP.height + 1) // 2
# onDiskBitmap seems to treat black as transparent...image won't
# show correctly on white background, so make an in-between rect
# to fill the area behind the battery icon with black.
BATT_GROUP.append(fillrect(BATT_ICON_TILEGRID.x, BATT_ICON_TILEGRID.y,
BATT_BITMAP.width, BATT_BITMAP.height, 0))
BATT_GROUP.append(BATT_ICON_TILEGRID)
except:
# If load fails, fall back on text low-batt message
TEXT = Label(FONT_MEDIUM, text='LOW BATTERY', color=0)
TEXT.anchor_point = (0.5, 0.5)
TEXT.anchored_position = (DISPLAY.width // 2, DISPLAY.height // 2)
BATT_GROUP.append(TEXT)
# Populate list of NextBus objects from STOPS[] and generate initial text
# labels (these get positioned in a second pass later)...
STOP_LIST = []
@ -247,17 +217,6 @@ LAST_QUERY_TIME = -QUERY_INTERVAL
while True:
# If battery is low, DO NOT SHOW PREDICTIONS. Because the display
# persists without power, information shown could "look right" but
# actually be WAY out of date. Instead, display low-battery indicator
# once and then wait for battery recharge or USB power.
if PERIPHERALS.battery < LOW_BATT_VOLTAGE:
DISPLAY.show(BATT_GROUP)
DISPLAY.refresh()
while PERIPHERALS.battery < LOW_BATT_VOLTAGE:
time.sleep(60)
DISPLAY.show(GROUP)
# Periodically sync clock with time server
if time.monotonic() - LAST_SYNC_TIME >= CLOCK_SYNC_INTERVAL:
try:

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,7 +1,7 @@
"""
Seasonal produce finder for Adafruit MagTag w/CircuitPython 6.1 or later.
Lists in-season fruits and vegetables for a user's location and season.
"Smart cursive" BDF font by Thomas A. Fine, helvB12.bdf from Xorg fonts.
"Smart cursive" BDF font by Thomas A. Fine, helvB12 from Xorg fonts.
"""
# pylint: disable=import-error, line-too-long
@ -52,7 +52,7 @@ MAGTAG.graphics.set_background('bitmaps/produce.bmp')
# Produce list is inserted at this position
MAGTAG.add_text(
text_font='/fonts/cursive-smart.bdf',
text_font='/fonts/cursive-smart.pcf',
text_position=(3, 2),
line_spacing=1.0,
text_anchor_point=(0, 0), # top left
@ -68,10 +68,9 @@ MAGTAG.graphics.splash.append(Rect(0, MAGTAG.graphics.display.height - 14,
# Center white text label over black bar to show last update time
# (Initially a placeholder, string is not assigned to label until later)
MAGTAG.add_text(
text_font='/fonts/helvB12.bdf',
text_font='/fonts/helvB12.pcf',
text_position=(MAGTAG.graphics.display.width // 2,
MAGTAG.graphics.display.height - 1),
text_maxlen=19,
text_color=0xFFFFFF,
text_anchor_point=(0.5, 1),
is_data=False, # we'll set this text manually later

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
Copyright (c) 1999, Thomas A. Fine
License to copy and distribute for both commercial and
non-commercial use is herby granted, provided this notice
is preserved.
fine@head-cfa.harvard.edu
http://hea-www.harvard.edu/~fine/
Produced with bdfedit, a tcl/tk font editing program
written by Thomas A. Fine

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
Copyright 1984-1989, 1994 Adobe Systems Incorporated.
Copyright 1988, 1994 Digital Equipment Corporation.
Adobe is a trademark of Adobe Systems Incorporated which may be
registered in certain jurisdictions.
Permission to use these trademarks is hereby granted only in
association with the images described in this file.
Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notices appear in all
copies and that both those copyright notices and this permission
notice appear in supporting documentation, and that the names of
Adobe Systems and Digital Equipment Corporation not be used in
advertising or publicity pertaining to distribution of the software
without specific, written prior permission. Adobe Systems and
Digital Equipment Corporation make no representations about the
suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.

Binary file not shown.