timer in a class
Posted: Fri Feb 11, 2022 6:39 am
Is there a proper way to initialise a timer inside a class?
I am trying to do a c++ project and i want to user the high resolution timer.
The class is about XH711 adc 24 bit.
I have an init function where i do everything needed for the adc and i want in there to init also the timer by seting the
esp_timer_create_args_t
When i set the callback function i also set a class function for the callback. I always get error on build
and my setup of args is
When i also tried this:
and i get error of:
What is the proper way to do this?
I am trying to do a c++ project and i want to user the high resolution timer.
The class is about XH711 adc 24 bit.
I have an init function where i do everything needed for the adc and i want in there to init also the timer by seting the
esp_timer_create_args_t
When i set the callback function i also set a class function for the callback. I always get error on build
Code: Select all
"void (Xh711::*)(void *args)" cannot be used to initialize an entity of type "esp_timer_cb_t"
Code: Select all
const esp_timer_create_args_t timerArgs={
.callback = onTimer,
.arg = NULL,
.dispatch_method = ESP_TIMER_TASK,
.name = "Measurement",
.skip_unhandled_events = false
};
Code: Select all
const esp_timer_create_args_t timerArgs={
.callback = Xh711::onTimer,
.arg = NULL,
.dispatch_method = ESP_TIMER_TASK,
.name = "Measurement",
.skip_unhandled_events = false
};
Code: Select all
cannot convert 'Xh711::onTimer' from type 'void (Xh711::)(void*)' to type 'esp_timer_cb_t' {aka 'void (*)(void*)'}