-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marcello Romani
committed
Mar 28, 2017
1 parent
6fd8abd
commit a71c054
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <ArduinoUnit.h> | ||
#include <SimpleTimer.h> | ||
|
||
// if when calling disable(), the timer callback doesn't get executed. | ||
|
||
// the timer object | ||
SimpleTimer timer; | ||
|
||
bool all_done = false; | ||
|
||
int counter = 0; | ||
|
||
void callMeOnce() { | ||
Serial.print("callMeOnce: counter="); | ||
counter++; | ||
Serial.println(counter); | ||
} | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
|
||
for (int i = 0; i < timer.MAX_TIMERS; i++) { | ||
int id = timer.setTimer(10, callMeOnce, 1); | ||
assertNotEqual(id, -1); | ||
} | ||
|
||
int id = timer.setTimer(10, callMeOnce, 1); | ||
assertEqual(id, -1); | ||
|
||
timer.disable(4); | ||
|
||
assertEqual(timer.getNumTimers(), timer.MAX_TIMERS); | ||
} | ||
|
||
void loop() { | ||
timer.run(); | ||
|
||
if (counter == (timer.MAX_TIMERS - 1)) { | ||
Serial.println("Tests finished."); | ||
while (true); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
SimpleTimer/tests/TestFillTimerTable/TestFillTimerTable.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <ArduinoUnit.h> | ||
#include <SimpleTimer.h> | ||
|
||
// the timer object | ||
SimpleTimer timer; | ||
|
||
bool all_done = false; | ||
|
||
int counter = 0; | ||
|
||
void callMeOnce() { | ||
Serial.print("callMeOnce: counter="); | ||
counter++; | ||
Serial.println(counter); | ||
} | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
|
||
for (int i = 0; i < timer.MAX_TIMERS; i++) { | ||
int id = timer.setTimer(10, callMeOnce, 1); | ||
assertNotEqual(id, -1); | ||
} | ||
|
||
int id = timer.setTimer(10, callMeOnce, 1); | ||
assertEqual(id, -1); | ||
assertEqual(timer.getNumTimers(), timer.MAX_TIMERS); | ||
} | ||
|
||
void loop() { | ||
timer.run(); | ||
|
||
if (counter == timer.MAX_TIMERS) { | ||
Serial.println("Tests finished."); | ||
while (true); | ||
} | ||
} |