Skip to content

aramperez/ElapsedTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElapsedTimer

A simple class for an elapsed timer, primarily for use with Arduinos.

Description

ElapsedTimer(dur, autoRestart)

Creates a timer object (constructor). Creating a timer does NOT start it, you must call the start method.

Arguments

  • unsigned long dur: duration in milliseconds. Default is 1000 milliseconds.
  • bool autoRestart: if true, the timer will auto-restart when the method timedOut is called and the result is true. Default is false.

void start(dur)

Starts (activates) the timer with an optional duration.

Arguments

  • unsigned long dur: duration in milliseconds. If none is provided (e.g., duration = 0), the previous duration is used.

void stop()

Stops (deactivates) the timer.

bool isActive()

Returns the current state of the timer, true = active, false = inactive.

bool timedOut()

Returns whether the timer has timed out (true) or not (false). When a timer times out, if the timer object was created with autoRestart set to true, then the timer is automatically restarted, otherwise the timer is stopped (deactivated).

unsigned long remainingMs()

Returns the number of milliseconds before the timer times out.

About

A simple class for an elapsed timer, primarily for use with Arduinos.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages