From fc513956be8cb0389d450308f6363c6b742af072 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 09:36:29 -0500 Subject: Update refresh to force immediate redraw with display.refresh() or display.refresh(target_frames_per_second=None), even with auto_refresh=False --- shared-bindings/displayio/Display.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index c4fbdab2e..ff003ab4b 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -227,6 +227,9 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is on, updates the display immediately. (The display will also update //| without calls to this.) //| +//| When auto refresh is off, refresh() or refresh(target_frames_per_second=None) will update +//| the display immediately. +//| //| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... @@ -234,9 +237,11 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_target_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 60} }, + //{ MP_QSTR_target_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 60} }, + { MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(60)} }, { MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -246,8 +251,18 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos if (minimum_frames_per_second > 0) { maximum_ms_per_real_frame = 1000 / minimum_frames_per_second; } - 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)); + + uint32_t target_ms_per_frame; + if ( (args[ARG_target_frames_per_second].u_obj == mp_const_none) || (n_args == 1) ) { // if None or no arguments + target_ms_per_frame = 0xffffffff; + } + else { + target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj); + } + + return mp_obj_new_bool(common_hal_displayio_display_refresh(self, target_ms_per_frame, maximum_ms_per_real_frame)); } + MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_refresh_obj, 1, displayio_display_obj_refresh); //| auto_refresh: bool -- cgit v1.2.3 From c4b1db006f3f091f67076226e26c3f53c9e76f8b Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 09:38:57 -0500 Subject: delete unnecessary comment --- shared-bindings/displayio/Display.c | 1 - 1 file changed, 1 deletion(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index ff003ab4b..cf1b840dc 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -237,7 +237,6 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; static const mp_arg_t allowed_args[] = { - //{ MP_QSTR_target_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 60} }, { MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(60)} }, { MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, }; -- cgit v1.2.3 From 8be862e644dad22641f5a4f9c1520f91df08d7a5 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 10:26:48 -0500 Subject: Remove trailing whitespace --- shared-bindings/displayio/Display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index cf1b840dc..9f3148dc7 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -227,7 +227,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is on, updates the display immediately. (The display will also update //| without calls to this.) //| -//| When auto refresh is off, refresh() or refresh(target_frames_per_second=None) will update +//| When auto refresh is off, refresh() or refresh(target_frames_per_second=None) will update //| the display immediately. //| //| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. @@ -252,8 +252,9 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos } uint32_t target_ms_per_frame; - if ( (args[ARG_target_frames_per_second].u_obj == mp_const_none) || (n_args == 1) ) { // if None or no arguments - target_ms_per_frame = 0xffffffff; + if ( (args[ARG_target_frames_per_second].u_obj == mp_const_none) || (n_args == 1) ) { + // if None or no arguments + target_ms_per_frame = 0xffffffff; } else { target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj); -- cgit v1.2.3 From e14de385283ad01b17e5abf51c5830db59a1a0f2 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 13:57:19 -0500 Subject: Revise .refresh input default value for target_frames_per_second to None --- shared-bindings/displayio/Display.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 9f3148dc7..b9e8d02b4 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -215,7 +215,7 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in) } MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show); -//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> bool: +//| def refresh(self, *, target_frames_per_second: int = None, minimum_frames_per_second: int = 1) -> bool: //| """When auto refresh is off, waits for the target frame rate and then refreshes the display, //| returning True. If the call has taken too long since the last refresh call for the given //| target frame rate, then the refresh returns False immediately without updating the screen to @@ -231,13 +231,14 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| the display immediately. //| //| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. +//| Set to None for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(60)} }, + { MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, { MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, }; @@ -252,8 +253,7 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos } uint32_t target_ms_per_frame; - if ( (args[ARG_target_frames_per_second].u_obj == mp_const_none) || (n_args == 1) ) { - // if None or no arguments + if (args[ARG_target_frames_per_second].u_obj == mp_const_none) { target_ms_per_frame = 0xffffffff; } else { -- cgit v1.2.3 From f5015e4485e8885d1af2507f61229a09faa332f3 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 14:36:43 -0500 Subject: Add hanging tab to doc --- shared-bindings/displayio/Display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index b9e8d02b4..a11a17c55 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -231,7 +231,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| the display immediately. //| //| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. -//| Set to None for immediate refresh. +//| Set to None for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| -- cgit v1.2.3 From c6529daac576aa3492abef2073b7e597c3ffee5d Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 14:44:32 -0500 Subject: Added some backticks to clarify the docs --- shared-bindings/displayio/Display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index a11a17c55..3df36d1bd 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -227,11 +227,11 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is on, updates the display immediately. (The display will also update //| without calls to this.) //| -//| When auto refresh is off, refresh() or refresh(target_frames_per_second=None) will update +//| When auto refresh is off, `refresh()` or `refresh(target_frames_per_second=None)` will update //| the display immediately. //| //| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. -//| Set to None for immediate refresh. +//| Set to `None` for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| -- cgit v1.2.3 From 649a955a74ec8206dfb53511e7a2e6a679968648 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 15:02:37 -0500 Subject: Modified docs to try to pass sphinx build --- shared-bindings/displayio/Display.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 3df36d1bd..9b63e4fec 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -230,8 +230,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is off, `refresh()` or `refresh(target_frames_per_second=None)` will update //| the display immediately. //| -//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. -//| Set to `None` for immediate refresh. +//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. Set to `None` for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| -- cgit v1.2.3 From 7b6d805580a3da679bd14807c7646c5a8c830ef6 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 15:40:55 -0500 Subject: Add Optional[int] to docs string --- shared-bindings/displayio/Display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 9b63e4fec..4d94fa1e0 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -215,7 +215,7 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in) } MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show); -//| def refresh(self, *, target_frames_per_second: int = None, minimum_frames_per_second: int = 1) -> bool: +//| def refresh(self, *, target_frames_per_second: Optional[int] = None, minimum_frames_per_second: int = 1) -> bool: //| """When auto refresh is off, waits for the target frame rate and then refreshes the display, //| returning True. If the call has taken too long since the last refresh call for the given //| target frame rate, then the refresh returns False immediately without updating the screen to @@ -230,7 +230,8 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is off, `refresh()` or `refresh(target_frames_per_second=None)` will update //| the display immediately. //| -//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. Set to `None` for immediate refresh. +//| :param int target_frames_per_second: How many times a second `refresh` should be called +//| and the screen updated. Set to `None` for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| -- cgit v1.2.3 From 554cc356dbdce74101e86090d71ea2955908f78a Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 15:43:18 -0500 Subject: Delete trailing whitespace --- shared-bindings/displayio/Display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 4d94fa1e0..5d9569f4c 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -230,7 +230,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is off, `refresh()` or `refresh(target_frames_per_second=None)` will update //| the display immediately. //| -//| :param int target_frames_per_second: How many times a second `refresh` should be called +//| :param int target_frames_per_second: How many times a second `refresh` should be called //| and the screen updated. Set to `None` for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... -- cgit v1.2.3 From 4b9306aa7cc87a5c0eed52db36cbccd5d00152b6 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Sep 2020 18:10:40 -0500 Subject: Cleanup for sphinx --- shared-bindings/displayio/Display.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 5d9569f4c..72b0eef27 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -227,11 +227,11 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| When auto refresh is on, updates the display immediately. (The display will also update //| without calls to this.) //| -//| When auto refresh is off, `refresh()` or `refresh(target_frames_per_second=None)` will update +//| When auto refresh is off, refresh() or refresh(target_frames_per_second=None) will update //| the display immediately. //| -//| :param int target_frames_per_second: How many times a second `refresh` should be called -//| and the screen updated. Set to `None` for immediate refresh. +//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. +//| Set to None for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| -- cgit v1.2.3 From 8256bf7ea68d714f16503c97329632b7c0ca477d Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Wed, 2 Sep 2020 11:20:30 -0500 Subject: Add backticks to function references in docs --- shared-bindings/displayio/Display.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 72b0eef27..fa180fe38 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -222,16 +222,16 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| hopefully help getting caught up. //| //| If the time since the last successful refresh is below the minimum frame rate, then an -//| exception will be raised. Set minimum_frames_per_second to 0 to disable. +//| exception will be raised. Set ``minimum_frames_per_second`` to 0 to disable. +//| +//| When auto refresh is off, ``display.refresh()`` or ``display.refresh(target_frames_per_second=None)`` +//| will update the display immediately. //| //| When auto refresh is on, updates the display immediately. (The display will also update //| without calls to this.) //| -//| When auto refresh is off, refresh() or refresh(target_frames_per_second=None) will update -//| the display immediately. -//| //| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. -//| Set to None for immediate refresh. +//| Set to `None` for immediate refresh. //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" //| ... //| -- cgit v1.2.3 From d224183a7e10ed2b10c92f9cc2f8a14412b1ed0a Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Wed, 2 Sep 2020 11:26:37 -0500 Subject: Delete trailing whitespace --- shared-bindings/displayio/Display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared-bindings') diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index fa180fe38..f36aeed18 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -224,7 +224,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show //| If the time since the last successful refresh is below the minimum frame rate, then an //| exception will be raised. Set ``minimum_frames_per_second`` to 0 to disable. //| -//| When auto refresh is off, ``display.refresh()`` or ``display.refresh(target_frames_per_second=None)`` +//| When auto refresh is off, ``display.refresh()`` or ``display.refresh(target_frames_per_second=None)`` //| will update the display immediately. //| //| When auto refresh is on, updates the display immediately. (The display will also update -- cgit v1.2.3