From 8eb7721b4aa838608d6e3b28b96992e3d2db42b4 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 4 Oct 2023 22:42:12 +1100 Subject: [PATCH] extmod/modframebuf: Remove FrameBuffer1 from natmod build. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- examples/natmod/framebuf/framebuf.c | 1 - extmod/modframebuf.c | 2 +- tests/extmod/framebuf1.py | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/natmod/framebuf/framebuf.c b/examples/natmod/framebuf/framebuf.c index 32b67eabcf..badc7ab46d 100644 --- a/examples/natmod/framebuf/framebuf.c +++ b/examples/natmod/framebuf/framebuf.c @@ -36,7 +36,6 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a MP_OBJ_TYPE_SET_SLOT(&mp_type_framebuf, locals_dict, (void*)&framebuf_locals_dict, 2); mp_store_global(MP_QSTR_FrameBuffer, MP_OBJ_FROM_PTR(&mp_type_framebuf)); - mp_store_global(MP_QSTR_FrameBuffer1, MP_OBJ_FROM_PTR(&legacy_framebuffer1_obj)); mp_store_global(MP_QSTR_MVLSB, MP_OBJ_NEW_SMALL_INT(FRAMEBUF_MVLSB)); mp_store_global(MP_QSTR_MONO_VLSB, MP_OBJ_NEW_SMALL_INT(FRAMEBUF_MVLSB)); mp_store_global(MP_QSTR_RGB565, MP_OBJ_NEW_SMALL_INT(FRAMEBUF_RGB565)); diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index c62ac4fe39..92313bd4bb 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -864,6 +864,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); #endif +#if !MICROPY_ENABLE_DYNRUNTIME // This factory function is provided for backwards compatibility with the old // FrameBuffer1 class which did not support a format argument. STATIC mp_obj_t legacy_framebuffer1(size_t n_args, const mp_obj_t *args_in) { @@ -872,7 +873,6 @@ STATIC mp_obj_t legacy_framebuffer1(size_t n_args, const mp_obj_t *args_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(legacy_framebuffer1_obj, 3, 4, legacy_framebuffer1); -#if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t framebuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_framebuf) }, { MP_ROM_QSTR(MP_QSTR_FrameBuffer), MP_ROM_PTR(&mp_type_framebuf) }, diff --git a/tests/extmod/framebuf1.py b/tests/extmod/framebuf1.py index b1173d5368..f5e92579f2 100644 --- a/tests/extmod/framebuf1.py +++ b/tests/extmod/framebuf1.py @@ -106,8 +106,9 @@ except ValueError: print("ValueError") # test legacy constructor -fbuf = framebuf.FrameBuffer1(buf, w, h) -fbuf = framebuf.FrameBuffer1(buf, w, h, w) +if hasattr(framebuf, "FrameBuffer1"): + fbuf = framebuf.FrameBuffer1(buf, w, h) + fbuf = framebuf.FrameBuffer1(buf, w, h, w) print(framebuf.MVLSB == framebuf.MONO_VLSB) # test get-buffer (returns the original buffer)