8 #ifndef COMPONENTS_CPP_UTILS_TASK_H_
9 #define COMPONENTS_CPP_UTILS_TASK_H_
10 #include <freertos/FreeRTOS.h>
11 #include <freertos/task.h>
36 Task(std::string taskName =
"Task", uint16_t stackSize = 10000, uint8_t priority = 5);
41 void setCore(BaseType_t coreId);
42 void start(
void* taskData =
nullptr);
53 virtual void run(
void* data) = 0;
54 static void delay(
int ms);
59 static void runTask(
void* data);
60 std::string m_taskName;
static void delay(int ms)
Suspend the task for the specified milliseconds.
Definition: Task.cpp:46
void setStackSize(uint16_t stackSize)
Set the stack size of the task.
Definition: Task.cpp:97
void setName(std::string name)
Set the name of the task.
Definition: Task.cpp:117
void setPriority(uint8_t priority)
Set the priority of the task.
Definition: Task.cpp:107
void setCore(BaseType_t coreId)
Set the core number the task has to be executed on. If the core number is not set, tskNO_AFFINITY will be used.
Definition: Task.cpp:128
void stop()
Stop the task.
Definition: Task.cpp:84
virtual void run(void *data)=0
Body of the task to execute.
Task(std::string taskName="Task", uint16_t stackSize=10000, uint8_t priority=5)
Create an instance of the task class.
Definition: Task.cpp:27
void start(void *taskData=nullptr)
Start an instance of the task.
Definition: Task.cpp:70
Encapsulate a runnable task.
Definition: Task.h:34