@@ -215,28 +215,33 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in)
215
215
}
216
216
MP_DEFINE_CONST_FUN_OBJ_2 (displayio_display_show_obj , displayio_display_obj_show );
217
217
218
- //| def refresh(self, *, target_frames_per_second: int = 60 , minimum_frames_per_second: int = 1) -> bool:
218
+ //| def refresh(self, *, target_frames_per_second: Optional[ int] = None , minimum_frames_per_second: int = 1) -> bool:
219
219
//| """When auto refresh is off, waits for the target frame rate and then refreshes the display,
220
220
//| returning True. If the call has taken too long since the last refresh call for the given
221
221
//| target frame rate, then the refresh returns False immediately without updating the screen to
222
222
//| hopefully help getting caught up.
223
223
//|
224
224
//| If the time since the last successful refresh is
10000
below the minimum frame rate, then an
225
- //| exception will be raised. Set minimum_frames_per_second to 0 to disable.
225
+ //| exception will be raised. Set ``minimum_frames_per_second`` to 0 to disable.
226
+ //|
227
+ //| When auto refresh is off, ``display.refresh()`` or ``display.refresh(target_frames_per_second=None)``
228
+ //| will update the display immediately.
226
229
//|
227
230
//| When auto refresh is on, updates the display immediately. (The display will also update
228
231
//| without calls to this.)
229
232
//|
230
233
//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated.
234
+ //| Set to `None` for immediate refresh.
231
235
//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second."""
232
236
//| ...
233
237
//|
234
238
STATIC mp_obj_t displayio_display_obj_refresh (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
235
239
enum { ARG_target_frames_per_second , ARG_minimum_frames_per_second };
236
240
static const mp_arg_t allowed_args [] = {
237
- { MP_QSTR_target_frames_per_second , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 60 } },
241
+ { MP_QSTR_target_frames_per_second , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = mp_const_none } },
238
242
{ MP_QSTR_minimum_frames_per_second , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 1 } },
239
243
};
244
+
240
245
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
241
246
mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
242
247
@@ -246,8 +251,18 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos
246
251
if (minimum_frames_per_second > 0 ) {
247
252
maximum_ms_per_real_frame = 1000 / minimum_frames_per_second ;
248
253
}
249
- return mp_obj_new_bool (common_hal_displayio_display_refresh (self , 1000 / args [ARG_target_frames_per_second ].u_int , maximum_ms_per_real_frame ));
254
+
255
+ uint32_t target_ms_per_frame ;
256
+ if (args [ARG_target_frames_per_second ].u_obj == mp_const_none ) {
257
+ target_ms_per_frame = 0xffffffff ;
258
+ }
259
+ else {
260
+ target_ms_per_frame = 1000 / mp_obj_get_int (args [ARG_target_frames_per_second ].u_obj );
261
+ }
262
+
263
+ return mp_obj_new_bool (common_hal_displayio_display_refresh (self , target_ms_per_frame , maximum_ms_per_real_frame ));
250
264
}
265
+
251
266
MP_DEFINE_CONST_FUN_OBJ_KW (displayio_display_refresh_obj , 1 , displayio_display_obj_refresh );
252
267
253
268
//| auto_refresh: bool
0 commit comments