Skip to content

Add CIRCUITPY_TERMINAL_SCALE settings.toml parameter #10099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 27, 2025
12 changes: 12 additions & 0 deletions docs/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,15 @@ Example: Configure the display to 640x480 black and white (1 bit per pixel):

`Adafruit Feather RP2350 <https://circuitpython.org/board/adafruit_feather_rp2350/>`_
`Adafruit Metro RP2350 <https://circuitpython.org/board/adafruit_metro_rp2350/>`_

CIRCUITPY_TERMINAL_SCALE
~~~~~~~~~~~~~~~~~~~~~~~~
Allows the entry of a display scaling factor used during the terminalio console construction.
The entered scaling factor only affects the terminalio console and has no impact on
the UART, Web Workflow, BLE Workflow, etc consoles.

This feature is not enabled on boards that the CIRCUITPY_OS_GETENV (os CIRCUIPTY_FULL_BUILD)
flag has been set to 0. Currently this is primarily boards with limited flash including some
of the Atmel_samd boards based on the SAMD21/M0 microprocessor.

`boards that the terminalio core module is available on <https://docs.circuitpython.org/en/latest/shared-bindings/terminalio/>`_
3 changes: 3 additions & 0 deletions shared-module/os/getenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"

#if CIRCUITPY_OS_GETENV
typedef FIL file_arg;
static bool open_file(const char *name, file_arg *active_file) {
#if defined(UNIX)
Expand Down Expand Up @@ -412,3 +414,4 @@ os_getenv_err_t common_hal_os_getenv_int(const char *key, mp_int_t *value) {
common_hal_os_getenv_showerr(key, result);
return result;
}
#endif
8 changes: 7 additions & 1 deletion supervisor/shared/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

#if CIRCUITPY_TERMINALIO
#include "supervisor/port.h"
#if CIRCUITPY_OS_GETENV
#include "shared-module/os/__init__.h"
#endif
#endif

#if CIRCUITPY_REPL_LOGO
Expand All @@ -55,7 +58,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
}
// Default the scale to 2 because we may show blinka without the terminal for
// languages that don't have font support.
uint8_t scale = 2;
mp_int_t scale = 2;

#if CIRCUITPY_TERMINALIO
displayio_tilegrid_t *scroll_area = &supervisor_terminal_scroll_area_text_grid;
Expand All @@ -66,6 +69,9 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
if (width_in_tiles <= 80) {
scale = 1;
}
#if CIRCUITPY_OS_GETENV
(void)common_hal_os_getenv_int("CIRCUITPY_TERMINAL_SCALE", &scale);
#endif

width_in_tiles = MAX(1, width_px / (scroll_area->tile_width * scale));
uint16_t height_in_tiles = MAX(2, height_px / (scroll_area->tile_height * scale));
Expand Down