Skip to content

Don't wait for display frame if interrupt pending #1604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shared-module/displayio/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ void common_hal_displayio_display_refresh_soon(displayio_display_obj_t* self) {

int32_t common_hal_displayio_display_wait_for_frame(displayio_display_obj_t* self) {
uint64_t last_refresh = self->last_refresh;
while (last_refresh == self->last_refresh) {
// Don't try to refresh if we got an exception.
while (last_refresh == self->last_refresh && MP_STATE_VM(mp_pending_exception) == NULL) {
MICROPY_VM_HOOK_LOOP
}
return 0;
Expand Down
8 changes: 7 additions & 1 deletion shared-module/displayio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <string.h>
#include "shared-module/displayio/__init__.h"

#include "lib/utils/interrupt_char.h"
#include "py/reload.h"
#include "py/runtime.h"
#include "shared-bindings/displayio/Bitmap.h"
#include "shared-bindings/displayio/Display.h"
#include "shared-bindings/displayio/Group.h"
Expand All @@ -23,8 +25,12 @@ static inline void swap(uint16_t* a, uint16_t* b) {
bool refreshing_displays = false;

void displayio_refresh_displays(void) {
if (mp_hal_is_interrupted()) {
return;
}
// Somehow reloads from the sdcard are being lost. So, cheat and reraise.
if (reload_requested) {
// But don't re-raise if already pending.
if (reload_requested && MP_STATE_VM(mp_pending_exception) == MP_OBJ_NULL) {
mp_raise_reload_exception();
return;
}
Expand Down