diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-06-11 18:01:04 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2019-06-11 18:01:04 -0400 |
| commit | aa3316b619c8a8bcddd889fa0b806e5798973137 (patch) | |
| tree | 1775e6ec52138cb18f89455026887c785ffa7dac /shared-module | |
| parent | ea760c042bcdff61792a4b5f3de0b3ec212c44c4 (diff) | |
| parent | 541c2a70acab02c419f1ddd4a0ffc38c23a054a0 (diff) | |
Merge remote-tracking branch 'adafruit/master' into vm-computed-goto
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/board/__init__.c | 2 | ||||
| -rw-r--r-- | shared-module/displayio/__init__.c | 16 | ||||
| -rw-r--r-- | shared-module/displayio/__init__.h | 1 |
3 files changed, 16 insertions, 3 deletions
diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index ac4de2fe5..be8502bc0 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -103,7 +103,7 @@ void reset_board_busses(void) { #endif #if BOARD_SPI bool display_using_spi = false; - #ifdef CIRCUITPY_DISPLAYIO + #if CIRCUITPY_DISPLAYIO for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { if (displays[i].fourwire_bus.bus == spi_singleton) { display_using_spi = true; diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 0f2e727dc..35bdad8fe 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -3,6 +3,7 @@ #include "shared-module/displayio/__init__.h" #include "lib/utils/interrupt_char.h" +#include "py/gc.h" #include "py/reload.h" #include "py/runtime.h" #include "shared-bindings/board/__init__.h" @@ -192,7 +193,6 @@ void common_hal_displayio_release_displays(void) { } void reset_displays(void) { - #if CIRCUITPY_DISPLAYIO // The SPI buses used by FourWires may be allocated on the heap so we need to move them inline. for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { if (displays[i].fourwire_bus.base.type != &displayio_fourwire_type) { @@ -229,7 +229,19 @@ void reset_displays(void) { display->auto_brightness = true; common_hal_displayio_display_show(display, &circuitpython_splash); } - #endif +} + +void displayio_gc_collect(void) { + for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { + if (displays[i].display.base.type == NULL) { + continue; + } + + // Alternatively, we could use gc_collect_root over the whole object, + // but this is more precise, and is the only field that needs marking. + gc_collect_ptr(displays[i].display.current_group); + + } } void displayio_area_shift(displayio_area_t* area, int16_t dx, int16_t dy) { diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h index 7ffc8eab2..18c1a4f4a 100644 --- a/shared-module/displayio/__init__.h +++ b/shared-module/displayio/__init__.h @@ -46,5 +46,6 @@ extern displayio_group_t circuitpython_splash; void displayio_refresh_displays(void); void reset_displays(void); +void displayio_gc_collect(void); #endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO___INIT___H |
