/**1* @file lv_task.c2* An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically.3* A priority (5 levels + disable) can be assigned to lv_tasks.4*/56#ifndef LV_TASK_H7#define LV_TASK_H89#ifdef __cplusplus10extern "C" {11#endif1213/*********************14* INCLUDES15*********************/16#ifdef LV_CONF_INCLUDE_SIMPLE17#include "lv_conf.h"18#else19#include "../../lv_conf.h"20#endif2122#include <stdint.h>23#include "lv_mem.h"24#include "lv_ll.h"2526/*********************27* DEFINES28*********************/29#ifndef LV_ATTRIBUTE_TASK_HANDLER30#define LV_ATTRIBUTE_TASK_HANDLER31#endif32/**********************33* TYPEDEFS34**********************/35/**36* Possible priorities for lv_tasks37*/38#define LV_TASK_ONESHOT 039enum40{41LV_TASK_PRIO_OFF = 0,42LV_TASK_PRIO_LOWEST,43LV_TASK_PRIO_LOW,44LV_TASK_PRIO_MID,45LV_TASK_PRIO_HIGH,46LV_TASK_PRIO_HIGHEST,47LV_TASK_PRIO_NUM,48};49typedef uint8_t lv_task_prio_t;5051/**52* Descriptor of a lv_task53*/54typedef struct55{56uint32_t period;57uint32_t last_run;58void (*task) (void*);59void * param;60uint8_t prio:3;61uint8_t once:1;62} lv_task_t;6364/**********************65* GLOBAL PROTOTYPES66**********************/6768/**69* Init the lv_task module70*/71void lv_task_init(void);7273/**74* Call it periodically to handle lv_tasks.75*/76LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void);7778/**79* Create a new lv_task80* @param task a function which is the task itself81* @param period call period in ms unit82* @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped)83* @param param free parameter84* @return pointer to the new task85*/86lv_task_t* lv_task_create(void (*task) (void *), uint32_t period, lv_task_prio_t prio, void * param);8788/**89* Delete a lv_task90* @param lv_task_p pointer to task created by lv_task_p91*/92void lv_task_del(lv_task_t* lv_task_p);9394/**95* Set new priority for a lv_task96* @param lv_task_p pointer to a lv_task97* @param prio the new priority98*/99void lv_task_set_prio(lv_task_t* lv_task_p, lv_task_prio_t prio);100101/**102* Set new period for a lv_task103* @param lv_task_p pointer to a lv_task104* @param period the new period105*/106void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period);107108/**109* Make a lv_task ready. It will not wait its period.110* @param lv_task_p pointer to a lv_task.111*/112void lv_task_ready(lv_task_t* lv_task_p);113114115/**116* Delete the lv_task after one call117* @param lv_task_p pointer to a lv_task.118*/119void lv_task_once(lv_task_t * lv_task_p);120121/**122* Reset a lv_task.123* It will be called the previously set period milliseconds later.124* @param lv_task_p pointer to a lv_task.125*/126void lv_task_reset(lv_task_t* lv_task_p);127128/**129* Enable or disable the whole lv_task handling130* @param en: true: lv_task handling is running, false: lv_task handling is suspended131*/132void lv_task_enable(bool en);133134/**135* Get idle percentage136* @return the lv_task idle in percentage137*/138uint8_t lv_task_get_idle(void);139140/**********************141* MACROS142**********************/143144#ifdef __cplusplus145} /* extern "C" */146#endif147148#endif149150151