Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_misc/lv_task.h
1476 views
1
/**
2
* @file lv_task.c
3
* An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically.
4
* A priority (5 levels + disable) can be assigned to lv_tasks.
5
*/
6
7
#ifndef LV_TASK_H
8
#define LV_TASK_H
9
10
#ifdef __cplusplus
11
extern "C" {
12
#endif
13
14
/*********************
15
* INCLUDES
16
*********************/
17
#ifdef LV_CONF_INCLUDE_SIMPLE
18
#include "lv_conf.h"
19
#else
20
#include "../../lv_conf.h"
21
#endif
22
23
#include <stdint.h>
24
#include "lv_mem.h"
25
#include "lv_ll.h"
26
27
/*********************
28
* DEFINES
29
*********************/
30
#ifndef LV_ATTRIBUTE_TASK_HANDLER
31
#define LV_ATTRIBUTE_TASK_HANDLER
32
#endif
33
/**********************
34
* TYPEDEFS
35
**********************/
36
/**
37
* Possible priorities for lv_tasks
38
*/
39
#define LV_TASK_ONESHOT 0
40
enum
41
{
42
LV_TASK_PRIO_OFF = 0,
43
LV_TASK_PRIO_LOWEST,
44
LV_TASK_PRIO_LOW,
45
LV_TASK_PRIO_MID,
46
LV_TASK_PRIO_HIGH,
47
LV_TASK_PRIO_HIGHEST,
48
LV_TASK_PRIO_NUM,
49
};
50
typedef uint8_t lv_task_prio_t;
51
52
/**
53
* Descriptor of a lv_task
54
*/
55
typedef struct
56
{
57
uint32_t period;
58
uint32_t last_run;
59
void (*task) (void*);
60
void * param;
61
uint8_t prio:3;
62
uint8_t once:1;
63
} lv_task_t;
64
65
/**********************
66
* GLOBAL PROTOTYPES
67
**********************/
68
69
/**
70
* Init the lv_task module
71
*/
72
void lv_task_init(void);
73
74
/**
75
* Call it periodically to handle lv_tasks.
76
*/
77
LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void);
78
79
/**
80
* Create a new lv_task
81
* @param task a function which is the task itself
82
* @param period call period in ms unit
83
* @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped)
84
* @param param free parameter
85
* @return pointer to the new task
86
*/
87
lv_task_t* lv_task_create(void (*task) (void *), uint32_t period, lv_task_prio_t prio, void * param);
88
89
/**
90
* Delete a lv_task
91
* @param lv_task_p pointer to task created by lv_task_p
92
*/
93
void lv_task_del(lv_task_t* lv_task_p);
94
95
/**
96
* Set new priority for a lv_task
97
* @param lv_task_p pointer to a lv_task
98
* @param prio the new priority
99
*/
100
void lv_task_set_prio(lv_task_t* lv_task_p, lv_task_prio_t prio);
101
102
/**
103
* Set new period for a lv_task
104
* @param lv_task_p pointer to a lv_task
105
* @param period the new period
106
*/
107
void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period);
108
109
/**
110
* Make a lv_task ready. It will not wait its period.
111
* @param lv_task_p pointer to a lv_task.
112
*/
113
void lv_task_ready(lv_task_t* lv_task_p);
114
115
116
/**
117
* Delete the lv_task after one call
118
* @param lv_task_p pointer to a lv_task.
119
*/
120
void lv_task_once(lv_task_t * lv_task_p);
121
122
/**
123
* Reset a lv_task.
124
* It will be called the previously set period milliseconds later.
125
* @param lv_task_p pointer to a lv_task.
126
*/
127
void lv_task_reset(lv_task_t* lv_task_p);
128
129
/**
130
* Enable or disable the whole lv_task handling
131
* @param en: true: lv_task handling is running, false: lv_task handling is suspended
132
*/
133
void lv_task_enable(bool en);
134
135
/**
136
* Get idle percentage
137
* @return the lv_task idle in percentage
138
*/
139
uint8_t lv_task_get_idle(void);
140
141
/**********************
142
* MACROS
143
**********************/
144
145
#ifdef __cplusplus
146
} /* extern "C" */
147
#endif
148
149
#endif
150
151