ESPectro32 Library
Library for using ESPectro32 board
 All Classes Functions Variables Enumerations Enumerator Pages
Task.h
1 /*
2  * Task.h
3  *
4  * Created on: Mar 4, 2017
5  * Author: kolban
6  */
7 
8 #ifndef COMPONENTS_CPP_UTILS_TASK_H_
9 #define COMPONENTS_CPP_UTILS_TASK_H_
10 #include <freertos/FreeRTOS.h>
11 #include <freertos/task.h>
12 #include <string>
34 class Task {
35 public:
36  Task(std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority = 5);
37  Task(BaseType_t coreId, std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority = 5);
38  virtual ~Task();
39  void setStackSize(uint16_t stackSize);
40  void setPriority(UBaseType_t priority);
41  void setTaskName(std::string &taskN);
42  void start(void *taskData=nullptr);
43  void stop();
53  virtual void runAsync(void *data) = 0; // Make run pure virtual
54  void delay(int ms);
55 
56 private:
57  xTaskHandle handle;
58  void *taskData;
59  static void runTask(void *data);
60  std::string taskName;
61  uint16_t stackSize;
62  UBaseType_t priority = 5;
63 
64  BaseType_t coreId = -1;
65 };
66 
67 #endif /* COMPONENTS_CPP_UTILS_TASK_H_ */
virtual void runAsync(void *data)=0
Body of the task to execute.
void delay(int ms)
Suspend the task for the specified milliseconds.
Definition: Task.cpp:49
Task(std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority=5)
Definition: Task.cpp:27
void start(void *taskData=nullptr)
Start an instance of the task.
Definition: Task.cpp:70
static void runTask(void *data)
Definition: Task.cpp:58
Encapsulate a runnable task.
Definition: Task.h:34