lv_task: add idle measurement

This commit is contained in:
Gabor Kiss-Vamosi
2017-12-20 00:47:37 +01:00
parent 8164e8eac3
commit d239b319ef
3 changed files with 30 additions and 4 deletions

View File

@@ -14,6 +14,7 @@
/*********************
* DEFINES
*********************/
#define IDLE_MEAS_PERIOD 500 /*[ms]*/
/**********************
* TYPEDEFS
@@ -55,8 +56,14 @@ void lv_task_init(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;
handler_start = lv_tick_get();
lv_task_t* lv_task_prio_a[LV_TASK_PRIO_NUM]; /*Lists for all prio.*/
lv_task_prio_t prio_act;
bool prio_reset = false; /*Used to go back to the highest priority*/
@@ -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();
}
}
/**