#include "Scheduler2.h"
int led1 = 13;
int led2 = 12;
Scheduler scheduler;
int count = 0;
void onMaxSpeedEvents();
void onHalfSecondEvents();
void onSecondEvents();
void epochScheduler();
void epoch10sec();
void epoch20sec();
void periodicBlink(int led) {
Serial.print("printing periodic blink led ");
Serial.println(led);
digitalWrite(led, !digitalRead(led));
}
void epoch10secToggle(){
Serial.print("Toggle: ");
if(scheduler.toggleEvent(1,1000)==false)
digitalWrite(led2, LOW);
}
void onHalfSecondEvents(){
periodicBlink(led1);
}
void onSecondEvents(){
periodicBlink(led2);
}
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(115200);
//scheduler.addEvent(onMaxSpeedEvents, 1, 0);
scheduler.addPeriodicEvent(onHalfSecondEvents, 1, 500);
scheduler.addPeriodicEvent(epoch10secToggle, 1, 10000);
scheduler.addPeriodicEvent(onSecondEvents, 1, 1000);
Serial.println(F("Scheduler init"));
Serial.print(F("Time base: "));
Serial.println(scheduler.getTimebase());
}
void loop() {
scheduler.scheduleAll();
delay(10);
}