Skip to content

Commit 08da1f0

Browse files
committed
Initial import
0 parents  commit 08da1f0

File tree

9 files changed

+632
-0
lines changed

9 files changed

+632
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.pio
2+
.idea
3+
cmake-build-*
4+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Konstantin M.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README

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

README.md

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

examples/main.ino

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include <Arduino.h>
2+
#include "esp32-tasker.h"
3+
4+
void task1() {
5+
log_i("task1!!!");
6+
deleteTask();
7+
}
8+
9+
[[noreturn]] void task2() {
10+
log_i("task2!!!");
11+
for (;;) {
12+
log_i("task2 loop!");
13+
delay(100);
14+
}
15+
}
16+
17+
void task3() {
18+
log_i("periodic task3");
19+
}
20+
21+
[[noreturn]] void task4() {
22+
log_i("task4");
23+
for (;;);
24+
}
25+
26+
void task5() {
27+
log_i("periodic task5!!!");
28+
deleteTask();
29+
}
30+
31+
void setup() {
32+
// Run single shot inline task on any core
33+
createTask([]() {
34+
log_i("inline single shot task!");
35+
deleteTask();
36+
});
37+
38+
// Run continues inline task on any core
39+
createTask([]() {
40+
log_i("inline continues task!");
41+
for(;;);
42+
});
43+
44+
// Run single shot task callback on any core
45+
createTask(task1);
46+
47+
// Run continues task callback on core id 0 (core #1)
48+
createTaskCore0(task2);
49+
50+
// Run task3 every 100 ms on core id 1 (core #2)
51+
createTaskCore1(task3, 100);
52+
53+
// Run continues named task callback with named task on core id 0 (core #1)
54+
createTaskCore0(task4, "task 4");
55+
56+
// Run periodic named task every 500 ms on core id 0 (core #1)
57+
createTaskCore0(task5, "task 5", 500);
58+
}
59+
60+
void loop() {
61+
// Delete built-in task in order to launch next ones on the same priority
62+
deleteTask();
63+
}

keywords.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#######################################
2+
# Syntax Coloring Map for esp32-tasker
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
taskCb KEYWORD1
10+
taskCb KEYWORD1
11+
BaseType_t KEYWORD1
12+
TaskHandle_t KEYWORD1
13+
14+
#######################################
15+
# Methods and Functions (KEYWORD2)
16+
#######################################
17+
18+
createTask KEYWORD2
19+
createTaskCore0 KEYWORD2
20+
createTaskCore1 KEYWORD2
21+
deleteTask KEYWORD2
22+
23+
#######################################
24+
# Constants (LITERAL1)
25+
#######################################
26+
27+
MINIMUM_STACK LITERAL1
28+
LIGHT_STACK LITERAL1
29+
MEDIUM_STACK LITERAL1
30+
HEAVY_STACK LITERAL1
31+
PRIO_IDLE LITERAL1
32+
PRIO_1 LITERAL1
33+
PRIO_2 LITERAL1
34+
PRIO_3 LITERAL1
35+
PRIO_4 LITERAL1
36+
PRIO_5 LITERAL1

library.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=esp32-tasker
2+
version=0.0.4
3+
author=Konstantin M. <[email protected]>
4+
maintainer=Konstantin M. <[email protected]>
5+
sentence=Easy ESP32 task management using FreeRTOS API
6+
paragraph=Easy ESP32 task management using FreeRTOS API
7+
category=task-manager
8+
url=https://github.com/ezdev128/esp32-tasker
9+
architectures=esp32
10+
includes=esp32-tasker.h

0 commit comments

Comments
 (0)