Add lv_task_set_repeat_count API
This commit is contained in:
@@ -31,6 +31,11 @@ extern "C" {
|
|||||||
* V6.0 COMPATIBILITY
|
* V6.0 COMPATIBILITY
|
||||||
*--------------------*/
|
*--------------------*/
|
||||||
|
|
||||||
|
static inline void lv_task_once(lv_task_t *task)
|
||||||
|
{
|
||||||
|
lv_task_set_repeat_count(task, 1);
|
||||||
|
}
|
||||||
|
|
||||||
#if LV_USE_CHART
|
#if LV_USE_CHART
|
||||||
|
|
||||||
#define lv_chart_get_point_cnt lv_chart_get_point_count
|
#define lv_chart_get_point_cnt lv_chart_get_point_count
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data)
|
|||||||
|
|
||||||
/* Set the task's user data */
|
/* Set the task's user data */
|
||||||
task->user_data = info;
|
task->user_data = info;
|
||||||
lv_task_once(task);
|
lv_task_set_repeat_count(task, 1);
|
||||||
return LV_RES_OK;
|
return LV_RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ lv_task_t * lv_task_create_basic(void)
|
|||||||
new_task->task_cb = NULL;
|
new_task->task_cb = NULL;
|
||||||
new_task->prio = DEF_PRIO;
|
new_task->prio = DEF_PRIO;
|
||||||
|
|
||||||
new_task->once = 0;
|
new_task->repeat_count = -1;
|
||||||
new_task->last_run = lv_tick_get();
|
new_task->last_run = lv_tick_get();
|
||||||
|
|
||||||
new_task->user_data = NULL;
|
new_task->user_data = NULL;
|
||||||
@@ -341,12 +341,13 @@ void lv_task_ready(lv_task_t * task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the lv_task after one call
|
* Set the number of times a task will repeat.
|
||||||
* @param task pointer to a lv_task.
|
* @param task pointer to a lv_task.
|
||||||
|
* @param repeat_count -1 : infinity; 0 : stop ; n>0: residual times
|
||||||
*/
|
*/
|
||||||
void lv_task_once(lv_task_t * task)
|
void lv_task_set_repeat_count(lv_task_t * task, int32_t repeat_count)
|
||||||
{
|
{
|
||||||
task->once = 1;
|
task->repeat_count = repeat_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,9 +399,12 @@ static bool lv_task_exec(lv_task_t * task)
|
|||||||
|
|
||||||
/*Delete if it was a one shot lv_task*/
|
/*Delete if it was a one shot lv_task*/
|
||||||
if(task_deleted == false) { /*The task might be deleted by itself as well*/
|
if(task_deleted == false) { /*The task might be deleted by itself as well*/
|
||||||
if(task->once != 0) {
|
if(task->repeat_count > 0) {
|
||||||
lv_task_del(task);
|
task->repeat_count--;
|
||||||
}
|
}
|
||||||
|
if(task->repeat_count == 0) {
|
||||||
|
lv_task_del(task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exec = true;
|
exec = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ typedef struct _lv_task_t {
|
|||||||
|
|
||||||
void * user_data; /**< Custom user data */
|
void * user_data; /**< Custom user data */
|
||||||
|
|
||||||
|
int32_t repeat_count; /**< 1: Task times; -1 : infinity; 0 : stop ; n>0: residual times */
|
||||||
uint8_t prio : 3; /**< Task priority */
|
uint8_t prio : 3; /**< Task priority */
|
||||||
uint8_t once : 1; /**< 1: one shot task */
|
|
||||||
} lv_task_t;
|
} lv_task_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -140,10 +140,11 @@ void lv_task_set_period(lv_task_t * task, uint32_t period);
|
|||||||
void lv_task_ready(lv_task_t * task);
|
void lv_task_ready(lv_task_t * task);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the lv_task after one call
|
* Set the number of times a task will repeat.
|
||||||
* @param task pointer to a lv_task.
|
* @param task pointer to a lv_task.
|
||||||
|
* @param repeat_count -1 : infinity; 0 : stop ; n>0: residual times
|
||||||
*/
|
*/
|
||||||
void lv_task_once(lv_task_t * task);
|
void lv_task_set_repeat_count(lv_task_t * task, int32_t repeat_count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset a lv_task.
|
* Reset a lv_task.
|
||||||
|
|||||||
Reference in New Issue
Block a user