I'm having an issue trying to use a normal non-member function of my main sketch file as a callback. I can't get the function pointer to invoke from a function other than it was saved. More info below;
MotorEncoder.h
typedef void (*cb)(int16_t,int16_t);
class MotorEncoder
...
private:
cb _motor_callback;
Program.ino
cb encoder_cb = NULL;
...
encoder_cb = function_that_accepts_2_int16
DC_Encoder_1.move(motor_pos, speed, motor_id, encoder_cb);
I'm ableEDIT: I want to useedit the pointer inside of MotorEncoderdescription as to not confuse anyone.cpp but only inside of The code with the "move" functioncallbacks above is all correct. My main sketch gets the callback when The issue was I use either the the function parameter orwas working with open-source software and another developer was setting the MotorEncoder callback variable that I storeselected serial-port connection back to the function parameterbluetooth channel in. Program-correctly.ino calls a loop() function on the encoder and eventually I'd like to call my Program back via the The callback thatwas executed, I saved during the initial move call. The problem I'm having is the function pointer is still set (initializedwas connected to NULL inside of MotorEncoder, and still set) but it doesn't actually invoke the function on Program.ino.
I assume I'm missing something with scope/context but I'm not exactly sure what because I'm not tryingATMega2560 via serial connection to use a member function asraspberry pi and was looking for the callback it's just a normal function in my main sketch file. Any helps or tips would be appreciatedto show there, thanks!not monitoring bluetooth so I didn't see any data come across. Document your code.