ESPectro32 Library
Library for using ESPectro32 board
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Task Class Referenceabstract

Encapsulate a runnable task. More...

#include <Task.h>

Inheritance diagram for Task:
Animator ESPectro32_Button ESPectro32_LED_Animator WiFiManager

Public Member Functions

 Task (std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority=5)
 
 Task (BaseType_t coreId, std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority=5)
 
void setStackSize (uint16_t stackSize)
 
void setPriority (UBaseType_t priority)
 
void setTaskName (std::string &taskN)
 
void start (void *taskData=nullptr)
 Start an instance of the task. More...
 
void stop ()
 
virtual void runAsync (void *data)=0
 Body of the task to execute. More...
 
void delay (int ms)
 Suspend the task for the specified milliseconds. More...
 

Static Private Member Functions

static void runTask (void *data)
 

Private Attributes

xTaskHandle handle
 
void * taskData
 
std::string taskName
 
uint16_t stackSize
 
UBaseType_t priority = 5
 
BaseType_t coreId = -1
 

Detailed Description

Encapsulate a runnable task.

This class is designed to be subclassed with the method:

void runAsync(void *data) { ... }

For example:

class BackgroundTask : public Task {
void runAsync(void *data) {
// Do something
}
};

implemented.

Constructor & Destructor Documentation

Task::Task ( std::string  taskName = "Task",
uint16_t  stackSize = 2048,
UBaseType_t  priority = 5 
)

Create an instance of the task class.

Parameters
taskName
stackSize
taskData

Member Function Documentation

void Task::delay ( int  ms)

Suspend the task for the specified milliseconds.

Parameters
[in]msThe delay time in milliseconds.
virtual void Task::runAsync ( void *  data)
pure virtual

Body of the task to execute.

This function must be implemented in the subclass that represents the actual task to run. When a task is started by calling start(), this is the code that is executed in the newly created task.

Parameters
[in]dataThe data passed in to the newly started task.

Implemented in WiFiManager, ESPectro32_Button, ESPectro32_LED_Animator, and Animator.

void Task::runTask ( void *  pData)
staticprivate

Static class member that actually runs the target task.

The code here will run on the task thread.

void Task::start ( void *  taskData = nullptr)

Start an instance of the task.

Parameters
[in]Datato be passed into the task.
Examples:
examples-idf/ex_wifi_conn_anim.hpp.

The documentation for this class was generated from the following files: