Skip to content

Latest commit

 

History

History
117 lines (77 loc) · 1.77 KB

timer.md

File metadata and controls

117 lines (77 loc) · 1.77 KB

This document was generated from file timer.h at 6. 4. 2023 22:35:49

Timer

class Timer /* line 30 */

Simple and easy to use timer library

Description

Example

Hallo World example (blinking LED)

#include <Timer.h>

Timer timer(1000);

void setup() {
  pinMode(LED, OUTPUT);
}

void loop() {
  if (timer.elapsed()) {
    digitalWrite(LED, ! digitalRead(LED)); // toggle LED
  }
}

Type definition

typedef unsigned long time_ms

typedef unsigned long time_ms /* line 41 */

Type of time in miliseconds

Constructors

💡 Timer(time_ms interval, bool autostop = false)

Timer(time_ms interval, bool autostop = false) /* line 60 */

Create new timer instance with defined interval

Parameters

  • interval - interval time (in miliseconds)
  • autostop - indicate if timer should stop after each elapsed

Example

Timer mytimer(5000); // New timer for 5 sec.

Methods

Ⓜ️ bool elapsed()

bool elapsed() /* line 74 */

Check if set interval elapsed

Return

Return true if interval epalsed othervise false

Ⓜ️ void restart()

void restart() /* line 79 */

Restart timer form begining

Ⓜ️ void restart(time_ms interval)

void restart(time_ms interval) /* line 88 */

Restart timer form begining and change interval

Parametry:

  • interval - interval time (in miliseconds)

Attributes

🔧 time_ms interval

time_ms interval /* line 97 */

Timers interval (in miliseconds)