allow set_root_group for FrameBufferDisplay instead of show()
This commit is contained in:
parent
e3cae22297
commit
ef3398422a
|
@ -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_PROPERTY_GETTER(framebufferio_framebufferdisplay_root_group_obj,
|
||||
(mp_obj_t)&framebufferio_framebufferdisplay_get_root_group_obj);
|
||||
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) {
|
||||
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[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&framebufferio_framebufferdisplay_show_obj) },
|
||||
|
|
|
@ -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_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
|
||||
|
|
|
@ -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) {
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue