diff options
Diffstat (limited to 'Arduino/Queue.h')
| -rw-r--r-- | Arduino/Queue.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Arduino/Queue.h b/Arduino/Queue.h new file mode 100644 index 0000000..d23afb3 --- /dev/null +++ b/Arduino/Queue.h @@ -0,0 +1,39 @@ +#ifndef QUEUE_H +#define QUEUE_H + +#include "Arduino.h" + +typedef int (*queuedFunction)(unsigned long); + +#define QueueScheduleSize 11 + +struct queueItem { + queuedFunction fPtr; + unsigned long next; + unsigned long recur; + char itemName[8]; +}; + +class Queue +{ +private: + unsigned int _queueStart; + unsigned int _queueEnd; + unsigned int _itemsInQueue; + queueItem _schedule[QueueScheduleSize]; + + int _queueGetTop(queueItem &item); + int _addToQueue(queueItem item); + +public: + Queue(); + + int scheduleFunction(queuedFunction func, const char * id, unsigned long initialRun, unsigned long recur); + int scheduleRemoveFunction(const char * id); + int scheduleChangeFunction(const char * id, unsigned long nextRunTime, unsigned long newRecur); + + int Run(unsigned long now); + /* data */ +}; + +#endif
\ No newline at end of file |
