diff options
| author | Brad Luyster <BradLuyster+git@gmail.com> | 2012-05-11 19:21:30 -0400 |
|---|---|---|
| committer | Brad Luyster <BradLuyster+git@gmail.com> | 2012-05-11 19:21:30 -0400 |
| commit | 9c96fa015ee8c80e9ab48154c4ecc4fbcfe13087 (patch) | |
| tree | d3129f21ebe1a02ab0e3722edb01e37e8d4b2158 /Arduino/Queue.h | |
Initial Commit
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 |
