View Single Post
  #3   Spotlight this post!  
Unread 04-02-2015, 20:05
DrOmni9885's Avatar
DrOmni9885 DrOmni9885 is offline
Registered User
FRC #1595 (Dragons)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Spokane, WA
Posts: 8
DrOmni9885 is an unknown quantity at this point
Re: Child function problems

Quote:
Originally Posted by lopsided98 View Post
You can, but you just can't create the motor controller within that function. You need to create it when the robot starts, but then you can set its speed in the function.
Will this work

Code:
	int motorAutomationEncoder(double encoderDist,
							   double encoderDistThresholdMax,
							   double encoderDistThresholdMin,
							   CANTalon motor,
							   double motorSpeed)


	{
		if(encoderDist > encoderDistThresholdMax) {
			motor.Set(0.0);
		}
		else if(encoderDist <= encoderDistThresholdMax && encoderDist >= encoderDistThresholdMin) {
			motor.Set(motorSpeed);
		}
		else if(encoderDist < encoderDistThresholdMin) {
			motor.Set(0.0);
		}
	}
As aforementioned, the start-stop loop seems to have disappeared.
__________________
Code guy.
Reply With Quote