Remove displayio.*.show()

Use `displayio.*.root_group =`.
This commit is contained in:
Scott Shawcroft 2023-10-02 14:28:59 -07:00
parent a3c932062f
commit 8183d8ef50
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
12 changed files with 11 additions and 110 deletions

View File

@ -239,33 +239,6 @@ static displayio_display_obj_t *native_display(mp_obj_t display_obj) {
return MP_OBJ_TO_PTR(native_display); return MP_OBJ_TO_PTR(native_display);
} }
//| def show(self, group: Group) -> None:
//| """
//| .. note:: `show()` is deprecated and will be removed in CircuitPython 9.0.0.
//| Use ``.root_group = group`` instead.
//|
//| Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
//| :param Group group: The group to show.
//|
//| """
//| ...
STATIC mp_obj_t displayio_display_obj_show(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_show_obj, displayio_display_obj_show);
//| def refresh( //| def refresh(
//| self, //| self,
//| *, //| *,
@ -512,7 +485,6 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row); MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row);
STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_display_show_obj) },
{ MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_display_refresh_obj) }, { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_display_refresh_obj) },
{ MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&displayio_display_fill_row_obj) }, { MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&displayio_display_fill_row_obj) },

View File

@ -46,9 +46,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency); bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency);
bool common_hal_displayio_display_show(displayio_display_obj_t *self,
displayio_group_t *root_group);
bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame);
bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t *self); bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t *self);

View File

@ -245,31 +245,6 @@ static displayio_epaperdisplay_obj_t *native_display(mp_obj_t display_obj) {
return MP_OBJ_TO_PTR(native_display); return MP_OBJ_TO_PTR(native_display);
} }
//| def show(self, group: Group) -> None:
//| """
//| .. note:: `show()` is deprecated and will be removed in CircuitPython 9.0.0.
//| Use ``.root_group = group`` instead.
//|
//| Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
//| :param Group group: The group to show."""
//| ...
STATIC mp_obj_t displayio_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) {
displayio_epaperdisplay_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_epaperdisplay_show(self, group);
if (!ok) {
mp_raise_ValueError(translate("Group already used"));
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_show_obj, displayio_epaperdisplay_obj_show);
//| def update_refresh_mode( //| def update_refresh_mode(
//| self, start_sequence: ReadableBuffer, seconds_per_frame: float = 180 //| self, start_sequence: ReadableBuffer, seconds_per_frame: float = 180
//| ) -> None: //| ) -> None:
@ -415,7 +390,6 @@ MP_PROPERTY_GETSET(displayio_epaperdisplay_root_group_obj,
(mp_obj_t)&displayio_epaperdisplay_set_root_group_obj); (mp_obj_t)&displayio_epaperdisplay_set_root_group_obj);
STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = { STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_epaperdisplay_show_obj) },
{ MP_ROM_QSTR(MP_QSTR_update_refresh_mode), MP_ROM_PTR(&displayio_epaperdisplay_update_refresh_mode_obj) }, { MP_ROM_QSTR(MP_QSTR_update_refresh_mode), MP_ROM_PTR(&displayio_epaperdisplay_update_refresh_mode_obj) },
{ MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_epaperdisplay_refresh_obj) }, { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_epaperdisplay_refresh_obj) },

View File

@ -52,8 +52,6 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t
bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self); bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self);
bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group);
mp_obj_t common_hal_displayio_epaperdisplay_get_root_group(displayio_epaperdisplay_obj_t *self); mp_obj_t common_hal_displayio_epaperdisplay_get_root_group(displayio_epaperdisplay_obj_t *self);
bool common_hal_displayio_epaperdisplay_set_root_group(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group); bool common_hal_displayio_epaperdisplay_set_root_group(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group);

View File

@ -50,7 +50,7 @@
//| //|
//| board.DISPLAY.brightness = 0 //| board.DISPLAY.brightness = 0
//| splash = displayio.Group() //| splash = displayio.Group()
//| board.DISPLAY.show(splash) //| board.DISPLAY.root_group = splash
//| //|
//| odb = displayio.OnDiskBitmap('/sample.bmp') //| odb = displayio.OnDiskBitmap('/sample.bmp')
//| face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader) //| face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)

View File

@ -99,27 +99,6 @@ static framebufferio_framebufferdisplay_obj_t *native_display(mp_obj_t display_o
return MP_OBJ_TO_PTR(native_display); return MP_OBJ_TO_PTR(native_display);
} }
//| def show(self, group: displayio.Group) -> None:
//| """Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
//| :param Group group: The group to show."""
//| ...
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_show(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_show(self, group);
if (!ok) {
mp_raise_ValueError(translate("Group already used"));
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_show_obj, framebufferio_framebufferdisplay_obj_show);
//| def refresh( //| def refresh(
//| self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1 //| self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1
//| ) -> bool: //| ) -> bool:
@ -354,7 +333,6 @@ MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_root_group_obj,
(mp_obj_t)&framebufferio_framebufferdisplay_set_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_refresh), MP_ROM_PTR(&framebufferio_framebufferdisplay_refresh_obj) }, { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&framebufferio_framebufferdisplay_refresh_obj) },
{ MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&framebufferio_framebufferdisplay_fill_row_obj) }, { MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&framebufferio_framebufferdisplay_fill_row_obj) },

View File

@ -42,9 +42,6 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
uint16_t rotation, uint16_t rotation,
bool auto_refresh); bool auto_refresh);
bool common_hal_framebufferio_framebufferdisplay_show(framebufferio_framebufferdisplay_obj_t *self,
displayio_group_t *root_group);
bool common_hal_framebufferio_framebufferdisplay_refresh(framebufferio_framebufferdisplay_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); bool common_hal_framebufferio_framebufferdisplay_refresh(framebufferio_framebufferdisplay_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame);
bool common_hal_framebufferio_framebufferdisplay_get_auto_refresh(framebufferio_framebufferdisplay_obj_t *self); bool common_hal_framebufferio_framebufferdisplay_get_auto_refresh(framebufferio_framebufferdisplay_obj_t *self);

View File

@ -140,13 +140,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
common_hal_displayio_display_set_auto_refresh(self, auto_refresh); common_hal_displayio_display_set_auto_refresh(self, auto_refresh);
} }
bool common_hal_displayio_display_show(displayio_display_obj_t *self, displayio_group_t *root_group) {
if (root_group == NULL) {
root_group = &circuitpython_splash;
}
return displayio_display_core_set_root_group(&self->core, root_group);
}
uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t *self) { uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t *self) {
return displayio_display_core_get_width(&self->core); return displayio_display_core_get_width(&self->core);
} }

View File

@ -116,14 +116,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t
// Set the group after initialization otherwise we may send pixels while we delay in // Set the group after initialization otherwise we may send pixels while we delay in
// initialization. // initialization.
common_hal_displayio_epaperdisplay_show(self, &circuitpython_splash); common_hal_displayio_epaperdisplay_set_root_group(self, &circuitpython_splash);
}
bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group) {
if (root_group == NULL) {
root_group = &circuitpython_splash;
}
return displayio_display_core_set_root_group(&self->core, root_group);
} }
bool common_hal_displayio_epaperdisplay_set_root_group(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group) { bool common_hal_displayio_epaperdisplay_set_root_group(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group) {
@ -503,6 +496,11 @@ void release_epaperdisplay(displayio_epaperdisplay_obj_t *self) {
} }
} }
void displayio_epaperdisplay_reset(displayio_epaperdisplay_obj_t *self) {
displayio_display_core_set_root_group(&self->core, &circuitpython_splash);
self->core.full_refresh = true;
}
void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t *self) { void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t *self) {
displayio_display_core_collect_ptrs(&self->core); displayio_display_core_collect_ptrs(&self->core);
gc_collect_ptr((void *)self->start_sequence); gc_collect_ptr((void *)self->start_sequence);

View File

@ -62,6 +62,7 @@ typedef struct {
void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self, void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self,
mp_buffer_info_t *start_sequence, float seconds_per_frame); mp_buffer_info_t *start_sequence, float seconds_per_frame);
void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t *self); void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t *self);
void displayio_epaperdisplay_reset(displayio_epaperdisplay_obj_t *self);
void release_epaperdisplay(displayio_epaperdisplay_obj_t *self); void release_epaperdisplay(displayio_epaperdisplay_obj_t *self);
size_t maybe_refresh_epaperdisplay(void); size_t maybe_refresh_epaperdisplay(void);

View File

@ -302,7 +302,7 @@ void reset_displays(void) {
reset_display(&displays[i].display); reset_display(&displays[i].display);
} else if (display_type == &displayio_epaperdisplay_type) { } else if (display_type == &displayio_epaperdisplay_type) {
displayio_epaperdisplay_obj_t *display = &displays[i].epaper_display; displayio_epaperdisplay_obj_t *display = &displays[i].epaper_display;
common_hal_displayio_epaperdisplay_show(display, NULL); displayio_epaperdisplay_reset(display);
#if CIRCUITPY_FRAMEBUFFERIO #if CIRCUITPY_FRAMEBUFFERIO
} else if (display_type == &framebufferio_framebufferdisplay_type) { } else if (display_type == &framebufferio_framebufferdisplay_type) {
framebufferio_framebufferdisplay_reset(&displays[i].framebuffer_display); framebufferio_framebufferdisplay_reset(&displays[i].framebuffer_display);

View File

@ -100,17 +100,10 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
// Set the group after initialization otherwise we may send pixels while we delay in // Set the group after initialization otherwise we may send pixels while we delay in
// initialization. // initialization.
common_hal_framebufferio_framebufferdisplay_show(self, &circuitpython_splash); displayio_display_core_set_root_group(&self->core, &circuitpython_splash);
common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, auto_refresh); common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, auto_refresh);
} }
bool common_hal_framebufferio_framebufferdisplay_show(framebufferio_framebufferdisplay_obj_t *self, displayio_group_t *root_group) {
if (root_group == NULL) {
root_group = &circuitpython_splash;
}
return displayio_display_core_set_root_group(&self->core, root_group);
}
uint16_t common_hal_framebufferio_framebufferdisplay_get_width(framebufferio_framebufferdisplay_obj_t *self) { uint16_t common_hal_framebufferio_framebufferdisplay_get_width(framebufferio_framebufferdisplay_obj_t *self) {
return displayio_display_core_get_width(&self->core); return displayio_display_core_get_width(&self->core);
} }
@ -360,7 +353,7 @@ void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj
const mp_obj_type_t *fb_type = mp_obj_get_type(self->framebuffer); const mp_obj_type_t *fb_type = mp_obj_get_type(self->framebuffer);
if (fb_type != NULL && fb_type != &mp_type_NoneType) { if (fb_type != NULL && fb_type != &mp_type_NoneType) {
common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, true); common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, true);
common_hal_framebufferio_framebufferdisplay_show(self, NULL); displayio_display_core_set_root_group(&self->core, &circuitpython_splash);
self->core.full_refresh = true; self->core.full_refresh = true;
} else { } else {
release_framebufferdisplay(self); release_framebufferdisplay(self);