Itmr() (Retentive Timer) accumulates the time the condition is ON and clears it with the Reset input.
bool Itmr(uint8_t timer_id, bool state, unsigned long delayTime, bool reset = false)
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
Itmr(timer_id, state, delayTime, reset) | uint8_t timer_id — Timer number. Supports 0 ~ 255bool state — Timer input stateunsigned long delayTime — Preset time in msbool reset = false — Clear the Itmr accumulated value | bool | (Retentive Timer) accumulates the time the condition is ON and clears it with the Reset input. |
This example selects MPINO-8A4R(T)-S and uses input P0 and output P32. Call the command on every pass through loop() without blocking it. ON time at P0 accumulates. P32 turns on after 3 s; OFF time does not clear the sum. P1 resets it.
const uint8_t RUN_INPUT = 0; const uint8_t RESET_INPUT = 1; const uint8_t OUTPUT_PIN = 32; void setup() {} void loop() { const bool run = digitalRead(RUN_INPUT) == HIGH; const bool reset = digitalRead(RESET_INPUT) == HIGH; const bool elapsed = Itmr(0, run, 3000, reset); // Accumulate ON time; clear it when reset is true. digitalWrite(OUTPUT_PIN, elapsed ? HIGH : LOW); }
loop() so elapsed time and OFF input are processed.timer_id between different timer operations; use a separate ID for each.reset is true, the accumulated time and done state are cleared.