I am trying to make it so when a button is pressed (not pressing) it runs a void function a parameter. This does work when I do not use a parameter, but when I be I get the following error:
./main.cpp:19:34: error: cannot initialize a parameter of type 'void (*)()' with an rvalue of type 'void'
Controller1.ButtonX.released(centerActivate(SIG_1));
^~~~~~~~~~~~~~~~~~~~~
./main.cpp:20:68: error: expected ‘(’ for function-style cast or type construction
Controller1.ButtonX.released( void (centerActivate(SIG_1))(void) ));
The callback needs to look like this, you cannot pass a parameter, you will need to figure out another way (i.e… global or something) to get currentSignature.
// will not work until currentSignature is defined
void centerActivate() {
currentlyCentered = false;
xCentered = false;
yCentered = false;
while (currentlyCentered == false) {
currentlyCentered = center(currentSignature);
}
}
Then in main, only register it once.
int main() {
Controller1.ButtonX.released( centerActivate );
while (true) {
// more code
}
}
also, not sure exactly what you are trying to do, but signatures like SIG_1 are usually only passed to the vision sensor constructor. Use the takeSnapshot method to retrieve the latest data from the vision sensor.