7 #define TASK_SECOND 1000
8 #define TASK_MINUTE 60*TASK_SECOND
106 Task(
TaskCallback func,
unsigned long interval = 5000,
bool enabled =
false,
107 int iterations = 0,
const char* name =
"Unk",
bool runImmediately =
false);
110 Task(
VoidCallback func,
unsigned long interval = 5000,
bool enabled =
false,
111 int iterations = 0,
const char* name =
"Unk",
bool runImmediately =
false);
131 unsigned long mInterval;
139 unsigned long mIterations;
148 bool mRunImmediately;
152 unsigned long mIterationCount;
160 unsigned long mLastStartTime;
263 static String
formatMS(
unsigned long milliseconds);
This class holds the initial state of a task.
bool mEnabled
saved enable flag
unsigned long mIterations
saved run iterations count
bool mRunImmediately
saved run immediately flag
unsigned long mInterval
This member holds the original interval value.
This class runs the scheduled tasks.
const SimpleList< Task * > & getTasks() const
bool isEnabled()
return true if the scheduler is enabled
unsigned long getSize()
return the number of tasks in the run queue
void enable()
enable the scheduler
void run()
called perodically to check if a task should be scheduled
void disable()
disable the scheduler
Represents a schedulable task.
bool getRunImmediately(void) const
return the run immediately flag
unsigned long getInterval(void) const
return the task interval
void setInterval(unsigned long newInterval)
function to set a new interval
void setIterations(unsigned long newIterations)
function to set a new iterations value
void(* TaskCallback)(Task *)
void showInit()
display stuff
String getName() const
return string containing name of task
bool fRunImmediately()
return true if the run immediately flag is set
bool isLastIteration()
return true if this is the last iteration
Task(TaskCallback func, unsigned long interval=5000, bool enabled=false, int iterations=0, const char *name="Unk", bool runImmediately=false)
Constructs a new Task.
static String formatMS(unsigned long milliseconds)
return a string with a formatted time
void setName(String)
give the task a new name
bool isEnabled() const
return true if task is enabled
unsigned long getIterationCount() const
return the iteration count, that is the number of iterations that the task has been run
unsigned long getLastStartTime(void) const
return the last start time flag
void setImmediately(bool)
function to set the run immediately flag
String showTaskInfo() const
function that displays task info
bool isFirstIteration()
return true if this is the first iteration
void setCallback(const TaskCallback &callback)
Sets a new callback function for the task.
void restart()
restart the task with the original parameters, Enable is not restored
void disable()
disable the task
void enable()
enable the task