コード例 #1
0
ファイル: vexuser.c プロジェクト: Impact2585/convex
// called before either autonomous or user control
void
vexUserInit()
{
    SmartMotorsInit();
    SmartMotorCurrentMonitorEnable();
    SmartMotorRun();
}
コード例 #2
0
task usercontrol()
{
	// User control code here, inside the loop
	SmartMotorRun();
	while (true)
	{
		//Create "deadzone" for Y1/Ch3
		if(abs(vexRT[Ch3]) > threshold)
			Y1 = vexRT[Ch3];
		else
			Y1 = 0;
		//Create "deadzone" for X1/Ch4
		if(abs(vexRT[Ch4]) > threshold)
			X1 = vexRT[Ch4];
		else
			X1 = 0;
		//Create "deadzone" for X2/Ch1
		if(abs(vexRT[Ch1]) > threshold)
			X2 = vexRT[Ch1];
		else
			X2 = 0;

		//Remote Control Commands
		motor[Rfrontwheel] = Y1 - X2 - X1;
		motor[Rbackwheel] =  Y1 - X2 + X1;
		motor[Lfrontwheel] = Y1 + X2 + X1;
		motor[Lbackwheel] =  Y1 + X2 - X1;
		motor[Lmidwheel] = vexRT(Ch3);
		motor[Rmidwheel] = vexRT(Ch3);
		motor[Lmidwheel] = -vexRT(Ch4);
		motor[Rmidwheel] = vexRT(Ch4);

		//Launcher Code
		if(vexRT[Btn8DXmtr2] == 1)
		{
			Outspeed(90);
			pressed = true;
		}
		else
			Outspeed(0);
		//ADVANCED LAUNCHER CODE
		/*else if(vexRT[Btn8D] == 0 && pressed)
		{
			revdown = true;
			pressed = false;
		}
		else
			Outspeed(0);
		if(revdown)
		{
			if(max != 0)
			{
				max--;
				Outspeed(127);
			}
			else if(med != 0)
			{
				med--;
				Outspeed(80);
			}
			else if(min != 0)
			{
				min--;
				Outspeed(20);
			}
			else
			{
				Outspeed(0);
				revdown = false;
				max = 50;
				med = 50;
				min = 50;
			}
		}
		*/
		//Intake Code
		if(vexRT[Btn5UXmtr2] == 1)
		{
			Inspeed(127);
		}
		else if(vexRT[Btn5DXmtr2] == 1)
		{
			Inspeed(-127);
		}
		else
		{
			Inspeed(0);
		}
	}
}