3939#include "shared-module/displayio/__init__.h"
4040#include "supervisor/shared/translate.h"
4141
42+ STATIC int get_int_property (mp_obj_t obj , qstr attr ) {
43+ return mp_obj_get_int (mp_load_attr (obj , attr ));
44+ }
45+
4246//| .. currentmodule:: framebufferio
4347//|
4448//| :class:`FramebufferDisplay` -- Manage updating a display with framebuffer in RAM
@@ -70,8 +74,8 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t
7074 enum { ARG_framebuffer , ARG_width , ARG_height , ARG_rotation , ARG_color_depth , ARG_bytes_per_cell , ARG_auto_refresh , ARG_native_frames_per_second , NUM_ARGS };
7175 static const mp_arg_t allowed_args [] = {
7276 { MP_QSTR_framebuffer , MP_ARG_REQUIRED | MP_ARG_OBJ },
73- { MP_QSTR_width , MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , },
74- { MP_QSTR_height , MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , },
77+ { MP_QSTR_width , MP_ARG_INT | MP_ARG_KW_ONLY , {. u_int = 0 } },
78+ { MP_QSTR_height , MP_ARG_INT | MP_ARG_KW_ONLY , {. u_int = 0 } },
7579 { MP_QSTR_rotation , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 0 } },
7680 { MP_QSTR_color_depth , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 16 } },
7781 { MP_QSTR_bytes_per_cell , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 1 } },
@@ -84,6 +88,14 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t
8488
8589 mp_obj_t framebuffer = args [ARG_framebuffer ].u_obj ;
8690
91+ if (args [ARG_width ].u_int == 0 ) {
92+ args [ARG_width ].u_int = get_int_property (framebuffer , MP_QSTR_width );
93+ }
94+
95+ if (args [ARG_height ].u_int == 0 ) {
96+ args [ARG_height ].u_int = get_int_property (framebuffer , MP_QSTR_height );
97+ }
98+
8799 mp_int_t rotation = args [ARG_rotation ].u_int ;
88100 if (rotation % 90 != 0 ) {
89101 mp_raise_ValueError (translate ("Display rotation must be in 90 degree increments" ));
0 commit comments