Skip to content

Commit 1ac2e5d

Browse files
committed
Merge branch 'pr/33'
2 parents c3d688e + e826474 commit 1ac2e5d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

DueTimer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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() :

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ Timer.getAvailable().attachInterrupt(callback1).start(10);
6868
DueTimer::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

0 commit comments

Comments
 (0)