-
Notifications
You must be signed in to change notification settings - Fork 0
Timer
Alex Krieg edited this page Nov 4, 2020
·
11 revisions
- Timer(bool Micros = TMillis);
- ~Timer();
- bool update();
- bool start(unsigned long timeOfDelayIn = 0);
- unsigned long stop();
- void onFinished(void (*p_func)());
- unsigned long runtime();
- void autoRestart(bool autoRestart);
- bool isRunning();
- 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
Timer myTimer;
Timer myTimer(TMillis);
Timer myTimer(TMicros);
- Destructor
delete p_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
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
myTimer.start();
myTimer.start(100);
if(myTimer.start(100))
{
//timer finished
}
- Stops the timer
- Returns the current runtime
myTimer.stop();
You do not know how events work?
Look over here
- Is executed when the timer is finished.
- NO values accepted.
- NO return values.
- Returns the current runtime.
- Value in ms when constructor initiallized with TMillis
- Value in us when constructor initiallized with TMicros
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.
myTimer.autoRestart(true);
- Returns true if the timer is running.
- Returns false if the timer is not running.
bool state = myTimer.isRunning();
if(myTimer.isRunning())
{
//Do something
}
Wiki
Arduino libraries