Merge pull request #1807 from pewpew-game/stage-cast-native

Allow use of displayio.Display subclasses in _stage
This commit is contained in:
Scott Shawcroft 2019-04-17 10:37:32 -07:00 committed by GitHub
commit bfbe9323ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,10 +83,12 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
uint16_t *buffer = bufinfo.buf; uint16_t *buffer = bufinfo.buf;
size_t buffer_size = bufinfo.len / 2; // 16-bit indexing size_t buffer_size = bufinfo.len / 2; // 16-bit indexing
if (!MP_OBJ_IS_TYPE(args[6], &displayio_display_type)) { mp_obj_t native_display = mp_instance_cast_to_native_base(args[6],
&displayio_display_type);
if (!MP_OBJ_IS_TYPE(native_display, &displayio_display_type)) {
mp_raise_TypeError(translate("argument num/types mismatch")); mp_raise_TypeError(translate("argument num/types mismatch"));
} }
displayio_display_obj_t *display = MP_OBJ_TO_PTR(args[6]); displayio_display_obj_t *display = MP_OBJ_TO_PTR(native_display);
while (!displayio_display_begin_transaction(display)) { while (!displayio_display_begin_transaction(display)) {
#ifdef MICROPY_VM_HOOK_LOOP #ifdef MICROPY_VM_HOOK_LOOP