Example #1
0
	/**
	 * Runs the motor from the output of a Joystick.
	 */
	void OperatorControl() {

		LifterEncoder.StartLiveWindowMode();
		LifterEncoder.Reset();



		while (IsOperatorControl() && IsEnabled()) {
			// Set the motor controller's output.
			// This takes a number from -1 (100% speed in reverse) to +1 (100% speed forwards).
			// lifterA_motor.Set(joy.GetY());
			// lifterB_motor.Set(joy.GetY());


			if ( stick.GetRawButton(1))
			{
			}
			else if (stick.GetRawButton(2))
			{
			}
			else if (stick.GetRawButton(3))
			{
				// Elevator down
				if (BottomLimitSwitch.Get() == 0) {
					lifterA_motor.Set(0.5);
					lifterB_motor.Set(0.5);
				} else {
					lifterA_motor.Set(0);
					lifterB_motor.Set(0);
				}
			}
			else if (stick.GetRawButton(4))
			{
			}
			else if (stick.GetRawButton(5))
			{
				// Elevator up
				if (TopLimitSwitch.Get() == 0) {
					lifterA_motor.Set(-0.5);
					lifterB_motor.Set(-0.5);
				} else {
					lifterA_motor.Set(0);
					lifterB_motor.Set(0);
				}
			}
			else if (stick.GetRawButton(6))
			{
			}
			else if (stick.GetRawButton(7))
			{
			}
			else if (stick.GetRawButton(8))
			{
			}
			else if (stick.GetRawButton(9))
			{
			}
			else if (stick.GetRawButton(10))
			{
			}
			else if (stick.GetRawButton(11))
			{
			}
			else if (stick.GetRawButton(12))
			{
			}
			else
			{
				lifterA_motor.Set(0.0);
				lifterB_motor.Set(0.0);
			}


			if(BottomLimitSwitch.Get()==true)
			{
				LifterEncoder.Reset();
			}

			// Send some stuff to the dashboard
			SmartDashboard::PutBoolean("Top Limit Switch", TopLimitSwitch.Get());
			SmartDashboard::PutBoolean("Bottom Limit Switch", BottomLimitSwitch.Get());
			SmartDashboard::PutNumber("Encoder Position",LifterEncoder.GetRaw());

			Wait(kUpdatePeriod); // Wait 5ms for the next update.
		}
	}