Skip to content

Commit

Permalink
Merge branch 'pr/33'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanseidel committed Apr 30, 2018
2 parents c3d688e + e826474 commit 1ac2e5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions DueTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class DueTimer

double getFrequency(void) const;
double getPeriod(void) const;

inline __attribute__((always_inline)) bool operator== (const DueTimer& rhs) const
{return timer == rhs.timer; };
inline __attribute__((always_inline)) bool operator!= (const DueTimer& rhs) const
{return timer != rhs.timer; };
};

// Just to call Timer.getAvailable instead of Timer::getAvailable() :
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ Timer.getAvailable().attachInterrupt(callback1).start(10);
DueTimer::getAvailable().attachInterrupt(callback2).start(10);
// Start timer on second available timer
// And so on...

DueTimer myTimer = Timer.getAvailable();
if (myTimer != DueTimer(0))
// Now we know that the timer returned is actually available
// Can compare timers using == or !=

```
### Compatibility with Servo.h
Expand Down Expand Up @@ -104,7 +110,8 @@ You will need uncommend the line in `DueTimer.h` in `DueTimer` folder inside the
### You don't need to know:
- `unsigned short timer` - Stores the object timer id (to access Timers struct array).
<<<<<<< HEAD
- `int timer` - Stores the object timer id (to access Timers struct array).
- `DueTimer(unsigned short _timer)` - Instantiate a new DueTimer object for Timer _timer (NOTE: All objects are already instantiated!).
Expand Down

0 comments on commit 1ac2e5d

Please sign in to comment.