Skip to content

Commit 146271f

Browse files
authored
Merge pull request #1604 from dhalbert/display_wait_for_frame-check-interrupts
Don't wait for display frame if interrupt pending
2 parents 0ac4023 + ced37c1 commit 146271f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

shared-module/displayio/Display.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ void common_hal_displayio_display_refresh_soon(displayio_display_obj_t* self) {
147147

148148
int32_t common_hal_displayio_display_wait_for_frame(displayio_display_obj_t* self) {
149149
uint64_t last_refresh = self->last_refresh;
150-
while (last_refresh == self->last_refresh) {
150+
// Don't try to refresh if we got an exception.
151+
while (last_refresh == self->last_refresh && MP_STATE_VM(mp_pending_exception) == NULL) {
151152
MICROPY_VM_HOOK_LOOP
152153
}
153154
return 0;

shared-module/displayio/__init__.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include <string.h>
33
#include "shared-module/displayio/__init__.h"
44

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

2527
void displayio_refresh_displays(void) {
28+
if (mp_hal_is_interrupted()) {
29+
return;
30+
}
2631
// Somehow reloads from the sdcard are being lost. So, cheat and reraise.
27-
if (reload_requested) {
32+
// But don't re-raise if already pending.
33+
if (reload_requested && MP_STATE_VM(mp_pending_exception) == MP_OBJ_NULL) {
2834
mp_raise_reload_exception();
2935
return;
3036
}

0 commit comments

Comments
 (0)