diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-06-11 16:16:29 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2019-06-11 16:16:29 -0400 |
| commit | 4fc189b60c800f097db55c16768fa8c73eb72ccf (patch) | |
| tree | 7829990c07bbd80c490bc03508d6e0d1c25e166b /shared-module/displayio/__init__.c | |
| parent | c85e111675ccfb0c03aa06bd3461f5a3c026ec87 (diff) | |
| parent | 036e7a332baea537d1a0b28854393fe1790b0991 (diff) | |
Merge latest 4.0.x fixes into master
Diffstat (limited to 'shared-module/displayio/__init__.c')
| -rw-r--r-- | shared-module/displayio/__init__.c | 16 |
1 files changed, 14 insertions, 2 deletions
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) { |
