en-us_commands:callback_timer
This is an old revision of the document!
Periodic Callback Timers
| Command | Description |
|---|---|
ItimerSet(intervalMs, callback) | Sets the default timer's interval and callback. |
ItimerSet(timerNo, intervalMs, callback) | Specifies the hardware timer to use. |
ItimerStart(), ItimerStart(timerNo) | Starts the configured timer. |
ItimerStop(), ItimerStop(timerNo) | Stops the timer. |
ItimerStopAll() | Stops all callback timers. |
ItimerState(), ItimerState(timerNo) | Returns the running state. |
volatile bool task = false; void onTimer() { task = true; } void setup() { ItimerSet(100, onTimer); ItimerStart(); } void loop() { if (task) { task = false; /* Actual work */ } }
Command Prototypes
| Return Type | Command Prototype |
|---|---|
bool | ItimerSet(unsigned long intervalMs, void (*callback)()) |
bool | ItimerSet(uint8_t timerNumber, unsigned long intervalMs, void (*callback)()) |
bool | ItimerStart() |
bool | ItimerStart(uint8_t timerNumber) |
void | ItimerStop() |
void | ItimerStop(uint8_t timerNumber) |
void | ItimerStopAll() |
bool | ItimerState() |
bool | ItimerState(uint8_t timerNumber) |
Callbacks run in interrupts. Change only flags in callbacks; do not use delay(), Serial, I²C, SPI or lengthy calculations. Also check whether the timer is shared with PWM.
en-us_commands/callback_timer.1788785564.txt.gz · Last modified: by 127.0.0.1
