Assumptions:
1. There are π tasks, which are circularly linked, in task queue.
2. Task π acquires π(π) loop slots in a round for π=1,β¦,π.
Operations:
1. Task π will execute π(π) loops from π=1,β¦,π in order.
2. After task π finished, the operation 1 will be repeated.
Example:
Assume that task 1 is designed to flash led1 per 0.2 seconds; task 2 is designed to flash led2 per 2 seconds. Developers can set π(1) as 10 with 0.1 second delay in a loop and π(2) as 1 with no delay in a loop. The operation of LDMA will operate as the following table.
Example Code
#include <LDMA.h>
int led1 = 4;
int led2 = 5;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
LDMA.addTask(led1flash, 10);
LDMA.addTask(led2flash, 1);
}
void loop() {
// put your main code here, to run repeatedly:
LDMA.start();
}
void led1flash(){
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
}
void led2flash(){
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led2, LOW);
delay(1000);
}