ESP-LiveControl  1.99.1
HTTP server, AJAX API backend and Vue.js web application implementing self-contained, zero-install WiFi remote control of hardware modules attached to the Espressif ESP32 SoC
Public Types | Public Member Functions | Protected Attributes | List of all members
MultiTimerNonStatic< TClass > Class Template Reference

Same as MultiTimer but allows a pointer to a non-static member function as a callback. More...

#include <multi_timer.hpp>

Inheritance diagram for MultiTimerNonStatic< TClass >:
Inheritance graph
[legend]
Collaboration diagram for MultiTimerNonStatic< TClass >:
Collaboration graph
[legend]

Public Types

using mem_func_ptr_t = void(TClass::*)()
 
using mem_func_ptr_with_count_t = void(TClass::*)(uint32_t)
 
- Public Types inherited from MultiTimer
template<class T >
using type_identity_t = typename type_identity< T >::type
 
using callback_with_arg_and_count_t = void(*)(void *, uint32_t)
 

Public Member Functions

esp_err_t attach_mem_func_ptr_ms (uint32_t milliseconds, uint32_t total_repeat_count, mem_func_ptr_t mem_func_ptr, TClass *inst, bool first_tick_nodelay=false)
 Same as attach_static_ms() but taking a pointer to a non-static member function as a callback, see class description. More...
 
esp_err_t attach_mem_func_ptr_ms (uint32_t milliseconds, uint32_t total_repeat_count, mem_func_ptr_with_count_t mem_func_ptr, TClass *inst, bool first_tick_nodelay=false)
 
- Public Member Functions inherited from MultiTimer
template<typename TArg >
esp_err_t attach_static_ms (uint32_t milliseconds, uint32_t total_repeat_count, void(*callback)(type_identity_t< TArg >, uint32_t), TArg arg, bool first_tick_nodelay=false)
 Attach a free function, static member function or a non-capturing lambda function to the timer. More...
 
template<typename TArg >
esp_err_t attach_static_ms (uint32_t milliseconds, uint32_t total_repeat_count, void(*callback)(type_identity_t< TArg >), TArg arg, bool first_tick_nodelay=false)
 
esp_err_t attach_static_ms (uint32_t milliseconds, uint32_t total_repeat_count, callback_t callback, bool first_tick_nodelay=false)
 
void start ()
 
void start (uint32_t interval_ms)
 
void stop ()
 
esp_err_t stop_return_errors ()
 
void pause ()
 
esp_err_t pause_return_errors ()
 
void resume ()
 
esp_err_t resume_return_errors ()
 

Protected Attributes

mem_func_ptr_t _mem_func_ptr
 
- Protected Attributes inherited from MultiTimer
uint32_t _interval_ms
 
uint32_t _repeat_count_requested {1}
 
uint32_t _repeat_count {0}
 
callback_t _callback
 
uint32_t _orig_arg {0}
 
callback_with_arg_t _cb_lambda {nullptr}
 
bool _first_tick_nodelay {false}
 
SemaphoreHandle_t _reentry_mutex = NULL
 

Additional Inherited Members

- Protected Member Functions inherited from MultiTimer
esp_err_t _attach_ms (uint32_t arg)
 
void _mutex_take ()
 
void _mutex_give ()
 

Detailed Description

template<typename TClass>
class MultiTimerNonStatic< TClass >

Same as MultiTimer but allows a pointer to a non-static member function as a callback.

For this to work without the overhead of a std::function object, the MultiTimerNonStatic object must be created with an additional template argument specifying the type of the object from which to call the non-static member function:

timer.attach_mem_func_ptr_ms(10, 1, &AppClass::member_func, this);
timer.start();
void start()
Definition: multi_timer.hpp:208
Same as MultiTimer but allows a pointer to a non-static member function as a callback.
Definition: multi_timer.hpp:304
esp_err_t attach_mem_func_ptr_ms(uint32_t milliseconds, uint32_t total_repeat_count, mem_func_ptr_t mem_func_ptr, TClass *inst, bool first_tick_nodelay=false)
Same as attach_static_ms() but taking a pointer to a non-static member function as a callback,...
Definition: multi_timer.hpp:324

Member Function Documentation

◆ attach_mem_func_ptr_ms()

template<typename TClass >
esp_err_t MultiTimerNonStatic< TClass >::attach_mem_func_ptr_ms ( uint32_t  milliseconds,
uint32_t  total_repeat_count,
mem_func_ptr_t  mem_func_ptr,
TClass *  inst,
bool  first_tick_nodelay = false 
)
inline

Same as attach_static_ms() but taking a pointer to a non-static member function as a callback, see class description.

Like for the static version, the member function can have an additional argument containing the current number of times the callback was called.

Parameters
millisecondsTimer interval in milliseconds
total_repeat_countTimer is stopped after this many repeats
mem_func_ptrPointer to a bound, non-static member function
instPointer to the class instance the mem_func_ptr is bound to
first_tick_nodelayIf set to true, call callback immediately when the start() function is invoked, the first tick counts as a normal repeat and is repeated until total repeat count is reached

The documentation for this class was generated from the following file: