6262//| de_idle_high: bool,
6363//| pclk_active_high: bool,
6464//| pclk_idle_high: bool,
65+ //| overscan_left: int = 0,
6566//| ) -> None:
6667//| """Create a DotClockFramebuffer object associated with the given pins.
6768//|
105106//| :param bool de_idle_high: True if the de signal is high in IDLE state
106107//| :param bool pclk_active_high: True if the display data is clocked out at the rising edge of dclk
107108//| :param bool pclk_idle_high: True if the dclk stays at high level in IDLE phase
109+ //|
110+ //| :param int overscan_left: Allocate additional non-visible columns left of the first display column
108111//| """
112+ //| #:param int overscan_top: Allocate additional non-visible rows above the first display row
113+ //| #:param int overscan_right: Allocate additional non-visible columns right of the last display column
114+ //| #:param int overscan_bottom: Allocate additional non-visible rows below the last display row
109115//| ...
110116STATIC mp_obj_t dotclockframebuffer_framebuffer_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
111117 enum { ARG_de , ARG_vsync , ARG_hsync , ARG_dclk , ARG_red , ARG_green , ARG_blue ,
112118 ARG_frequency , ARG_width , ARG_height ,
113119 ARG_hsync_pulse_width , ARG_hsync_back_porch , ARG_hsync_front_porch , ARG_hsync_idle_low ,
114120 ARG_vsync_pulse_width , ARG_vsync_back_porch , ARG_vsync_front_porch , ARG_vsync_idle_low ,
115- ARG_de_idle_high , ARG_pclk_active_high , ARG_pclk_idle_high , };
121+ ARG_de_idle_high , ARG_pclk_active_high , ARG_pclk_idle_high ,
122+ ARG_overscan_left };
116123
117124 static const mp_arg_t allowed_args [] = {
118125 { MP_QSTR_de , MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , {.u_obj = mp_const_none } },
@@ -140,6 +147,8 @@ STATIC mp_obj_t dotclockframebuffer_framebuffer_make_new(const mp_obj_type_t *ty
140147 { MP_QSTR_de_idle_high , MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , {.u_bool = false } },
141148 { MP_QSTR_pclk_active_high , MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , {.u_bool = false } },
142149 { MP_QSTR_pclk_idle_high , MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , {.u_bool = false } },
150+
151+ { MP_QSTR_overscan_left , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 0 } },
143152 };
144153
145154 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
@@ -169,7 +178,8 @@ STATIC mp_obj_t dotclockframebuffer_framebuffer_make_new(const mp_obj_type_t *ty
169178 args [ARG_vsync_pulse_width ].u_int , args [ARG_vsync_back_porch ].u_int , args [ARG_vsync_front_porch ].u_int , args [ARG_vsync_idle_low ].u_bool ,
170179 args [ARG_de_idle_high ].u_bool ,
171180 args [ARG_pclk_active_high ].u_bool ,
172- args [ARG_pclk_idle_high ].u_bool
181+ args [ARG_pclk_idle_high ].u_bool ,
182+ args [ARG_overscan_left ].u_int
173183 );
174184
175185 return self ;
@@ -243,6 +253,24 @@ MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_height_obj, dotclo
243253MP_PROPERTY_GETTER (dotclockframebuffer_framebuffer_height_obj ,
244254 (mp_obj_t )& dotclockframebuffer_framebuffer_get_height_obj );
245255
256+ //| row_stride: int
257+ //| """The row_stride of the display, in bytes
258+ //|
259+ //| Due to overscan or alignment requirements, the memory address for row N+1 may not be exactly ``2*width`` bytes after the memory address for row N.
260+ //| This property gives the stride in **bytes**.
261+ //|
262+ //| On Espressif this value is **guaranteed** to be a multiple of the 2 (i.e., it is a whole number of pixels)"""
263+ //|
264+ STATIC mp_obj_t dotclockframebuffer_framebuffer_get_row_stride (mp_obj_t self_in ) {
265+ dotclockframebuffer_framebuffer_obj_t * self = (dotclockframebuffer_framebuffer_obj_t * )self_in ;
266+ check_for_deinit (self );
267+ return MP_OBJ_NEW_SMALL_INT (common_hal_dotclockframebuffer_framebuffer_get_row_stride (self ));
268+ }
269+ MP_DEFINE_CONST_FUN_OBJ_1 (dotclockframebuffer_framebuffer_get_row_stride_obj , dotclockframebuffer_framebuffer_get_row_stride );
270+
271+ MP_PROPERTY_GETTER (dotclockframebuffer_framebuffer_row_stride_obj ,
272+ (mp_obj_t )& dotclockframebuffer_framebuffer_get_row_stride_obj );
273+
246274STATIC mp_int_t dotclockframebuffer_framebuffer_get_buffer (mp_obj_t self_in , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
247275 dotclockframebuffer_framebuffer_obj_t * self = (dotclockframebuffer_framebuffer_obj_t * )self_in ;
248276 // a readonly framebuffer would be unusual but not impossible
@@ -300,6 +328,10 @@ STATIC void dotclockframebuffer_framebuffer_get_bufinfo(mp_obj_t self_in, mp_buf
300328 * bufinfo = self -> bufinfo ;
301329}
302330
331+ STATIC int dotclockframebuffer_framebuffer_get_row_stride_proto (mp_obj_t self_in ) {
332+ dotclockframebuffer_framebuffer_obj_t * self = (dotclockframebuffer_framebuffer_obj_t * )self_in ;
333+ return common_hal_dotclockframebuffer_framebuffer_get_row_stride (self );
334+ }
303335
304336STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
305337 MP_PROTO_IMPLEMENT (MP_QSTR_protocol_framebuffer )
@@ -309,6 +341,7 @@ STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
309341 .get_width = dotclockframebuffer_framebuffer_get_width_proto ,
310342 .get_height = dotclockframebuffer_framebuffer_get_height_proto ,
311343 .get_color_depth = dotclockframebuffer_framebuffer_get_color_depth_proto ,
344+ .get_row_stride = dotclockframebuffer_framebuffer_get_row_stride_proto ,
312345 .get_bytes_per_cell = dotclockframebuffer_framebuffer_get_bytes_per_cell_proto ,
313346 .get_native_frames_per_second = dotclockframebuffer_framebuffer_get_native_frames_per_second_proto ,
314347 .swapbuffers = dotclockframebuffer_framebuffer_swapbuffers ,
@@ -319,6 +352,7 @@ STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
319352STATIC const mp_rom_map_elem_t dotclockframebuffer_framebuffer_locals_dict_table [] = {
320353 { MP_ROM_QSTR (MP_QSTR_width ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_width_obj ) },
321354 { MP_ROM_QSTR (MP_QSTR_height ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_height_obj ) },
355+ { MP_ROM_QSTR (MP_QSTR_row_stride ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_row_stride_obj ) },
322356 { MP_ROM_QSTR (MP_QSTR_frequency ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_frequency_obj ) },
323357 { MP_ROM_QSTR (MP_QSTR_refresh_rate ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_refresh_rate_obj ) },
324358 { MP_ROM_QSTR (MP_QSTR_refresh ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_refresh_obj ) },
0 commit comments