Simple task manager which uses a Ticker

Committer:
Phlaphead
Date:
Fri Jan 14 19:51:13 2011 +0000
Revision:
0:e381c3adaa04
Child:
1:e95b703c6ad7

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Phlaphead 0:e381c3adaa04 1 #ifndef Task_h
Phlaphead 0:e381c3adaa04 2 #define Task_h
Phlaphead 0:e381c3adaa04 3
Phlaphead 0:e381c3adaa04 4 #include "mbed.h"
Phlaphead 0:e381c3adaa04 5
Phlaphead 0:e381c3adaa04 6 #define DEFAULT_INTERVAL 1000 //1ms
Phlaphead 0:e381c3adaa04 7
Phlaphead 0:e381c3adaa04 8 class Task
Phlaphead 0:e381c3adaa04 9 {
Phlaphead 0:e381c3adaa04 10
Phlaphead 0:e381c3adaa04 11 public:
Phlaphead 0:e381c3adaa04 12
Phlaphead 0:e381c3adaa04 13 Task();
Phlaphead 0:e381c3adaa04 14 Task(int _interval);
Phlaphead 0:e381c3adaa04 15 void start();
Phlaphead 0:e381c3adaa04 16 virtual void tick() = 0;
Phlaphead 0:e381c3adaa04 17
Phlaphead 0:e381c3adaa04 18
Phlaphead 0:e381c3adaa04 19 protected:
Phlaphead 0:e381c3adaa04 20
Phlaphead 0:e381c3adaa04 21 void setInterval(int _interval) { interval = _interval; }
Phlaphead 0:e381c3adaa04 22
Phlaphead 0:e381c3adaa04 23
Phlaphead 0:e381c3adaa04 24 private:
Phlaphead 0:e381c3adaa04 25
Phlaphead 0:e381c3adaa04 26 Ticker ticker;
Phlaphead 0:e381c3adaa04 27 int interval;
Phlaphead 0:e381c3adaa04 28
Phlaphead 0:e381c3adaa04 29 void preTick();
Phlaphead 0:e381c3adaa04 30
Phlaphead 0:e381c3adaa04 31 };
Phlaphead 0:e381c3adaa04 32
Phlaphead 0:e381c3adaa04 33 #endif