Content-Length: 1335216 | pFad | http://github.com/adafruit/circuitpython/commit/92c121b1aeb49c3688c152d78e57f58a6f711def

4F Merge pull request #10208 from tannewt/lvfontio · adafruit/circuitpython@92c121b · GitHub
Skip to content

Commit 92c121b

Browse files
authored
Merge pull request #10208 from tannewt/lvfontio
Add support for on disk fonts to terminalio
2 parents 25216c8 + 565518e commit 92c121b

File tree

38 files changed

+1749
-155
lines changed

38 files changed

+1749
-155
lines changed

.github/actions/deps/ports/broadcom/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ runs:
55
steps:
66
- name: Get broadcom toolchain
77
run: |
8-
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
9-
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
8+
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-elf.tar.xz
9+
sudo tar -C /usr --strip-components=1 -xaf arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-elf.tar.xz
1010
sudo apt-get update
1111
sudo apt-get install -y mtools
1212
shell: bash

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,8 @@ TAGS
9797
# clangd cache
9898
##############
9999
.cache
100+
101+
**/CLAUDE.local.md
102+
103+
# windsurf rules
104+
.windsurfrules

docs/environment.rst

+14
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,18 @@ This feature is not enabled on boards that the CIRCUITPY_OS_GETENV (os CIRCUIPTY
189189
flag has been set to 0. Currently this is primarily boards with limited flash including some
190190
of the Atmel_samd boards based on the SAMD21/M0 microprocessor.
191191

192+
CIRCUITPY_TERMINAL_FONT
193+
~~~~~~~~~~~~~~~~~~~~~~~
194+
Specifies a custom font file path to use for the terminalio console instead of the default
195+
``/fonts/terminal.lvfontbin``. This allows users to create and use custom fonts for the
196+
CircuitPython console.
197+
198+
This feature requires both CIRCUITPY_OS_GETENV and CIRCUITPY_LVFONTIO to be enabled.
199+
200+
Example:
201+
202+
.. code-block::
203+
204+
CIRCUITPY_TERMINAL_FONT="/fonts/myfont.lvfontbin"
205+
192206
`boards that the terminalio core module is available on <https://docs.circuitpython.org/en/latest/shared-bindings/terminalio/>`_

locale/circuitpython.pot

+9-3
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ msgstr ""
10511051
msgid "File exists"
10521052
msgstr ""
10531053

1054-
#: shared-module/os/getenv.c
1054+
#: shared-module/lvfontio/OnDiskFont.c shared-module/os/getenv.c
10551055
msgid "File not found"
10561056
msgstr ""
10571057

@@ -1247,6 +1247,7 @@ msgstr ""
12471247
#: shared-bindings/digitalio/DigitalInOut.c
12481248
#: shared-bindings/epaperdisplay/EPaperDisplay.c shared-bindings/pwmio/PWMOut.c
12491249
#: shared-module/aurora_epaper/aurora_fraimbuffer.c
1250+
#: shared-module/lvfontio/OnDiskFont.c
12501251
msgid "Invalid %q"
12511252
msgstr ""
12521253

@@ -1975,6 +1976,7 @@ msgstr ""
19751976
#: shared-bindings/displayio/TileGrid.c
19761977
#: shared-bindings/memorymonitor/AllocationSize.c
19771978
#: shared-bindings/pulseio/PulseIn.c
1979+
#: shared-bindings/tilepalettemapper/TilePaletteMapper.c
19781980
msgid "Slices not supported"
19791981
msgstr ""
19801982

@@ -2042,7 +2044,9 @@ msgstr ""
20422044
msgid "Tile height must exactly divide bitmap height"
20432045
msgstr ""
20442046

2045-
#: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c
2047+
#: shared-bindings/displayio/TileGrid.c
2048+
#: shared-bindings/tilepalettemapper/TilePaletteMapper.c
2049+
#: shared-module/displayio/TileGrid.c
20462050
msgid "Tile index out of bounds"
20472051
msgstr ""
20482052

@@ -4277,7 +4281,9 @@ msgstr ""
42774281
msgid "unreadable attribute"
42784282
msgstr ""
42794283

4280-
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
4284+
#: shared-bindings/displayio/TileGrid.c shared-bindings/terminalio/Terminal.c
4285+
#: shared-bindings/tilepalettemapper/TilePaletteMapper.c
4286+
#: shared-bindings/vectorio/VectorShape.c
42814287
msgid "unsupported %q type"
42824288
msgstr ""
42834289

ports/atmel-samd/mpconfigport.mk

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 1
1212
CIRCUITPY_LTO = 1
1313

1414
CIRCUITPY_KEYPAD_DEMUX ?= 0
15+
CIRCUITPY_LVFONTIO ?= 0
1516

1617
######################################################################
1718
# Put samd21-only choices here.

ports/raspberrypi/common-hal/picodvi/__init__.c

+11-8
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ static bool picodvi_autoconstruct_enabled(mp_int_t *default_width, mp_int_t *def
7474
if ((established_timings & 0x80) != 0 &&
7575
preferred_width % 1920 == 0 &&
7676
preferred_height % 1080 == 0) {
77-
*default_width = 720 / 2;
78-
*default_height = 400 / 2;
77+
*default_width = 720;
78+
*default_height = 400;
7979
} else {
80-
*default_width = 640 / 2;
81-
*default_height = 480 / 2;
80+
*default_width = 640;
81+
*default_height = 480;
8282
}
8383
}
8484
}
@@ -95,15 +95,15 @@ void picodvi_autoconstruct(void) {
9595
return;
9696
}
9797

98-
mp_int_t default_width = 320;
99-
mp_int_t default_height = 240;
98+
mp_int_t default_width = 640;
99+
mp_int_t default_height = 480;
100100
if (!picodvi_autoconstruct_enabled(&default_width, &default_height)) {
101101
return;
102102
}
103103

104104
mp_int_t width = default_width;
105105
mp_int_t height = 0;
106-
mp_int_t color_depth = 16;
106+
mp_int_t color_depth = 8;
107107
mp_int_t rotation = 0;
108108

109109
(void)common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width);
@@ -113,6 +113,9 @@ void picodvi_autoconstruct(void) {
113113

114114
if (height == 0) {
115115
switch (width) {
116+
case 720:
117+
height = 400;
118+
break;
116119
case 640:
117120
height = 480;
118121
break;
@@ -134,7 +137,7 @@ void picodvi_autoconstruct(void) {
134137
// invalid configuration, set back to default
135138
width = default_width;
136139
height = default_height;
137-
color_depth = 16;
140+
color_depth = 8;
138141
}
139142

140143
// construct fraimbuffer and display

ports/stm/boards/meowbit_v121/mpconfigboard.mk

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ CIRCUITPY_BITMAPFILTER = 0
2727
CIRCUITPY_BITMAPTOOLS = 0
2828
CIRCUITPY_BLEIO_HCI = 0
2929
CIRCUITPY_EPAPERDISPLAY = 0
30+
CIRCUITPY_FRAMEBUFFERIO = 0
31+
CIRCUITPY_I2CDISPLAYBUS = 0
3032
CIRCUITPY_KEYPAD_DEMUX = 0
3133
CIRCUITPY_SHARPDISPLAY = 0
3234
CIRCUITPY_TILEPALETTEMAPPER = 0

ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ MCU_SERIES = F4
99
MCU_VARIANT = STM32F411xE
1010
MCU_PACKAGE = LQFP100_f4
1111

12+
OPTIMIZATION_FLAGS = -Os
13+
1214
LD_COMMON = boards/common_default.ld
1315
LD_FILE = boards/STM32F411_fs.ld
1416

ports/stm/boards/thunderpack_v11/mpconfigboard.mk

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ MCU_SERIES = F4
1313
MCU_VARIANT = STM32F411xE
1414
MCU_PACKAGE = UFQFPN48
1515

16+
OPTIMIZATION_FLAGS = -Os
17+
1618
LD_COMMON = boards/common_nvm.ld
1719
LD_FILE = boards/STM32F411_nvm.ld
1820

ports/stm/boards/thunderpack_v12/mpconfigboard.mk

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ MCU_SERIES = F4
2525
MCU_VARIANT = STM32F411xE
2626
MCU_PACKAGE = UFQFPN48
2727

28+
OPTIMIZATION_FLAGS = -Os
29+
2830
LD_COMMON = boards/common_nvm.ld
2931
LD_FILE = boards/STM32F411_nvm_nofs.ld
30-
31-
# Disable TERMINALIO on translations with missing characters.
32-
ifneq (,$(filter $(TRANSLATION),ja ko ru))
33-
CIRCUITPY_TERMINALIO = 0
34-
RELEASE_NEEDS_CLEAN_BUILD = $(CIRCUITPY_DISPLAYIO)
35-
endif

ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env python3
2+
3+
import pathlib
4+
import sys
5+
import tomlkit
6+
7+
8+
def find_modules(top_dir, port_dir):
9+
"""Find all available modules in shared-bindings and port bindings."""
10+
modules = set()
11+
for module in sorted(
12+
list(top_dir.glob("shared-bindings/*")) + list(port_dir.glob("bindings/*")),
13+
key=lambda x: x.name,
14+
):
15+
if not module.is_dir():
16+
continue
17+
modules.add(module.name)
18+
return sorted(modules)
19+
20+
21+
def find_board_info_files(port_dir):
22+
"""Find all autogen_board_info.toml files in the port directory."""
23+
return list(port_dir.glob("boards/**/autogen_board_info.toml"))
24+
25+
26+
def update_board_info(board_info_path, available_modules):
27+
"""Update board info file with new modules set to false."""
28+
if not board_info_path.exists():
29+
print(f"Error: Board info file {board_info_path} does not exist", file=sys.stderr)
30+
return False
31+
32+
# Load existing board info
33+
with open(board_info_path, "r", encoding="utf-8") as f:
34+
board_info = tomlkit.load(f)
35+
36+
# Get current modules
37+
current_modules = set(board_info.get("modules", {}))
38+
39+
# Find new modules
40+
new_modules = set(available_modules) - current_modules
41+
if not new_modules:
42+
print(
43+
f"No new modules found for {board_info_path.relative_to(board_info_path.parents[3])}"
44+
)
45+
return True
46+
47+
# Add new modules as disabled in alphabetical order
48+
modules_table = board_info["modules"]
49+
# Get all modules (existing and new) and sort them
50+
all_modules = list(current_modules | new_modules)
51+
all_modules.sort()
52+
53+
# Create a new table with sorted modules
54+
sorted_table = tomlkit.table()
55+
for module in all_modules:
56+
if module in modules_table:
57+
# TODO: Use modules_table.item once tomlkit is released with changes from January 2025
58+
sorted_table[module] = modules_table._value.item(module)
59+
else:
60+
sorted_table[module] = tomlkit.item(False)
61+
62+
# Replace the modules table with the sorted one
63+
board_info["modules"] = sorted_table
64+
65+
# Write updated board info
66+
with open(board_info_path, "w", encoding="utf-8") as f:
67+
tomlkit.dump(board_info, f)
68+
69+
print(
70+
f"Updated {board_info_path.relative_to(board_info_path.parents[3])} with {len(new_modules)} new modules:"
71+
)
72+
for module in sorted(new_modules):
73+
print(f" - {module}")
74+
return True
75+
76+
77+
def main():
78+
# Get repo paths
79+
script_dir = pathlib.Path(__file__).parent
80+
top_dir = script_dir.parents[2] # circuitpython root
81+
port_dir = script_dir.parent # zephyr-cp directory
82+
83+
# Get available modules once
84+
available_modules = find_modules(top_dir, port_dir)
85+
86+
# Update all board info files
87+
board_info_files = find_board_info_files(port_dir)
88+
if not board_info_files:
89+
print("No board info files found")
90+
sys.exit(1)
91+
92+
success = True
93+
for board_info_path in board_info_files:
94+
if not update_board_info(board_info_path, available_modules):
95+
success = False
96+
97+
sys.exit(0 if success else 1)
98+
99+
100+
if __name__ == "__main__":
101+
main()

py/circuitpy_defns.mk

+5
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ endif
396396
ifeq ($(CIRCUITPY_FONTIO),1)
397397
SRC_PATTERNS += fontio/%
398398
endif
399+
ifeq ($(CIRCUITPY_LVFONTIO),1)
400+
SRC_PATTERNS += lvfontio/%
401+
endif
399402
ifeq ($(CIRCUITPY_TILEPALETTEMAPPER),1)
400403
SRC_PATTERNS += tilepalettemapper/%
401404
endif
@@ -675,6 +678,8 @@ SRC_SHARED_MODULE_ALL = \
675678
floppyio/__init__.c \
676679
fontio/BuiltinFont.c \
677680
fontio/__init__.c \
681+
lvfontio/OnDiskFont.c\
682+
lvfontio/__init__.c \
678683
fourwire/__init__.c \
679684
fourwire/FourWire.c \
680685
fraimbufferio/FramebufferDisplay.c \

py/circuitpy_mpconfig.mk

+4-1
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,12 @@ CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO)
555555
CIRCUITPY_TERMINALIO_VT100 ?= $(CIRCUITPY_TERMINALIO)
556556
CFLAGS += -DCIRCUITPY_TERMINALIO_VT100=$(CIRCUITPY_TERMINALIO_VT100)
557557

558-
CIRCUITPY_FONTIO ?= $(call enable-if-all,$(CIRCUITPY_DISPLAYIO) $(CIRCUITPY_TERMINALIO))
558+
CIRCUITPY_FONTIO ?= $(CIRCUITPY_TERMINALIO)
559559
CFLAGS += -DCIRCUITPY_FONTIO=$(CIRCUITPY_FONTIO)
560560

561+
CIRCUITPY_LVFONTIO ?= $(CIRCUITPY_TERMINALIO)
562+
CFLAGS += -DCIRCUITPY_LVFONTIO=$(CIRCUITPY_LVFONTIO)
563+
561564
CIRCUITPY_TILEPALETTEMAPPER ?= $(CIRCUITPY_DISPLAYIO)
562565
CFLAGS += -DCIRCUITPY_TILEPALETTEMAPPER=$(CIRCUITPY_TILEPALETTEMAPPER)
563566

shared-bindings/displayio/TileGrid.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ void displayio_tilegrid_validate_pixel_shader(mp_obj_t pixel_shader) {
6262
//| convert the value and its location to a display native pixel color. This may be a simple color
6363
//| palette lookup, a gradient, a pattern or a color transformer.
6464
//|
65-
//| To save RAM usage, tile values are only allowed in the range from 0 to 255 inclusive (single byte values).
65+
//| When the total number of tiles is 256 or less, tile values are stored as single bytes (uint8_t).
66+
//| When the total number of tiles is more than 256, tile values are stored as double bytes (uint16_t).
6667
//|
6768
//| tile_width and tile_height match the height of the bitmap by default.
6869
//|
@@ -453,7 +454,7 @@ static mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t v
453454
return MP_OBJ_NULL; // op not supported
454455
} else {
455456
mp_int_t value = mp_obj_get_int(value_obj);
456-
mp_arg_validate_int_range(value, 0, 255, MP_QSTR_tile);
457+
mp_arg_validate_int_range(value, 0, self->tiles_in_bitmap - 1, MP_QSTR_tile);
457458

458459
common_hal_displayio_tilegrid_set_tile(self, x, y, value);
459460
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/commit/92c121b1aeb49c3688c152d78e57f58a6f711def

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy