#include <Arduino_FreeRTOS.h>
//Calling the Task Handle
TaskHandle_t config_handle;
void setup() {
Serial.begin(9600);
xTaskCreate(task1, "print task1", 128, NULL, 2, NULL);
xTaskCreate(task2, "calling the task once", 128, NULL, 3, &config_handle);
}
void loop() {
//this part of the code is empty
}
void task1(void *pvParameters){
//the use of vTaskDelayUntil
//you must call the TickTime first to enable to work its functionalities
//TickType_t reftime;
//record current time as it ticks
//reftime = xTaskGetTickCount();
//How to delete another task from another task which is via vTaskDelete and
//calling the handle
vTaskDelete(config_handle);
while(1){
Serial.println("Hello from task1!");
vTaskDelay( 1000 / portTICK_PERIOD_MS);
// /*&reftime*/
// ^this is use to call it from TaskGetTickCount();
// ^make sure to add delay if you're going to use TaskGetTickCount();
}
}
void task2(void *pvParameters){
while(1){
//Serial.println("Hello from task2!");
//Serial.println("this task2 will be deleted");
//vTaskDelete(NULL); //the task itself will be deleted
//another way of deleting a task via Task Handle which is calling it
Serial.println("Configure LCD. . . . .");
vTaskDelay(1000/portTICK_PERIOD_MS);
}
}