You must change the function2 code to do that. As it is now you directly return to function1 if the stepper has reached the target position:
case 2: // // Move to angle set by compass for testing "CompassAngle",
// switch back to joystick control if position reached or joystick is active
if ( !stepper1.moving() || joyActive ) function = 1;
break;
You can try this, if you want the stepper to hold its position for 60 seconds before going back to function1 ( try, it's untested! )
case 2: // // Move to angle set by compass for testing "CompassAngle",
// switch back to joystick control if position reached or joystick is active
if ( joyActive || holdTimer.expired() ) function = 1;
if ( !stepper1.moving() && !holdTimer.running() ) {
holdTimer.setTime( 60000 );
}
Of course you must define the new timer:
...
MoToTimebase printTimer; // Timer to print in regular intervals without blocking sketch
MoToTimebase joyTimer; // Timer to read joystick in regular intervals without blocking sketch
MoToTimer holdTimer; // Timer for stepper to hold position
...
I can't really imagine that yet. Perhaps a photo of the construction would be helpful. And I have no experience with your sensor.