Skip to content

Commit 60b0192

Browse files
authored
Merge pull request #10099 from RetiredWizard/scaleterm
Add CIRCUITPY_TERMINAL_SCALE settings.toml parameter
2 parents 22e5a09 + e1260eb commit 60b0192

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

docs/environment.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,15 @@ Example: Configure the display to 640x480 black and white (1 bit per pixel):
174174
175175
`Adafruit Feather RP2350 <https://circuitpython.org/board/adafruit_feather_rp2350/>`_
176176
`Adafruit Metro RP2350 <https://circuitpython.org/board/adafruit_metro_rp2350/>`_
177+
178+
CIRCUITPY_TERMINAL_SCALE
179+
~~~~~~~~~~~~~~~~~~~~~~~~
180+
Allows the entry of a display scaling factor used during the terminalio console construction.
181+
The entered scaling factor only affects the terminalio console and has no impact on
182+
the UART, Web Workflow, BLE Workflow, etc consoles.
183+
184+
This feature is not enabled on boards that the CIRCUITPY_OS_GETENV (os CIRCUIPTY_FULL_BUILD)
185+
flag has been set to 0. Currently this is primarily boards with limited flash including some
186+
of the Atmel_samd boards based on the SAMD21/M0 microprocessor.
187+
188+
`boards that the terminalio core module is available on <https://docs.circuitpython.org/en/latest/shared-bindings/terminalio/>`_

shared-module/os/getenv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#include "extmod/vfs.h"
2929
#include "extmod/vfs_fat.h"
30+
31+
#if CIRCUITPY_OS_GETENV
3032
typedef FIL file_arg;
3133
static bool open_file(const char *name, file_arg *active_file) {
3234
#if defined(UNIX)
@@ -412,3 +414,4 @@ os_getenv_err_t common_hal_os_getenv_int(const char *key, mp_int_t *value) {
412414
common_hal_os_getenv_showerr(key, result);
413415
return result;
414416
}
417+
#endif

supervisor/shared/display.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737
#if CIRCUITPY_TERMINALIO
3838
#include "supervisor/port.h"
39+
#if CIRCUITPY_OS_GETENV
40+
#include "shared-module/os/__init__.h"
41+
#endif
3942
#endif
4043

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

6063
#if CIRCUITPY_TERMINALIO
6164
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) {
6669
if (width_in_tiles <= 80) {
6770
scale = 1;
6871
}
72+
#if CIRCUITPY_OS_GETENV
73+
(void)common_hal_os_getenv_int("CIRCUITPY_TERMINAL_SCALE", &scale);
74+
#endif
6975

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

0 commit comments

Comments
 (0)