From 2cd5d4f5a542d77f117c01b3398daa6f21180b39 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 14 Nov 2022 15:10:28 -0600 Subject: [PATCH] allow setting root_group on Display --- shared-bindings/displayio/Display.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 512969eb20..15b5c4c4fa 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -423,8 +423,24 @@ STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group); -MP_PROPERTY_GETTER(displayio_display_root_group_obj, - (mp_obj_t)&displayio_display_get_root_group_obj); +STATIC mp_obj_t displayio_display_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) { + displayio_display_obj_t *self = native_display(self_in); + displayio_group_t *group = NULL; + if (group_in != mp_const_none) { + group = MP_OBJ_TO_PTR(native_group(group_in)); + } + + bool ok = common_hal_displayio_display_show(self, group); + if (!ok) { + mp_raise_ValueError(translate("Group already used")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_root_group_obj, displayio_display_obj_set_root_group); + +MP_PROPERTY_GETSET(displayio_display_root_group_obj, +(mp_obj_t)&displayio_display_get_root_group_obj, +(mp_obj_t)&displayio_display_set_root_group_obj); //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: