Task scheduler library  1.3
Arduino library for simply executing tasks in parallel
Tasks.h
Go to the documentation of this file.
1 
32 /*-----------------------------------------------------------------------------
33  MODULE DEFINITION FOR MULTIPLE INCLUSION
34 -----------------------------------------------------------------------------*/
35 #ifndef TASKS_H
36 #define TASKS_H
37 
38 
39 /*-----------------------------------------------------------------------------
40  INCLUDE FILES
41 -----------------------------------------------------------------------------*/
42 #include <Arduino.h>
43 
44 
45 /*-----------------------------------------------------------------------------
46  COMPILER OPTIONS
47 -----------------------------------------------------------------------------*/
48 #pragma GCC optimize ("O2")
49 
50 
51 /*-----------------------------------------------------------------------------
52  GLOBAL MACROS
53 -----------------------------------------------------------------------------*/
54 #define MAX_TASK_CNT 8
55 //#define PTR_NON_STATIC_METHOD(instance, method) [instance](){instance.method();}
56 
57 
58 /*-----------------------------------------------------------------------------
59  GLOBAL CLASS
60 -----------------------------------------------------------------------------*/
61 
62 typedef void (*Task)(void);
63 
64 
65 
73 void Tasks_Init(void);
74 
75 
76 
84 void Tasks_Clear(void);
85 
86 
87 
108 bool Tasks_Add(Task func, int16_t period, int16_t delay = 0);
109 
110 
111 
123 bool Tasks_Remove(Task func);
124 
125 
126 
145 bool Tasks_Delay(Task func, int16_t delay);
146 
147 
148 
164 bool Tasks_SetState(Task func, bool state);
165 
166 
167 
180 inline bool Tasks_Start_Task(Task func)
181  {
182  return Tasks_SetState(func, true);
183  }
184 
185 
186 
199 inline bool Tasks_Pause_Task(Task func)
200  {
201  return Tasks_SetState(func, false);
202  }
203 
204 
205 
213 void Tasks_Start(void);
214 
215 
216 
224 void Tasks_Pause(void);
225 
226 
227 #endif //TASKS_H
void(* Task)(void)
Example prototype for a function than can be executed as a task.
Definition: Tasks.h:62
void Tasks_Init(void)
Initialize timer and reset the tasks scheduler at first call.
Definition: Tasks.cpp:130
bool Tasks_SetState(Task func, bool state)
Enable or disable the execution of a task.
Definition: Tasks.cpp:365
bool Tasks_Add(Task func, int16_t period, int16_t delay=0)
Add a task to the task scheduler.
Definition: Tasks.cpp:173
bool Tasks_Start_Task(Task func)
Activate a task in the scheduler.
Definition: Tasks.h:180
bool Tasks_Delay(Task func, int16_t delay)
Delay execution of a task.
Definition: Tasks.cpp:314
bool Tasks_Remove(Task func)
Remove a task from the task scheduler.
Definition: Tasks.cpp:258
void Tasks_Pause(void)
Pause the task scheduler.
Definition: Tasks.cpp:430
void Tasks_Clear(void)
Reset the tasks schedulder.
Definition: Tasks.cpp:144
bool Tasks_Pause_Task(Task func)
Deactivate a task in the scheduler.
Definition: Tasks.h:199
void Tasks_Start(void)
Start the task scheduler.
Definition: Tasks.cpp:404