Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6e1ff07
Remove fixed display limit
tannewt Nov 20, 2026
2b4fb9d
Add a simple display lifetime mode
tannewt Nov 26, 2026
9f0f61f
Shrink the new display lifetime mode further
tannewt Nov 30, 2026
e59ff96
Remove special function to find board displays
tannewt Dec 1, 2026
1638933
Use proper MP protocol
tannewt Dec 1, 2026
d619504
Don't deinit board buses automatically
tannewt Dec 1, 2026
b6185ad
Split lifecycle stuff from proxy object
tannewt Dec 1, 2026
b93626c
Fix epaper build
tannewt Dec 1, 2026
1f69438
Make sure boards set their display as primary
tannewt Dec 1, 2026
dad2729
Accept any display for primary
tannewt Dec 2, 2026
2a4187e
Rename and rework based on feedback
tannewt Dec 2, 2026
91459df
Make deinited displays and buses False
tannewt Dec 3, 2026
9c3c554
Merge remote-tracking branch 'adafruit/main' into infinite_displays
tannewt Dec 3, 2026
f20bec8
Rely on gc_collect to potentially shared resources
tannewt Dec 3, 2026
1620c05
Rename all {start,stop}_vm functions
tannewt Dec 3, 2026
0571f93
check_for_deinit in displays and buses
tannewt Dec 3, 2026
5d04e7d
Correct zephyr i2c lock
tannewt Dec 3, 2026
1189e84
Ensure one Zephyr Display at a time
tannewt Dec 3, 2026
78c354a
Rename backlight_adopt so it matches on_vm_start clearly
tannewt Dec 3, 2026
4a065fe
Have web workflow check all display buses
tannewt Dec 3, 2026
cba0836
Rework LVGL displayio for mutliple displays
tannewt Dec 3, 2026
308e01e
Fix up Monster Mask
tannewt Dec 4, 2026
b3fdcea
Raise when a display is given a deinited bus or framebuffer
dhalbert Dec 4, 2026
4bf9a96
Clear pointers to freed objects on deinit
dhalbert Dec 4, 2026
3e0034c
Fix LVGL EPaperDisplay constructor cleanup and Zephyr display recreation
dhalbert Dec 4, 2026
f288f66
Add is_deinited to the picodvi framebuffer protocol
dhalbert Dec 4, 2026
10f6de5
Track RGBMatrix deinit with an explicit flag
dhalbert Dec 4, 2026
7664801
Update stale comment about the one-Display limit
dhalbert Dec 4, 2026
ca427fe
Add CIRCUITPY-CHANGE marker to the gc.c finaliser type assert
dhalbert Dec 4, 2026
922abe0
Document that only supervisor.runtime.display shows the terminal
dhalbert Dec 4, 2026
c396e65
Fix proxy unwrapping in non-self places
tannewt Dec 4, 2026
dde7be3
Merge remote-tracking branch 'adafruit/main' into infinite_displays
tannewt Dec 4, 2026
bac75f4
Don't expose a backlight built from backlight_pin
dhalbert Dec 4, 2026
d2ac59d
espcamera: finalise the camera before its I2C bus
dhalbert Dec 4, 2026
43e5751
Merge branch 'infinite_displays' into dhalbert-11963-review-fixes
tannewt Dec 4, 2026
7b8f6d4
Merge pull request #28 from adafruit/dhalbert-11963-review-fixes
tannewt Dec 4, 2026
02b33e2
Merge pull request #29 from adafruit/dhalbert-11963-backlight
tannewt Dec 4, 2026
9dd489b
Merge pull request #30 from adafruit/dhalbert-11963-camera-i2c
tannewt Dec 4, 2026
4a4128a
Update hwdesigns_crescent_city
tannewt Dec 4, 2026
c24ebd9
Apply suggestion from @dhalbert
tannewt Dec 4, 2026
958c7e1
Raise when reading BusDisplay.backlight after deinit
dhalbert Dec 4, 2026
e3c024c
Swap deinit check and valid check order
tannewt Dec 4, 2026
6d5068a
Merge pull request #31 from adafruit/dhalbert-11963-backlight-deinit
tannewt Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 14 additions & 13 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ msgstr ""
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
#: ports/stm/common-hal/pulseio/PulseIn.c py/argcheck.c
#: shared-bindings/bitmaptools/__init__.c shared-bindings/canio/Match.c
#: shared-bindings/time/__init__.c
#: shared-bindings/time/__init__.c shared-module/displayio/lvgl/Group.c
msgid "%q out of range"
msgstr ""

Expand Down Expand Up @@ -1745,10 +1745,9 @@ msgstr ""
#: ports/raspberrypi/common-hal/usb_host/Port.c
#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/emmcio/EMMC.c
#: shared-bindings/i2cioexpander/IOPin.c shared-bindings/microcontroller/Pin.c
#: shared-module/_airlift/__init__.c
#: shared-module/epaperdisplay/EPaperDisplay.c
#: shared-module/max3421e/Max3421E.c shared-module/usb/core/Device.c
#: shared-module/usb_host_audio/USBIn.c
#: shared-module/_airlift/__init__.c shared-module/audiotap/LevelReader.c
#: shared-module/epaperdisplay/epaper_core.c shared-module/max3421e/Max3421E.c
#: shared-module/usb/core/Device.c shared-module/usb_host_audio/USBIn.c
msgid "%q in use"
msgstr ""

Expand Down Expand Up @@ -2051,8 +2050,8 @@ msgstr ""
#: shared-bindings/bitmapfilter/__init__.c shared-bindings/canio/CAN.c
#: shared-bindings/digitalio/Pull.c shared-bindings/picogame/Sprite.c
#: shared-bindings/supervisor/__init__.c shared-module/audiofilters/__init__.c
#: shared-module/displayio/legacy/__init__.c
#: shared-module/synthio/Synthesizer.c shared-module/videocore/VideoBuffer.c
#: shared-module/displayio/lifetime.c shared-module/synthio/Synthesizer.c
#: shared-module/videocore/VideoBuffer.c
msgid "%q must be of type %q or %q, not %q"
msgstr ""

Expand Down Expand Up @@ -4601,12 +4600,18 @@ msgstr ""
msgid "unsupported bitmap depth"
msgstr ""

#: shared-module/busdisplay/__init__.c
msgid "%q must be a DigitalInOut, PWMOut or None"
msgstr ""

#: shared-module/busdisplay/lvgl/BusDisplay.c
#: shared-module/epaperdisplay/lvgl/EPaperDisplay.c
#: shared-module/framebufferio/lvgl/FramebufferDisplay.c
msgid "LVGL display create failed"
msgstr ""

#: shared-module/busdisplay/lvgl/BusDisplay.c
#: shared-module/epaperdisplay/lvgl/EPaperDisplay.c
#: shared-module/framebufferio/lvgl/FramebufferDisplay.c
msgid "LVGL buffer alloc failed"
msgstr ""
Expand Down Expand Up @@ -4654,12 +4659,8 @@ msgstr ""
msgid "Unable to read color palette data"
msgstr ""

#: shared-module/displayio/legacy/__init__.c
msgid "Too many displays"
msgstr ""

#: shared-module/displayio/legacy/__init__.c
msgid "Too many display buses; deinit() unused displays"
#: shared-module/displayio/lifetime.c
msgid "expected %q"
msgstr ""

#: shared-module/displayio/lvgl/Group.c
Expand Down
28 changes: 9 additions & 19 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ static void start_mp(safe_mode_t safe_mode) {
common_hal_os_chdir("/");

_vm_is_running = true;
#if CIRCUITPY_DISPLAYIO
displayio_on_vm_start();
#endif
}

static void stop_mp(void) {
Expand Down Expand Up @@ -350,9 +353,6 @@ static void count_strn(void *data, const char *str, size_t len) {
}

static void cleanup_after_vm(mp_obj_t exception) {
// Do any port cleanup needed before anything else, including releasing board buses.
reset_port_early();

// Get the traceback of any exception from this run off the heap.
// MP_OBJ_SENTINEL means "this run does not contribute to traceback storage, don't touch it"
// MP_OBJ_NULL (=0) means "this run completed successfully, clear any stored traceback"
Expand Down Expand Up @@ -405,9 +405,9 @@ static void cleanup_after_vm(mp_obj_t exception) {
videogif_reset();
#endif

// Turn off the display and flush the filesystem before the heap disappears.
// Release or preserve displays while their drivers and the VM still exist.
#if CIRCUITPY_DISPLAYIO
reset_displays();
displayio_on_vm_stop();
#endif

#if CIRCUITPY_MEMORYMONITOR
Expand Down Expand Up @@ -452,10 +452,8 @@ static void cleanup_after_vm(mp_obj_t exception) {
reset_port();
reset_board();

// Free the heap last because other modules may reference heap memory and need to shut down.
// Free the heap last because other modules may reference heap memory.
filesystem_flush();

// Runs finalisers while shutting down the heap.
stop_mp();

// Let the workflows know we've reset in case they want to restart.
Expand Down Expand Up @@ -714,10 +712,9 @@ static bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
// OK to start sleeping, real or fake.
const bool true_deep_sleep = awoke_from_true_deep_sleep || !supervisor_workflow_active();
#if CIRCUITPY_DISPLAYIO
// A fake sleep doesn't run boot.py again, so keep a display set as
// supervisor.runtime.display. Also leave the board as a reload does, because
// board_init() can't make its own display if the kept one fills the slots.
keep_display_in_fake_sleep = !true_deep_sleep && common_hal_displayio_primary_display_set_by_user();
// A fake sleep doesn't run boot.py again, so preserve a user-selected
// display and leave the board initialized, as on soft reload.
keep_display_in_fake_sleep = !true_deep_sleep && common_hal_supervisor_runtime_display_set_by_user();
if (!keep_display_in_fake_sleep) {
common_hal_displayio_release_displays();
}
Expand Down Expand Up @@ -838,9 +835,6 @@ static bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
if (fake_sleeping) {
if (!keep_display_in_fake_sleep) {
board_init();
#if CIRCUITPY_DISPLAYIO
common_hal_displayio_auto_primary_display();
#endif
}
// Undo any preserve_dios.
#if CIRCUITPY_ALARM_PRESERVE_DIOS
Expand Down Expand Up @@ -1146,10 +1140,6 @@ int __attribute__((used)) main(void) {
// displays init after filesystem, since they could share the flash SPI
board_init();

#if CIRCUITPY_DISPLAYIO
common_hal_displayio_auto_primary_display();
#endif

mp_hal_stdout_tx_str(line_clear);

// This is first time we are running CircuitPython after a reset or power-up.
Expand Down
13 changes: 13 additions & 0 deletions ports/analog/common-hal/busio/I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {
return self->sda == NULL;
}

bool common_hal_busio_i2c_is_moveable(busio_i2c_obj_t *self) {
return !common_hal_busio_i2c_deinited(self) && !self->has_lock;
}

bool common_hal_busio_i2c_move(busio_i2c_obj_t *self, busio_i2c_obj_t *destination) {
if (!common_hal_busio_i2c_is_moveable(self)) {
return false;
}
*destination = *self;
self->sda = NULL;
return true;
}

// Deinit i2c obj, reset I2C pin
void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
MXC_I2C_Shutdown(self->i2c_regs);
Expand Down
2 changes: 1 addition & 1 deletion ports/analog/common-hal/busio/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct {
mxc_i2c_regs_t *i2c_regs;
const mcu_pin_obj_t *scl;
const mcu_pin_obj_t *sda;
const int frequency;
uint32_t frequency;

uint32_t timeout;
bool has_lock;
Expand Down
13 changes: 13 additions & 0 deletions ports/analog/common-hal/busio/SPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ void common_hal_busio_spi_mark_deinit(busio_spi_obj_t *self) {
self->sck = NULL;
}

bool common_hal_busio_spi_is_moveable(busio_spi_obj_t *self) {
return !common_hal_busio_spi_deinited(self) && !self->has_lock;
}

bool common_hal_busio_spi_move(busio_spi_obj_t *self, busio_spi_obj_t *destination) {
if (!common_hal_busio_spi_is_moveable(self)) {
return false;
}
*destination = *self;
common_hal_busio_spi_mark_deinit(self);
return true;
}

// Deinit SPI obj
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {

Expand Down
13 changes: 13 additions & 0 deletions ports/analog/common-hal/digitalio/DigitalInOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *se
return self->pin == NULL;
}

bool common_hal_digitalio_digitalinout_is_moveable(digitalio_digitalinout_obj_t *self) {
return !common_hal_digitalio_digitalinout_deinited(self);
}

bool common_hal_digitalio_digitalinout_move(digitalio_digitalinout_obj_t *self, digitalio_digitalinout_obj_t *destination) {
if (!common_hal_digitalio_digitalinout_is_moveable(self)) {
return false;
}
*destination = *self;
self->pin = NULL;
return true;
}

digitalinout_result_t common_hal_digitalio_digitalinout_construct(
digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin) {

Expand Down
16 changes: 14 additions & 2 deletions ports/atmel-samd/boards/hallowing_m0_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ uint8_t display_init_sequence[] = {
0x29, 0 | DELAY, 100, // _DISPON
};

static fourwire_fourwire_obj_t display_bus;
busdisplay_busdisplay_obj_t board_display;

void board_init(void) {
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
fourwire_fourwire_obj_t *bus = displayio_native_init(&display_bus, &fourwire_fourwire_type, 0, MP_OBJ_NULL, true);
if (bus == NULL) {
return;
}
bus->base.type = &fourwire_fourwire_type;
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
common_hal_fourwire_fourwire_construct(bus,
Expand All @@ -60,7 +66,12 @@ void board_init(void) {
0, // Polarity
0); // Phase

busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
busdisplay_busdisplay_obj_t *display = displayio_native_init(
&board_display, &busdisplay_busdisplay_type, 0, MP_OBJ_FROM_PTR(bus), true);

if (display == NULL) {
return;
}
display->base.type = &busdisplay_busdisplay_type;
common_hal_busdisplay_busdisplay_construct(display,
bus,
Expand Down Expand Up @@ -90,6 +101,7 @@ void board_init(void) {
true, // backlight_on_high
false, // not SH1107
50000); // backlight pwm frequency
common_hal_supervisor_runtime_set_display(MP_OBJ_FROM_PTR(display), false);
}

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
11 changes: 11 additions & 0 deletions ports/atmel-samd/boards/hallowing_m0_express/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#pragma once

#include "shared-module/busdisplay/BusDisplay.h"

extern busdisplay_busdisplay_obj_t board_display;
4 changes: 3 additions & 1 deletion ports/atmel-samd/boards/hallowing_m0_express/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "shared-bindings/board/__init__.h"

#include "board.h"

#include "supervisor/board.h"
#include "shared-module/displayio/__init__.h"

Expand Down Expand Up @@ -73,6 +75,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },

{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&board_display) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
15 changes: 13 additions & 2 deletions ports/atmel-samd/boards/hallowing_m4_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ uint8_t display_init_sequence[] = {
0x29, 0 | DELAY, 255, // _DISPON
};

static fourwire_fourwire_obj_t board_display_bus;
busdisplay_busdisplay_obj_t board_display;

void board_init(void) {
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
fourwire_fourwire_obj_t *bus = displayio_native_init(&board_display_bus, &fourwire_fourwire_type, 0, MP_OBJ_NULL, true);
if (bus == NULL) {
return;
}
busio_spi_obj_t *spi = &bus->inline_bus;
common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL, false);

Expand All @@ -41,7 +47,11 @@ void board_init(void) {
0, // Polarity
0); // Phase

busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
busdisplay_busdisplay_obj_t *display = displayio_native_init(&board_display, &busdisplay_busdisplay_type, 0, MP_OBJ_FROM_PTR(bus), true);

if (display == NULL) {
return;
}
display->base.type = &busdisplay_busdisplay_type;
common_hal_busdisplay_busdisplay_construct(display,
bus,
Expand Down Expand Up @@ -71,6 +81,7 @@ void board_init(void) {
true, // backlight_on_high
false, // not SH1107
50000); // backlight pwm frequency
common_hal_supervisor_runtime_set_display(MP_OBJ_FROM_PTR(display), false);
}

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
11 changes: 11 additions & 0 deletions ports/atmel-samd/boards/hallowing_m4_express/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#pragma once

#include "shared-module/busdisplay/BusDisplay.h"

extern busdisplay_busdisplay_obj_t board_display;
4 changes: 3 additions & 1 deletion ports/atmel-samd/boards/hallowing_m4_express/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "shared-bindings/board/__init__.h"

#include "board.h"

#include "shared-module/displayio/__init__.h"

static const mp_rom_map_elem_t board_module_globals_table[] = {
Expand Down Expand Up @@ -77,6 +79,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },

{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&board_display) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Loading
Loading