Table of Contents

ItimerState()

ItimerState() returns the running state of the default or specified callback timer.

ItimerState command operation flow

bool ItimerState()
bool ItimerState(uint8_t timerNumber)

Commands

Command Arguments Return Value Operation
ItimerState() None bool Returns the running state of the default or specified callback timer.

Example

This uses the default callback timer (Timer2). The callback changes only a flag; serial output runs in loop().

void onTimer() {}
 
void setup() {
  Serial.begin(115200);
  if (!ItimerSet(1000, onTimer)) return;  // Configure the callback and interval first.
  ItimerStart();  // Start the configured callback timer.
}
 
void loop() {
  static unsigned long lastPrint = 0;
  static bool stopped = false;
  if (!stopped && millis() >= 3000) {
    ItimerStop();  // Stop the default callback timer after 5 s.
    stopped = true;
  }
  if (millis() - lastPrint >= 1000) {
    lastPrint = millis();
    const bool running = ItimerState();  // Check whether the default callback timer is running.
    Serial.println(running ? F("running") : F("stopped"));
  }
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List