arkhipenko / TaskScheduler

Cooperative multitasking for Arduino, ESPx, STM32, nRF and other microcontrollers
http://playground.arduino.cc/Code/TaskScheduler
BSD 3-Clause "New" or "Revised" License
1.26k stars 230 forks source link

Task Does not Restart If Set to limited iterations #73

Closed rupin closed 5 years ago

rupin commented 5 years ago

To verify if a task can be executed again after the limited number of iterations it has run for, I created this sketch


#include <TaskScheduler.h>

void blinkTask();

void initTaskC();
void repeaterTask();

Task blinking(100, TASK_ONCE , &blinkTask);
Task initialisation(1, 1, &initTaskC);
Task repet(1000, TASK_FOREVER, &repeaterTask);
Scheduler runner;

boolean state = false;
void initTaskC()
{
  pinMode(PC13, OUTPUT);
}
void blinkTask()
{
  state = !state;
  digitalWrite(PC13, state);

}

void repeaterTask()
{
  blinking.setIterations(1);
  blinking.restart();
}
void setup() {
  // put your setup code here, to run once:
  runner.init();
  runner.addTask(initialisation);
  runner.addTask(blinking);
  initialisation.enable();
  blinking.enable();
  repet.enable();

}

void loop() {
  // put your main code here, to run repeatedly:
  runner.execute();
}

The blinking should restart and happen again, but I do not see the task exeucting/LED blinking again.

Please advise what changes should happen in the Repet task callback function repeaterTask()

rupin commented 5 years ago

My error, had not put the repet task in the runner