diff --git a/lv_conf_template.h b/lv_conf_template.h index 8405cc734c..8bfe9da40c 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -725,8 +725,9 @@ /*1: Enable system monitor component*/ #define LV_USE_SYSMON 0 - #if LV_USE_SYSMON + /*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/ + #define LV_SYSMON_GET_IDLE lv_timer_get_idle /*1: Show CPU usage and FPS count * Requires `LV_USE_SYSMON = 1`*/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 98dff9594e..2fff711cf6 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -2375,8 +2375,15 @@ #define LV_USE_SYSMON 0 #endif #endif - #if LV_USE_SYSMON + /*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/ + #ifndef LV_SYSMON_GET_IDLE + #ifdef CONFIG_LV_SYSMON_GET_IDLE + #define LV_SYSMON_GET_IDLE CONFIG_LV_SYSMON_GET_IDLE + #else + #define LV_SYSMON_GET_IDLE lv_timer_get_idle + #endif + #endif /*1: Show CPU usage and FPS count * Requires `LV_USE_SYSMON = 1`*/ diff --git a/src/misc/lv_timer.c b/src/misc/lv_timer.c index 7b7ec2f862..5537e59109 100644 --- a/src/misc/lv_timer.c +++ b/src/misc/lv_timer.c @@ -258,7 +258,7 @@ void _lv_timer_core_deinit(void) _lv_ll_clear(timer_ll_p); } -uint8_t lv_timer_get_idle(void) +uint32_t lv_timer_get_idle(void) { return state.idle_last; } diff --git a/src/misc/lv_timer.h b/src/misc/lv_timer.h index 3b10c4cd15..06576a853b 100644 --- a/src/misc/lv_timer.h +++ b/src/misc/lv_timer.h @@ -224,7 +224,7 @@ void lv_timer_enable(bool en); * Get idle percentage * @return the lv_timer idle in percentage */ -uint8_t lv_timer_get_idle(void); +uint32_t lv_timer_get_idle(void); /** * Get the time remaining until the next timer will run diff --git a/src/others/sysmon/lv_sysmon.c b/src/others/sysmon/lv_sysmon.c index 1437153893..50bb83d66a 100644 --- a/src/others/sysmon/lv_sysmon.c +++ b/src/others/sysmon/lv_sysmon.c @@ -144,15 +144,18 @@ static void perf_monitor_disp_event_cb(lv_event_t * e) break; } } +uint32_t lv_os_get_idle_percent(void); static void perf_update_timer_cb(lv_timer_t * t) { + uint32_t LV_SYSMON_GET_IDLE(void); + lv_sysmon_perf_info_t * info = lv_timer_get_user_data(t); info->calculated.run_cnt++; info->calculated.fps = info->measured.refr_interval_sum ? (1000 * info->measured.refr_cnt / info->measured.refr_interval_sum) : 0; - info->calculated.cpu = 100 - lv_timer_get_idle(); + info->calculated.cpu = 100 - LV_SYSMON_GET_IDLE(); info->calculated.refr_avg_time = info->measured.refr_cnt ? (info->measured.refr_elaps_sum / info->measured.refr_cnt) : 0; info->calculated.flush_avg_time = info->measured.flush_cnt ? (info->measured.flush_elaps_sum / info->measured.flush_cnt)