So the Void for the Button Up and the double target at the top of the loop aren’t responding. it is saying:
[clang] Cannot initialize a parameter of type ‘void (*)()’ with an lvalue of type ‘void (double)’: different number of parameters (0 vs 1)
you cannot have an argument passed to the callback function. So it would need to be defined as follows:
void tiltPID(void) {
...
}
However, if you have a specific target in mind when using the button you can create an intermediary callback function that selects the value of target to past to tiltPID. Then tiltPID can have a argument and the intermediate function would look like this.
void buttonTilt(void) {
tiltPID(50);
}
...
// example may not be accurate I don't use VEXCode
main () {
...
Controller1.ButtonUp.pressed(buttonTilt);
...
}
void tiltPID(double target) {
// code here
}
void buttonTilt (void) {
tiltPID(50);
}
void usercontrol (void) {
Controller1.ButtonUp.pressed(buttonTilt); // this may be able to be called from pre_auton().
while (1) {
// code here
}
}
void main (void) {
// standard competition template
}
If you want to test the callback is working you can replace the code in tiltPID() with
Controller1.Screen.clearScreen();
// Set the cursor (text starting point) to row 1, column 1
Controller1.Screen.setCursor(1,1);
// Print formatted on the first line
Controller1.Screen.print("In tiltPID!");
mostly copied form VCS example
If the text shows up on the controller then the problem is with the PID not the callback.
The problem is that you have two different paths that Tilter.stop() will get called. While this may not be technically what happens, but when you press ButtonUp, essentially a task gets created to run the call-back (buttonTilt in this case). So now buttonTilt and usercontrol are running at the same time (really not true, but the OS provides the illusion this is the case). Now, buttonTilt is trying to move the Tilter motor. At the same time, un usercontrol, assuming neither ButtonLeft nor ButtonRight are being pressed, the control of that if statement falls thru to Tilt.stop().
TL;DR - You have two things fighting for control over issuing commands to the Tilt motor - one trying to move it while the other tries to stop it.