#include "Scheduler.h"
bool TimedTask::canRun(uint32_t now) {
return now >= runTime;
}
TaskScheduler::TaskScheduler(Task **_tasks, uint8_t _numTasks) :
tasks(_tasks),
numTasks(_numTasks) {
}
void TaskScheduler::run() {
for(;;) {
uint32_t now = millis();
for (int t = 0; t < numTasks; t++) {
Task *tp = tasks[t];
if (tp->canRun(now)) {
tp->run(now);
break;
}
}
}
}
// vim:ft=arduino