diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 91fe3a681..8727ca8a1 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -68,13 +68,13 @@ void lv_indev_init(void) * Called periodically to read the input devices * @param param pointer to and input device to read */ -void lv_indev_read_task(void * param) +void lv_indev_read_task(lv_task_t * task) { LV_LOG_TRACE("indev read task started"); lv_indev_data_t data; - indev_act = param; + indev_act = task->user_data; /*Read and process all indevs*/ if(indev_act->driver.disp == NULL) return; /*Not assigned to any displays*/ diff --git a/src/lv_core/lv_indev.h b/src/lv_core/lv_indev.h index e29afc761..f1adeca88 100644 --- a/src/lv_core/lv_indev.h +++ b/src/lv_core/lv_indev.h @@ -36,9 +36,9 @@ void lv_indev_init(void); /** * Called periodically to read the input devices - * @param param pointer to and input device to read + * @param task pointer to the task itself */ -void lv_indev_read_task(void * param); +void lv_indev_read_task(lv_task_t * task); /** * Get the currently processed input device. Can be used in action functions too. diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index b8ff84710..155b8c75f 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -132,15 +132,15 @@ lv_disp_t * lv_refr_get_disp_refreshing(void) /** * Called periodically to handle the refreshing - * @param param point to a `lv_disp_t` to refresh + * @param task pointer to the task itself */ -void lv_disp_refr_task(void * param) +void lv_disp_refr_task(lv_task_t * task) { LV_LOG_TRACE("lv_refr_task: started"); uint32_t start = lv_tick_get(); - disp_refr = param; + disp_refr = task->user_data; lv_refr_join_area(); diff --git a/src/lv_core/lv_refr.h b/src/lv_core/lv_refr.h index 990e32f87..ed74a0ea8 100644 --- a/src/lv_core/lv_refr.h +++ b/src/lv_core/lv_refr.h @@ -69,9 +69,9 @@ lv_disp_t * lv_refr_get_disp_refreshing(void); /** * Called periodically to handle the refreshing - * @param param point to a `lv_disp_t` to refresh + * @param task pointer to the task itself */ -void lv_disp_refr_task(void * param); +void lv_disp_refr_task(lv_task_t * task); /********************** * STATIC FUNCTIONS diff --git a/src/lv_misc/lv_task.c b/src/lv_misc/lv_task.c index b009ee34c..e2ece2abf 100644 --- a/src/lv_misc/lv_task.c +++ b/src/lv_misc/lv_task.c @@ -138,7 +138,7 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) if(task_deleted) break; /*If a task was deleted then this or the next item might be corrupted*/ if(task_created) - break; /*If a task was deleted then this or the next item might be corrupted*/ + break; /*If a task was created then this or the next item might be corrupted*/ LV_GC_ROOT(_lv_task_act) = next; /*Load the next task*/ } @@ -165,7 +165,7 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) * @param task a function which is the task itself * @param period call period in ms unit * @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) - * @param user_data free parameter + * @param user_data custom parameter * @return pointer to the new task */ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t prio, void * user_data) @@ -198,12 +198,20 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t } new_lv_task->period = period; - new_lv_task->task = task; + new_lv_task->task_cb = task; new_lv_task->prio = prio; - new_lv_task->param = user_data; + new_lv_task->once = 0; new_lv_task->last_run = lv_tick_get(); +#if LV_USE_USER_DATA_SINGLE + new_lv_task->user_data = user_data; +#endif + +#if LV_USE_USER_DATA_MULTI + new_lv_task->task_user_data = NULL; +#endif + task_created = true; return new_lv_task; @@ -322,7 +330,7 @@ static bool lv_task_exec(lv_task_t * lv_task_p) lv_task_p->last_run = lv_tick_get(); task_deleted = false; task_created = false; - lv_task_p->task(lv_task_p->param); + lv_task_p->task_cb(lv_task_p); /*Delete if it was a one shot lv_task*/ if(task_deleted == false) { /*The task might be deleted by itself as well*/ diff --git a/src/lv_misc/lv_task.h b/src/lv_misc/lv_task.h index 8d5112260..e3959a98d 100644 --- a/src/lv_misc/lv_task.h +++ b/src/lv_misc/lv_task.h @@ -55,8 +55,16 @@ typedef struct { uint32_t period; uint32_t last_run; - void (*task)(void *); - void * param; + void (*task_cb)(void *); + +#if LV_USE_USER_DATA_SINGLE + void * user_data; +#endif + +#if LV_USE_USER_DATA_MULTI + void * task_user_data; +#endif + uint8_t prio : 3; uint8_t once : 1; } lv_task_t; @@ -80,15 +88,14 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void); * @param task a function which is the task itself * @param period call period in ms unit * @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) - * @param user_data free parameter - * @return pointer to the new task + * @param user_data custom parameter + * @return pointer to the new task_cb */ -lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t prio, - void * user_data); +lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t prio, void * user_data); /** * Delete a lv_task - * @param lv_task_p pointer to task created by lv_task_p + * @param lv_task_p pointer to task_cb created by lv_task_p */ void lv_task_del(lv_task_t * lv_task_p);