BigW Consortium Gitlab

Commit d239b319 by Gabor Kiss-Vamosi

lv_task: add idle measurement

parent 8164e8ea
...@@ -27,13 +27,13 @@ extern "C" { ...@@ -27,13 +27,13 @@ extern "C" {
typedef struct typedef struct
{ {
uint32_t total_size;
uint32_t free_cnt; uint32_t free_cnt;
uint32_t used_cnt;
uint32_t free_size; uint32_t free_size;
uint32_t total_size;
uint32_t free_biggest_size; uint32_t free_biggest_size;
uint8_t frag_pct; uint32_t used_cnt;
uint8_t used_pct; uint8_t used_pct;
uint8_t frag_pct;
}lv_mem_monitor_t; }lv_mem_monitor_t;
/********************** /**********************
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define IDLE_MEAS_PERIOD 500 /*[ms]*/
/********************** /**********************
* TYPEDEFS * TYPEDEFS
...@@ -55,8 +56,14 @@ void lv_task_init(void) ...@@ -55,8 +56,14 @@ void lv_task_init(void)
*/ */
void lv_task_handler(void) void lv_task_handler(void)
{ {
static uint32_t idle_period_start = 0;
static uint32_t handler_start = 0;
static uint32_t busy_time = 0;
if(lv_task_run == false) return; if(lv_task_run == false) return;
handler_start = lv_tick_get();
lv_task_t* lv_task_prio_a[LV_TASK_PRIO_NUM]; /*Lists for all prio.*/ lv_task_t* lv_task_prio_a[LV_TASK_PRIO_NUM]; /*Lists for all prio.*/
lv_task_prio_t prio_act; lv_task_prio_t prio_act;
bool prio_reset = false; /*Used to go back to the highest priority*/ bool prio_reset = false; /*Used to go back to the highest priority*/
...@@ -100,6 +107,19 @@ void lv_task_handler(void) ...@@ -100,6 +107,19 @@ void lv_task_handler(void)
} }
} }
} }
busy_time += lv_tick_elaps(handler_start);
uint32_t idle_period_time = lv_tick_elaps(idle_period_start);
if(idle_period_time >= IDLE_MEAS_PERIOD) {
idle_last = (uint32_t)((uint32_t)busy_time * 100) / IDLE_MEAS_PERIOD; /*Calculate the busy percentage*/
idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/
busy_time = 0;
idle_period_start = lv_tick_get();
}
} }
/** /**
......
...@@ -123,6 +123,12 @@ void lv_task_reset(lv_task_t* lv_task_p); ...@@ -123,6 +123,12 @@ void lv_task_reset(lv_task_t* lv_task_p);
*/ */
void lv_task_enable(bool en); void lv_task_enable(bool en);
/**
* Get idle percentage
* @return the lv_task idle in percentage
*/
uint8_t lv_task_get_idle(void);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment