en-us_commands:reference:itmr
This is an old revision of the document!
Table of Contents
Itmr()
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)
Commands
| 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. |
Example
bool Iton(uint8_t timer_id, bool state, unsigned long delayTime); bool Itof(uint8_t timer_id, bool state, unsigned long delayTime); bool Itpl(uint8_t timer_id, bool state, unsigned long delayTime); bool Itmon(uint8_t timer_id, bool state, unsigned long delayTime); bool Itmr(uint8_t timer_id, bool state, unsigned long delayTime, bool reset = false); unsigned long IgetTime(uint8_t timer_id); bool IgetState(uint8_t timer_id);
Precautions
- Timer interrupt callbacks run inside an ISR. For safety, change only flags in the callback and perform actual control processing in
loop(). - Do not use slow or interrupt-dependent code such as
delay(),Serial, I2C or SPI in callbacks. - Normally, call
ImodbusRTU()repeatedly inloop(). Call it from a timer interrupt with a sufficient interval only when longdelay()calls or debug output slow downloop(). - Do not use the default
ItimerSet()together withtone()using Timer2 oranalogWrite()on Timer2 PWM pins. - Explicitly using Timer1, Timer3, Timer4 or Timer5 may conflict with PWM, analog output or high-speed counter functions using that timer.
- Configure only one
Itimercallback per hardware timer. - Defining an ISR for the same timer directly in the sketch may conflict with
Itimeroperation. ItimerStopAll()stops only hardware interrupt timers. It does not reset PLC-style timer states such asIton,ItoforItmr.
en-us_commands/reference/itmr.1788785568.txt.gz · Last modified: by 127.0.0.1
