@@ -24,9 +24,10 @@ static char tag[] = "Task";
24
24
* @param [in] stackSize The size of the stack.
25
25
* @return N/A.
26
26
*/
27
- Task::Task (std::string taskName, uint16_t stackSize) {
27
+ Task::Task (std::string taskName, uint16_t stackSize, uint8_t priority ) {
28
28
m_taskName = taskName;
29
29
m_stackSize = stackSize;
30
+ m_priority = priority;
30
31
m_taskData = nullptr ;
31
32
m_handle = nullptr ;
32
33
} // Task
@@ -55,8 +56,8 @@ void Task::runTask(void* pTaskInstance) {
55
56
Task* pTask = (Task*)pTaskInstance;
56
57
ESP_LOGD (tag, " >> runTask: taskName=%s" , pTask->m_taskName .c_str ());
57
58
pTask->run (pTask->m_taskData );
58
- pTask->stop ();
59
59
ESP_LOGD (tag, " << runTask: taskName=%s" , pTask->m_taskName .c_str ());
60
+ pTask->stop ();
60
61
} // runTask
61
62
62
63
/* *
@@ -70,7 +71,7 @@ void Task::start(void* taskData) {
70
71
ESP_LOGW (tag, " Task::start - There might be a task already running!" );
71
72
}
72
73
m_taskData = taskData;
73
- ::xTaskCreate (&runTask, m_taskName.c_str(), m_stackSize, this, 5 , &m_handle);
74
+ ::xTaskCreate (&runTask, m_taskName.c_str(), m_stackSize, this, m_priority , &m_handle);
74
75
} // start
75
76
76
77
@@ -97,3 +98,23 @@ void Task::stop() {
97
98
void Task::setStackSize (uint16_t stackSize) {
98
99
m_stackSize = stackSize;
99
100
} // setStackSize
101
+
102
+ /* *
103
+ * @brief Set the priority of the task.
104
+ *
105
+ * @param [in] priority The priority for the task.
106
+ * @return N/A.
107
+ */
108
+ void Task::setPriority (uint8_t priority) {
109
+ m_priority = priority;
110
+ } // setPriority
111
+
112
+ /* *
113
+ * @brief Set the name of the task.
114
+ *
115
+ * @param [in] name The name for the task.
116
+ * @return N/A.
117
+ */
118
+ void Task::setName (std::string name) {
119
+ m_taskName = name;
120
+ } // setName
0 commit comments