file1.cpp 715 B

12345678910111213141516171819202122232425262728293031
  1. #include <Arduino.h>
  2. #include "header.hpp"
  3. //Declare the functions we want to use before we are ready to define them
  4. void t1Callback();
  5. // Tasks
  6. Task t1(2000, 10, &t1Callback, &runner, true); //adding task to the chain on creation
  7. Task t3(5000, TASK_FOREVER, &t3Callback);
  8. void t1Callback() {
  9. Serial.print("t1: ");
  10. Serial.println(millis());
  11. if (t1.isFirstIteration()) {
  12. runner.addTask(t3);
  13. t3.enable();
  14. Serial.println("t1: enabled t3 and added to the chain");
  15. }
  16. if (t1.isLastIteration()) {
  17. t3.disable();
  18. runner.deleteTask(t3);
  19. t2.setInterval(500);
  20. Serial.println("t1: disable t3 and delete it from the chain. t2 interval set to 500");
  21. }
  22. }