I’m trying to let the controller print the real-time inertial sensor value to its screen, but when I run this code, the screen is blank. I think the screen refreshes too quickly, so the controller does not have enough time to print them. Is there a way to use a separate thread to print the sensor value?
int error = ang;
int prevError = 0;
int derivative;
Inertial.setRotation(0, degrees);
while(abs(error) > 2){
error = ang - Inertial.rotation(degrees);
derivative = error - prevError;
double mmp = kp * error + kd * derivative;
if(mmp > 0){mmp += 5;}
else if(mmp < 0){mmp -= 5;}
LF.spin(forward, mmp, percent);
LR.spin(forward, mmp, percent);
RF.spin(reverse, mmp, percent);
RR.spin(reverse, mmp, percent);
prevError = error;
Controller1.Screen.clearScreen();
Controller1.Screen.print(Inertial.rotation(degrees));
vex::task::sleep(20);
}
LF.stop();
LR.stop();
RF.stop();
RR.stop();
return 1;
}