displayio, framebufferio: Enable supervisor tick when a display is auto-refresh

This is a step towards restoring the efficiency of the background
tasks
This commit is contained in:
Jeff Epler 2020-07-08 10:32:06 -05:00
parent bdab6c12d4
commit af520729fe
3 changed files with 24 additions and 4 deletions

View File

@ -137,7 +137,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
common_hal_displayio_display_show(self, &circuitpython_splash);
self->auto_refresh = 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) {
@ -383,6 +383,13 @@ bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t* self
void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self,
bool auto_refresh) {
self->first_manual_refresh = !auto_refresh;
if (auto_refresh != self->auto_refresh) {
if (auto_refresh) {
supervisor_enable_tick();
} else {
supervisor_disable_tick();
}
}
self->auto_refresh = auto_refresh;
}
@ -409,6 +416,7 @@ void displayio_display_background(displayio_display_obj_t* self) {
}
void release_display(displayio_display_obj_t* self) {
common_hal_displayio_display_set_auto_refresh(self, false);
release_display_core(&self->core);
#if (CIRCUITPY_PULSEIO)
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
@ -423,7 +431,7 @@ void release_display(displayio_display_obj_t* self) {
}
void reset_display(displayio_display_obj_t* self) {
self->auto_refresh = true;
common_hal_displayio_display_set_auto_refresh(self, true);
self->auto_brightness = true;
common_hal_displayio_display_show(self, NULL);
}

View File

@ -187,6 +187,7 @@ void displayio_epaperdisplay_finish_refresh(displayio_epaperdisplay_obj_t* self)
displayio_display_core_begin_transaction(&self->core);
self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, &self->refresh_display_command, 1);
displayio_display_core_end_transaction(&self->core);
supervisor_enable_tick();
self->refreshing = true;
displayio_display_core_finish_refresh(&self->core);
@ -301,6 +302,7 @@ bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t* s
if (self->refreshing && self->busy.base.type == &digitalio_digitalinout_type) {
if (common_hal_digitalio_digitalinout_get_value(&self->busy) != self->busy_state) {
supervisor_disable_tick();
self->refreshing = false;
// Run stop sequence but don't wait for busy because busy is set when sleeping.
send_command_sequence(self, false, self->stop_sequence, self->stop_sequence_len);
@ -342,6 +344,7 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
refresh_done = supervisor_ticks_ms64() - self->core.last_refresh > self->refresh_time;
}
if (refresh_done) {
supervisor_disable_tick();
self->refreshing = false;
// Run stop sequence but don't wait for busy because busy is set when sleeping.
send_command_sequence(self, false, self->stop_sequence, self->stop_sequence_len);
@ -352,6 +355,7 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) {
if (self->refreshing) {
wait_for_busy(self);
supervisor_disable_tick();
self->refreshing = false;
// Run stop sequence but don't wait for busy because busy is set when sleeping.
send_command_sequence(self, false, self->stop_sequence, self->stop_sequence_len);

View File

@ -79,7 +79,7 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
common_hal_framebufferio_framebufferdisplay_show(self, &circuitpython_splash);
self->auto_refresh = 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) {
@ -280,6 +280,13 @@ bool common_hal_framebufferio_framebufferdisplay_get_auto_refresh(framebufferio_
void common_hal_framebufferio_framebufferdisplay_set_auto_refresh(framebufferio_framebufferdisplay_obj_t* self,
bool auto_refresh) {
self->first_manual_refresh = !auto_refresh;
if (auto_refresh != self->auto_refresh) {
if (auto_refresh) {
supervisor_enable_tick();
} else {
supervisor_disable_tick();
}
}
self->auto_refresh = auto_refresh;
}
@ -297,12 +304,13 @@ void framebufferio_framebufferdisplay_background(framebufferio_framebufferdispla
}
void release_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self) {
common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, false);
release_display_core(&self->core);
self->framebuffer_protocol->deinit(self->framebuffer);
}
void reset_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self) {
self->auto_refresh = true;
common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, true);
common_hal_framebufferio_framebufferdisplay_show(self, NULL);
}