User Tools

Site Tools


en-us_commands:callback_timer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en-us_commands:callback_timer [2026/09/07 21:52] – 만듦 - 바깥 편집 127.0.0.1en-us_commands:callback_timer [2026/09/12 23:27] (current) – 바깥 편집 127.0.0.1
Line 1: Line 1:
-====== Periodic Callback Timers ======+====== Callback timers ======
  
-^ Command ^ Description ^ +Configure and control a hardware timer that calls a function periodically.
-| ''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|+
  
-<code cpp> +  * [[:en-us_commands:reference:itimerset|ItimerSet()]] — Sets the interval and callback function, or the hardware timer to use. 
-volatile bool task = false; +  * [[:en-us_commands:reference:itimerstart|ItimerStart()]] — Starts the configured callback timer. 
-void onTimer() { task = true; } +  * [[:en-us_commands:reference:itimerstop|ItimerStop()]] — Stops the default or specified callback timer. 
-void setup() { ItimerSet(100, onTimer)ItimerStart(); } +  * [[:en-us_commands:reference:itimerstopall|ItimerStopAll()]] — Stops all running callback timers. 
-void loop() { if (task{ task = false; /* Actual work */ } } +  * [[:en-us_commands:reference:itimerstate|ItimerState()]] — Returns the running state of the default or specified callback timer.
-</code>+
  
-===== Command Prototypes ===== +[[:en-us_commands:builtin|← Built-in function list]]
- +
-^ 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:builtin|← Built-in Command List]]+
  
en-us_commands/callback_timer.1788785564.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki