Skip to content

Commit 2cd5d4f

Browse files
committed
allow setting root_group on Display
1 parent 8f414eb commit 2cd5d4f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

shared-bindings/displayio/Display.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,24 @@ STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) {
423423
}
424424
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group);
425425

426-
MP_PROPERTY_GETTER(displayio_display_root_group_obj,
427-
(mp_obj_t)&displayio_display_get_root_group_obj);
426+
STATIC mp_obj_t displayio_display_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) {
427+
displayio_display_obj_t *self = native_display(self_in);
428+
displayio_group_t *group = NULL;
429+
if (group_in != mp_const_none) {
430+
group = MP_OBJ_TO_PTR(native_group(group_in));
431+
}
432+
433+
bool ok = common_hal_displayio_display_show(self, group);
434+
if (!ok) {
435+
mp_raise_ValueError(translate("Group already used"));
436+
}
437+
return mp_const_none;
438+
}
439+
MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_root_group_obj, displayio_display_obj_set_root_group);
440+
441+
MP_PROPERTY_GETSET(displayio_display_root_group_obj,
442+
(mp_obj_t)&displayio_display_get_root_group_obj,
443+
(mp_obj_t)&displayio_display_set_root_group_obj);
428444

429445

430446
//| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer:

0 commit comments

Comments
 (0)