|
Member function as Task
I'm using the Task class in WPILib to poll for IMU data at the moment, and in doing so I've discovered that I can't cast member functions to a FUNCPTR or a VOIDFUNCPTR. To solve this, I created a static class which holds an IMU instance and has a static function that calls the instance's update method. That did it, but now I have more methods that I'd like to call in the background. I figured that creating a class for every member function is not a very extendable solution, so my question is, how can I create Tasks with member functions? Or am I missing something and can cast a member function to a FUNCPTR? Do I even need to cast functions to FUNCPTRs? The online examples I saw casted functions to FUNCPTRs, and directly passing functions as arguments throws a compile-time error.
|