diff --git a/src/drivers/nuttx/lv_nuttx_entry.c b/src/drivers/nuttx/lv_nuttx_entry.c index 1754b6205..559f9bbac 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.c +++ b/src/drivers/nuttx/lv_nuttx_entry.c @@ -12,6 +12,7 @@ #include #include +#include #include #include "lv_nuttx_cache.h" #include "lv_nuttx_image_cache.h" @@ -158,6 +159,26 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result) #endif } +#ifdef CONFIG_SCHED_CPULOAD + +uint32_t lv_nuttx_get_idle(void) +{ + struct cpuload_s cpuload; + int ret = clock_cpuload(0, &cpuload); + if(ret < 0) { + LV_LOG_WARN("clock_cpuload failed: %d", ret); + return 0; + } + + uint32_t idle = cpuload.active * 100 / cpuload.total; + LV_LOG_TRACE("active = %" LV_PRIu32 ", total = %" LV_PRIu32, + cpuload.active, cpuload.total); + + return idle; +} + +#endif + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/drivers/nuttx/lv_nuttx_entry.h b/src/drivers/nuttx/lv_nuttx_entry.h index e54ec0a4c..2e0d8bd71 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.h +++ b/src/drivers/nuttx/lv_nuttx_entry.h @@ -78,6 +78,12 @@ void lv_nuttx_init_custom(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result #endif /* LV_USE_NUTTX_CUSTOM_INIT */ +/** + * Get the idle percentage of the system. + * @return The idle percentage of the system. + */ +uint32_t lv_nuttx_get_idle(void); + /********************** * MACROS **********************/