MCPcopy Create free account
hub / github.com/SmingHub/Sming / DelegateCallbackTimer

Class DelegateCallbackTimer

Sming/Core/Timer.h:189–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 * @brief Class template adding delegate callback method support to the basic CallbackTimer template
188 */
189template <typename TimerApi> class DelegateCallbackTimer : public CallbackTimer<TimerApi>
190{
191public:
192 using typename TimerApi::TickType;
193 using typename TimerApi::TimeType;
194 using CallbackTimer<TimerApi>::initializeUs;
195 using CallbackTimer<TimerApi>::initializeMs;
196 using CallbackTimer<TimerApi>::setCallback;
197
198 /** @brief Initialise timer in microseconds, with static check
199 * @tparam microseconds Timer interval in microseconds
200 * @param delegateFunction Function to call when timer triggers
201 * @retval ExtendedCallbackTimer& Reference to timer
202 */
203 template <TimeType microseconds> DelegateCallbackTimer& IRAM_ATTR initializeUs(TimerDelegate delegateFunction)
204 {
205 setCallback(delegateFunction);
206 this->template setIntervalUs<microseconds>();
207 return *this;
208 }
209
210 /** @brief Initialise hardware timer in milliseconds, with static check
211 * @tparam milliseconds Timer interval in milliseconds
212 * @param delegateFunction Function to call when timer triggers
213 * @retval ExtendedCallbackTimer& Reference to timer
214 */
215 template <uint32_t milliseconds> DelegateCallbackTimer& IRAM_ATTR initializeMs(TimerDelegate delegateFunction)
216 {
217 setCallback(delegateFunction);
218 this->template setIntervalMs<milliseconds>();
219 return *this;
220 }
221
222 /** @brief Initialise millisecond timer
223 * @param milliseconds Duration of timer in milliseconds
224 * @param delegateFunction Function to call when timer triggers
225 * @note Delegate callback method
226 */
227 DelegateCallbackTimer& initializeMs(uint32_t milliseconds, TimerDelegate delegateFunction)
228 {
229 setCallback(delegateFunction);
230 this->setIntervalMs(milliseconds);
231 return *this;
232 }
233
234 /** @brief Initialise microsecond timer
235 * @param microseconds Duration of timer in milliseconds
236 * @param delegateFunction Function to call when timer triggers
237 * @note Delegate callback method
238 */
239 DelegateCallbackTimer& initializeUs(uint32_t microseconds, TimerDelegate delegateFunction)
240 {
241 setCallback(delegateFunction);
242 this->setIntervalUs(microseconds);
243 return *this;
244 }
245
246 /** @brief Set timer trigger function using Delegate callback method

Callers

nothing calls this directly

Calls 3

setCallbackFunction · 0.85
setIntervalMsMethod · 0.80
setIntervalUsMethod · 0.80

Tested by

no test coverage detected