// The LED_BUILTIN exhibits a continuous blinking pattern
// with a frequency of 500ms in the ON state followed by 500ms in the OFF state.
#include "TCone.h"
// Define the task periodic in milliseconds
#define TASK_PERIOD 1
// Define the number of tasks
#define TASK_SIZE 1
// TaskMember declaration
// Single:
// taskMember = {duration, manualReset, enable};
// Array:
// taskMembers[N] = {
// {duration_0, manualReset_0, enable_0},
// {duration_1, manualReset_1, enable_1},
// {..., ..., ...}
// {duration_N-1, manualReset_N-1, enable_N-1},
// };
TaskMember taskMember = {500};
// Task declaration
// Para:
// uint16_t period - in milliseconds
// TaskMember *tasks - Pointer of TaskMember
// uint16_t size - Number of Tasks
// It is mandatory to name the TCone declaration as "Tasks". No other name should be used.
TCone Tasks(TASK_PERIOD, &taskMember, TASK_SIZE);
void setup() {
// Set the pin mode of "LED_BUILTIN" as an output.
pinMode(LED_BUILTIN, OUTPUT);
// Manual reset when task completed.
Tasks.manualReset(true);
// It is imperative to utilize the begin() function to internally configure Timer0
// and commence its operation.
Tasks.begin();
}
void loop() {
// If the task is completed,
if (taskMember.completed) {
// Toggle the state.
taskMember.state = !taskMember.state;
//Manual Reset: Reset the elapsed time to zero and mark the completed flag as false.
Tasks.reset();
}
// Write the state value to LED_BUILTIN.
digitalWrite(LED_BUILTIN, taskMember.state);
}