Don't wait for display frame if interrupt pending

This commit is contained in:
Dan Halbert 2019-02-28 22:36:50 -05:00
parent 2c9fbb5d40
commit ced37c1001
2 changed files with 9 additions and 2 deletions

View File

@ -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;

View File

@ -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"
@ -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;
}