Add .busy property to EPaperDisplay

This commit is contained in:
Scott Shawcroft 2020-11-11 16:53:45 -08:00
parent 8d4296f964
commit 78ccac930f
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
3 changed files with 24 additions and 0 deletions

View File

@ -245,6 +245,23 @@ const mp_obj_property_t displayio_epaperdisplay_time_to_refresh_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| busy: bool
//| """True when the display is refreshing. This uses the ``busy_pin`` when available or the
//| ``refresh_time`` otherwise."""
//|
STATIC mp_obj_t displayio_epaperdisplay_obj_get_busy(mp_obj_t self_in) {
displayio_epaperdisplay_obj_t *self = native_display(self_in);
return mp_obj_new_bool(common_hal_displayio_epaperdisplay_get_busy(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_busy_obj, displayio_epaperdisplay_obj_get_busy);
const mp_obj_property_t displayio_epaperdisplay_busy_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&displayio_epaperdisplay_get_busy_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
//| width: int
//| """Gets the width of the display in pixels"""
//|
@ -301,6 +318,7 @@ STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_epaperdisplay_width_obj) },
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_epaperdisplay_height_obj) },
{ MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_epaperdisplay_bus_obj) },
{ MP_ROM_QSTR(MP_QSTR_busy), MP_ROM_PTR(&displayio_epaperdisplay_busy_obj) },
{ MP_ROM_QSTR(MP_QSTR_time_to_refresh), MP_ROM_PTR(&displayio_epaperdisplay_time_to_refresh_obj) },
};
STATIC MP_DEFINE_CONST_DICT(displayio_epaperdisplay_locals_dict, displayio_epaperdisplay_locals_dict_table);

View File

@ -52,6 +52,7 @@ bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t* self
// Returns time in milliseconds.
uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t* self);
bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* self);
uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t* self);
uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t* self);

View File

@ -360,6 +360,11 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
}
}
bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* self) {
displayio_epaperdisplay_background(self);
return self->refreshing;
}
void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) {
if (self->refreshing) {
wait_for_busy(self);