Skip to content
KROIA edited this page May 21, 2018 · 11 revisions

Timer(bool Micros = TMillis);

Description

  • 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

Syntax

  • normal
  • Timer myTimer;
  • Timer myTimer(TMillis);
  • Timer myTimer(TMicros);
  • pointer
  • Timer *myTimer = new Timer;
  • Timer *myTimer = new Timer(TMillis);
  • Timer *myTimer = new Timer(TMicros);

~Timer();

Description

  • Destructor

Syntax

  • normal
  • delete &myTimer;
  • pointer
  • delete myTimer;

bool update();

Description

  • 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

Syntax

  • normal
  • myTimer.update();
  • pointer
  • myTimer->update();

bool start(unsigned long timeOfDelayIn = 0);

Description

  • 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

Syntax

  • normal
  • myTimer.start();
  • myTimer.start(100);
  • if(myTimer.start(100)) { //timer finished }
  • pointer
  • myTimer->start();
  • myTimer->start(100);
  • if(myTimer->start(100)) { //timer finished }

unsigned long stop();

Description

  • Stops the timer
  • Returns the current runtime

Syntax

  • normal myTimer.stop()
  • pointer myTimer->stop()

void onFinished(void (*p_func)());

Description

  • Defines a function, which is called every time when the timer is finished.
  • For this feature you need to run the update() function cyclical.

Syntax

  • void myFunction() { //Do something }
  • normal
  • myTimer.onFinished(myFunction);
  • pointer
  • myTimer->onFinished(myFunction);

unsigned long runtime();

Description

  • Returns the current runtime.
  • Value in ms when constructor initiallized with TMillis
  • Value in us when constructor initiallized with TMicros

Syntax

  • normal
  • unsigned int runtime = myTimer.runtime();
  • pointer
  • unsigned int runtime = myTimer->runtime();

void autoRestart(bool autoRestart);

Description

  • 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.

Syntax

  • normal
  • myTimer.autoRestart(true);
  • pointer
  • myTimer->autoRestart(true);

bool isRunning();

Description

  • Returns true if the timer is running.
  • Returns false if the timer is not running.

Syntax

  • normal
  • bool state = myTimer.isRunning();
  • if(myTimer.isRunning()) { //Do something }
  • pointer
  • bool state = myTimer->isRunning();
  • if(myTimer->isRunning()) { //Do something }
Clone this wiki locally