From 2be4e8299138d5862947e53ee4621b656cc8b2b6 Mon Sep 17 00:00:00 2001 From: _VIFEXTech <1290176185@qq.com> Date: Fri, 18 Feb 2022 18:32:16 +0800 Subject: [PATCH] fix(refr): fix performance monitor NULL pointer access (#3105) * fix(refr) performance monitor NULL pointer access * doc(refr): describe the setting of LV_DISP_DEF_REFR_PERIOD Co-authored-by: pengyiqiang --- docs/porting/display.md | 2 ++ src/core/lv_refr.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/porting/display.md b/docs/porting/display.md index c06a7c9c3..541c854fe 100644 --- a/docs/porting/display.md +++ b/docs/porting/display.md @@ -228,6 +228,8 @@ If you have multiple displays call `lv_disp_set_deafult(disp1);` to select the d Note that `lv_timer_handler()` and `_lv_disp_refr_timer()` can not run at the same time. +If the performance monitor is enabled, the value of `LV_DISP_DEF_REFR_PERIOD` needs to be set to be consistent with the refresh period of the display to ensure that the statistical results are correct. + ## Further reading - [lv_port_disp_template.c](https://github.com/lvgl/lvgl/blob/master/examples/porting/lv_port_disp_template.c) for a template for your own driver. diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index 1d7724658..05c0840df 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -376,9 +376,16 @@ void _lv_disp_refr_timer(lv_timer_t * tmr) } else { perf_monitor.perf_last_time = lv_tick_get(); - uint32_t fps_limit = 1000 / disp_refr->refr_timer->period; + uint32_t fps_limit; uint32_t fps; + if(disp_refr->refr_timer) { + fps_limit = 1000 / disp_refr->refr_timer->period; + } + else { + fps_limit = 1000 / LV_DISP_DEF_REFR_PERIOD; + } + if(perf_monitor.elaps_sum == 0) { perf_monitor.elaps_sum = 1; }