-
Notifications
You must be signed in to change notification settings - Fork 0
Timer
KROIA edited this page May 21, 2018
·
11 revisions
- Constructor of the Timer
- Parameters are TMillis or TMicros
- TMillis Defines the timer as an millis Timer
- TMicros Defines the timer as an micros Timer
- normal
Timer myTimer;
Timer myTimer(TMillis);
Timer myTimer(TMicros);
- pointer
Timer *myTimer = new Timer;
Timer *myTimer = new Timer(TMillis);
Timer *myTimer = new Timer(TMicros);
- Destructor
- normal
delete &myTimer;
- pointer
delete myTimer;
- checks if the time is over
- If Yes
-
- The timer resets itself
-
- If there is an defined function to call when the time is over it will by executed.
-
- It returns true
- If No
-
- It returns false
- normal
myTimer.update();
- pointer
myTimer->update();
- Starts the timer with the time timeOfDelayIn
- runs update() internally
- returns the status of update()
- The time can by changed when the timer is still running
- If timeOfDelayIn is 0, the Timer will never end untill stop() is called
- normal
myTimer.start();
myTimer.start(100);
if(myTimer.start(100)) { //timer finished }
- pointer
myTimer->start();
myTimer->start(100);
if(myTimer->start(100)) { //timer finished }
- Stops the timer
- Returns the current runtime
-
normal
myTimer.stop()
-
pointer
myTimer->stop()
- Defines a function, which is called every time when the timer is finished.
- For this feature you need to run the update() function cyclical.
void myFunction() { //Do something }
- normal
myTimer.onFinished(myFunction);
- pointer
myTimer->onFinished(myFunction);
- Returns the current runtime.
- Value in ms when constructor initiallized with TMillis
- Value in us when constructor initiallized with TMicros
- normal
unsigned int runtime = myTimer.runtime();
- pointer
unsigned int runtime = myTimer->runtime();
- autoRestart(true) lets the timer automaticly restart when the timer finishes.
- autoRestart(false) lets the timer not automaticly restart when the timer finishes. This is standard.
- normal
myTimer.autoRestart(true);
- pointer
myTimer->autoRestart(true);
- Returns true if the timer is running.
- Returns false if the timer is not running.
- normal
bool state = myTimer.isRunning();
if(myTimer.isRunning()) { //Do something }
- pointer
bool state = myTimer->isRunning();
if(myTimer->isRunning()) { //Do something }
Wiki
Arduino libraries