diff --git a/docs/environment.rst b/docs/environment.rst index 461fd9273acd8..9f6b47c6fa849 100644 --- a/docs/environment.rst +++ b/docs/environment.rst @@ -174,3 +174,15 @@ Example: Configure the display to 640x480 black and white (1 bit per pixel): `Adafruit Feather RP2350 `_ `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 `_ diff --git a/shared-module/os/getenv.c b/shared-module/os/getenv.c index 39c3b4cee4ac7..c7bfadf3418d8 100644 --- a/shared-module/os/getenv.c +++ b/shared-module/os/getenv.c @@ -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) @@ -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 diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index f6788af0a8db4..32df5be74efce 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -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 @@ -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; @@ -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));