Add NO_FPS_LIMIT instead of magic numbers
This commit is contained in:
parent
807edd4c66
commit
923a5b28ca
@ -276,7 +276,7 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
displayio_display_obj_t *self = native_display(pos_args[0]);
|
||||
uint32_t maximum_ms_per_real_frame = 0xffffffff;
|
||||
uint32_t maximum_ms_per_real_frame = NO_FPS_LIMIT;
|
||||
mp_int_t minimum_frames_per_second = args[ARG_minimum_frames_per_second].u_int;
|
||||
if (minimum_frames_per_second > 0) {
|
||||
maximum_ms_per_real_frame = 1000 / minimum_frames_per_second;
|
||||
@ -284,7 +284,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) {
|
||||
target_ms_per_frame = 0xffffffff;
|
||||
target_ms_per_frame = NO_FPS_LIMIT;
|
||||
} else {
|
||||
target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
extern const mp_obj_type_t displayio_display_type;
|
||||
|
||||
#define NO_BRIGHTNESS_COMMAND 0x100
|
||||
#define NO_FPS_LIMIT 0xffffffff
|
||||
|
||||
void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
||||
mp_obj_t bus, uint16_t width, uint16_t height,
|
||||
|
@ -136,7 +136,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, cons
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
framebufferio_framebufferdisplay_obj_t *self = native_display(pos_args[0]);
|
||||
uint32_t maximum_ms_per_real_frame = 0xffffffff;
|
||||
uint32_t maximum_ms_per_real_frame = NO_FPS_LIMIT;
|
||||
mp_int_t minimum_frames_per_second = args[ARG_minimum_frames_per_second].u_int;
|
||||
if (minimum_frames_per_second > 0) {
|
||||
maximum_ms_per_real_frame = 1000 / minimum_frames_per_second;
|
||||
@ -144,7 +144,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, cons
|
||||
|
||||
uint32_t target_ms_per_frame;
|
||||
if (args[ARG_target_frames_per_second].u_obj == mp_const_none) {
|
||||
target_ms_per_frame = 0xffffffff;
|
||||
target_ms_per_frame = NO_FPS_LIMIT;
|
||||
} else {
|
||||
target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
extern const mp_obj_type_t framebufferio_framebufferdisplay_type;
|
||||
|
||||
#define NO_BRIGHTNESS_COMMAND 0x100
|
||||
#define NO_FPS_LIMIT 0xffffffff
|
||||
|
||||
void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t *self,
|
||||
mp_obj_t framebuffer,
|
||||
|
@ -354,7 +354,7 @@ uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t *self
|
||||
|
||||
|
||||
bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) {
|
||||
if (!self->auto_refresh && !self->first_manual_refresh && (target_ms_per_frame != 0xffffffff)) {
|
||||
if (!self->auto_refresh && !self->first_manual_refresh && (target_ms_per_frame != NO_FPS_LIMIT)) {
|
||||
uint64_t current_time = supervisor_ticks_ms64();
|
||||
uint32_t current_ms_since_real_refresh = current_time - self->core.last_refresh;
|
||||
// Test to see if the real frame time is below our minimum.
|
||||
|
@ -283,7 +283,7 @@ uint16_t common_hal_framebufferio_framebufferdisplay_get_rotation(framebufferio_
|
||||
|
||||
|
||||
bool common_hal_framebufferio_framebufferdisplay_refresh(framebufferio_framebufferdisplay_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) {
|
||||
if (!self->auto_refresh && !self->first_manual_refresh && (target_ms_per_frame != 0xffffffff)) {
|
||||
if (!self->auto_refresh && !self->first_manual_refresh && (target_ms_per_frame != NO_FPS_LIMIT)) {
|
||||
uint64_t current_time = supervisor_ticks_ms64();
|
||||
uint32_t current_ms_since_real_refresh = current_time - self->core.last_refresh;
|
||||
// Test to see if the real frame time is below our minimum.
|
||||
|
Loading…
Reference in New Issue
Block a user