mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge pull request #1452 from littlevgl/task_repeat_count
Add lv_task_set_repeat_count API
This commit is contained in:
commit
be80438c92
@ -31,6 +31,11 @@ extern "C" {
|
||||
* V6.0 COMPATIBILITY
|
||||
*--------------------*/
|
||||
|
||||
static inline void lv_task_once(lv_task_t *task)
|
||||
{
|
||||
lv_task_set_repeat_count(task, 1);
|
||||
}
|
||||
|
||||
#if LV_USE_CHART
|
||||
|
||||
#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 */
|
||||
task->user_data = info;
|
||||
lv_task_once(task);
|
||||
lv_task_set_repeat_count(task, 1);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ lv_task_t * lv_task_create_basic(void)
|
||||
new_task->task_cb = NULL;
|
||||
new_task->prio = DEF_PRIO;
|
||||
|
||||
new_task->once = 0;
|
||||
new_task->repeat_count = -1;
|
||||
new_task->last_run = lv_tick_get();
|
||||
|
||||
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 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*/
|
||||
if(task_deleted == false) { /*The task might be deleted by itself as well*/
|
||||
if(task->once != 0) {
|
||||
lv_task_del(task);
|
||||
if(task->repeat_count > 0) {
|
||||
task->repeat_count--;
|
||||
}
|
||||
if(task->repeat_count == 0) {
|
||||
lv_task_del(task);
|
||||
}
|
||||
}
|
||||
exec = true;
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ typedef struct _lv_task_t {
|
||||
|
||||
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 once : 1; /**< 1: one shot task */
|
||||
} 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);
|
||||
|
||||
/**
|
||||
* Delete the lv_task after one call
|
||||
* Set the number of times a task will repeat.
|
||||
* @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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user