I'm having a really hard time passing an instance of a callback method that's in a class (C++), oto an esp_timer callback. I'm essentially trying to port some code from an old project to ESP and this old project uses a Timer class that allows you to pass in the function and the instance of that class then uses std::bind() to point to the callback method, and that's what gets passed into the Timer. However I seem to be unable to do this with esp_timer, regardless of my attempts.
I've created the esp_timer_create_args_t, and tried passing in any non-static function, but that never works. I even went as far as passing the return of std::bind() as the arg of the timer_args, and calling it within there, but I get an panic abort when I try to call the function.
Is there any simple way to create esp_timer_create_args_t and pass in an instance of a callback function?
Timer callback as class instance
Re: Timer callback as class instance
https://github.com/vanBassum/ESP_Compon ... os/timer.h
https://github.com/vanBassum/ESP_Compon ... callback.h
This is how I do this.
Especially the callback class is handy.
I think the code is quite straight forward, however if you need some help, do ask.
https://github.com/vanBassum/ESP_Compon ... callback.h
This is how I do this.
Especially the callback class is handy.
I think the code is quite straight forward, however if you need some help, do ask.
Re: Timer callback as class instance
Wow, thanks so much for that. Looking through it now.
Re: Timer callback as class instance
As another reference, you could consider the ESPTimer class from esp-idf-cxx project: https://github.com/espressif/esp-idf-cx ... er_cxx.hpp
Who is online
Users browsing this forum: Assasinsareus and 97 guests