-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
95 lines (77 loc) · 1.81 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
The source code of each library should be placed in an own separate directory
("lib/esp32-tasker/[here are source files]").
Structure of the following library `esp32-tasker`:
```
|--lib
| |
| |--esp32-tasker
| | |--docs
| | |--examples
| | |- main.ino
| | |--src
| | |- esp32-tasker.cpp
| | |- esp32-tasker.h
| | |- library.json
| | |- README --> THIS FILE
| | |- README.md
| | |- LICENSE
| | |- .gitignore
| | |- library.properties
|
|- platformio.ini
|--src
|- main.c
```
and a contents of `src/main.c`:
```
#include <Arduino.h>
#include "esp32-tasker.h"
void task1() {
log_i("task1!!!");
deleteTask();
}
[[noreturn]] void task2() {
log_i("task2!!!");
for (;;) {
log_i("task2 loop!");
delay(100);
}
}
void task3() {
log_i("periodic task3");
}
[[noreturn]] void task4() {
log_i("task4");
for (;;);
}
void task5() {
log_i("periodic task5!!!");
deleteTask();
}
void setup() {
// Run single shot inline task on any core
createTask([]() {
log_i("inline single shot task!");
deleteTask();
});
// Run continues inline task on any core
createTask([]() {
log_i("inline continues task!");
for(;;);
});
// Run single shot task callback on any core
createTask(task1);
// Run continues task callback on core id 0 (core #1)
createTaskCore0(task2);
// Run task3 every 100 ms on core id 1 (core #2)
createTaskCore1(task3, 100);
// Run continues named task callback with named task on core id 0 (core #1)
createTaskCore0(task4, "task 4");
// Run periodic named task every 500 ms on core id 0 (core #1)
createTaskCore0(task5, "task 5", 500);
}
void loop() {
// Delete built-in task in order to launch next ones on the same priority
deleteTask();
}
```