allow set_root_group for FrameBufferDisplay instead of show()

This commit is contained in:
foamyguy 2022-11-19 11:41:48 -06:00
parent e3cae22297
commit ef3398422a
3 changed files with 27 additions and 2 deletions

View File

@ -328,8 +328,24 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_root_group(mp_obj_t sel
} }
MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_root_group_obj, framebufferio_framebufferdisplay_obj_get_root_group); MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_root_group_obj, framebufferio_framebufferdisplay_obj_get_root_group);
MP_PROPERTY_GETTER(framebufferio_framebufferdisplay_root_group_obj, STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) {
(mp_obj_t)&framebufferio_framebufferdisplay_get_root_group_obj); framebufferio_framebufferdisplay_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_framebufferio_framebufferdisplay_set_root_group(self, group);
if (!ok) {
mp_raise_ValueError(translate("Group already used"));
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_set_root_group_obj, framebufferio_framebufferdisplay_obj_set_root_group);
MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_root_group_obj,
(mp_obj_t)&framebufferio_framebufferdisplay_get_root_group_obj,
(mp_obj_t)&framebufferio_framebufferdisplay_set_root_group_obj);
STATIC const mp_rom_map_elem_t framebufferio_framebufferdisplay_locals_dict_table[] = { STATIC const mp_rom_map_elem_t framebufferio_framebufferdisplay_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&framebufferio_framebufferdisplay_show_obj) }, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&framebufferio_framebufferdisplay_show_obj) },

View File

@ -61,5 +61,6 @@ bool common_hal_framebufferio_framebufferdisplay_set_brightness(framebufferio_fr
mp_obj_t common_hal_framebufferio_framebufferdisplay_framebuffer(framebufferio_framebufferdisplay_obj_t *self); mp_obj_t common_hal_framebufferio_framebufferdisplay_framebuffer(framebufferio_framebufferdisplay_obj_t *self);
mp_obj_t common_hal_framebufferio_framebufferdisplay_get_root_group(framebufferio_framebufferdisplay_obj_t *self); mp_obj_t common_hal_framebufferio_framebufferdisplay_get_root_group(framebufferio_framebufferdisplay_obj_t *self);
mp_obj_t common_hal_framebufferio_framebufferdisplay_set_root_group(framebufferio_framebufferdisplay_obj_t *self, displayio_group_t *root_group);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_FRAMEBUFFERDISPLAY_H #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_FRAMEBUFFERDISPLAY_H

View File

@ -362,3 +362,11 @@ void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj
mp_obj_t common_hal_framebufferio_framebufferdisplay_get_root_group(framebufferio_framebufferdisplay_obj_t *self) { mp_obj_t common_hal_framebufferio_framebufferdisplay_get_root_group(framebufferio_framebufferdisplay_obj_t *self) {
return self->core.current_group; return self->core.current_group;
} }
mp_obj_t common_hal_framebufferio_framebufferdisplay_set_root_group(framebufferio_framebufferdisplay_obj_t *self, displayio_group_t *root_group) {
bool ok = displayio_display_core_set_root_group(&self->core, root_group);
if (!ok) {
mp_raise_ValueError(translate("Group already used"));
}
return mp_const_none;
}