File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ class DueTimer
9090
9191 double getFrequency (void ) const ;
9292 double getPeriod (void ) const ;
93+
94+ inline __attribute__ ((always_inline)) bool operator== (const DueTimer& rhs) const
95+ {return timer == rhs.timer ; };
96+ inline __attribute__ ((always_inline)) bool operator!= (const DueTimer& rhs) const
97+ {return timer != rhs.timer ; };
9398};
9499
95100// Just to call Timer.getAvailable instead of Timer::getAvailable() :
Original file line number Diff line number Diff line change @@ -68,6 +68,12 @@ Timer.getAvailable().attachInterrupt(callback1).start(10);
6868DueTimer::getAvailable ().attachInterrupt(callback2).start(10);
6969// Start timer on second available timer
7070// And so on...
71+
72+ DueTimer myTimer = Timer.getAvailable();
73+ if (myTimer != DueTimer(0))
74+ // Now we know that the timer returned is actually available
75+ // Can compare timers using == or !=
76+
7177```
7278
7379### Compatibility with Servo.h
@@ -104,7 +110,8 @@ You will need uncommend the line in `DueTimer.h` in `DueTimer` folder inside the
104110
105111### You don't need to know:
106112
107- - `unsigned short timer` - Stores the object timer id (to access Timers struct array).
113+ <<<<<<< HEAD
114+ - `int timer` - Stores the object timer id (to access Timers struct array).
108115
109116- `DueTimer(unsigned short _timer)` - Instantiate a new DueTimer object for Timer _timer (NOTE: All objects are already instantiated!).
110117
You can’t perform that action at this time.
0 commit comments