62
62
//| de_idle_high: bool,
63
63
//| pclk_active_high: bool,
64
64
//| pclk_idle_high: bool,
65
+ //| overscan_left: int = 0,
65
66
//| ) -> None:
66
67
//| """Create a DotClockFramebuffer object associated with the given pins.
67
68
//|
105
106
//| :param bool de_idle_high: True if the de signal is high in IDLE state
106
107
//| :param bool pclk_active_high: True if the display data is clocked out at the rising edge of dclk
107
108
//| :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
108
111
//| """
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
109
115
//| ...
110
116
STATIC 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 ) {
111
117
enum { ARG_de , ARG_vsync , ARG_hsync , ARG_dclk , ARG_red , ARG_green , ARG_blue ,
112
118
ARG_frequency , ARG_width , ARG_height ,
113
119
ARG_hsync_pulse_width , ARG_hsync_back_porch , ARG_hsync_front_porch , ARG_hsync_idle_low ,
114
120
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 };
116
123
117
124
static const mp_arg_t allowed_args [] = {
118
125
{ 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
140
147
{ MP_QSTR_de_idle_high , MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , {.u_bool = false } },
141
148
{ MP_QSTR_pclk_active_high , MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED , {.u_bool = false } },
142
149
{ 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 } },
143
152
};
144
153
145
154
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
169
178
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 ,
170
179
args [ARG_de_idle_high ].u_bool ,
171
180
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
173
183
);
174
184
175
185
return self ;
@@ -243,6 +253,24 @@ MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_height_obj, dotclo
243
253
MP_PROPERTY_GETTER (dotclockframebuffer_framebuffer_height_obj ,
244
254
(mp_obj_t )& dotclockframebuffer_framebuffer_get_height_obj );
245
255
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
+
246
274
STATIC mp_int_t dotclockframebuffer_framebuffer_get_buffer (mp_obj_t self_in , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
247
275
dotclockframebuffer_framebuffer_obj_t * self = (dotclockframebuffer_framebuffer_obj_t * )self_in ;
248
276
// 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
300
328
* bufinfo = self -> bufinfo ;
301
329
}
302
330
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
+ }
303
335
304
336
STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
305
337
MP_PROTO_IMPLEMENT (MP_QSTR_protocol_framebuffer )
@@ -309,6 +341,7 @@ STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
309
341
.get_width = dotclockframebuffer_framebuffer_get_width_proto ,
310
342
.get_height = dotclockframebuffer_framebuffer_get_height_proto ,
311
343
.get_color_depth = dotclockframebuffer_framebuffer_get_color_depth_proto ,
344
+ .get_row_stride = dotclockframebuffer_framebuffer_get_row_stride_proto ,
312
345
.get_bytes_per_cell = dotclockframebuffer_framebuffer_get_bytes_per_cell_proto ,
313
346
.get_native_frames_per_second = dotclockframebuffer_framebuffer_get_native_frames_per_second_proto ,
314
347
.swapbuffers = dotclockframebuffer_framebuffer_swapbuffers ,
@@ -319,6 +352,7 @@ STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
319
352
STATIC const mp_rom_map_elem_t dotclockframebuffer_framebuffer_locals_dict_table [] = {
320
353
{ MP_ROM_QSTR (MP_QSTR_width ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_width_obj ) },
321
354
{ 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 ) },
322
356
{ MP_ROM_QSTR (MP_QSTR_frequency ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_frequency_obj ) },
323
357
{ MP_ROM_QSTR (MP_QSTR_refresh_rate ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_refresh_rate_obj ) },
324
358
{ MP_ROM_QSTR (MP_QSTR_refresh ), MP_ROM_PTR (& dotclockframebuffer_framebuffer_refresh_obj ) },
0 commit comments