refactor RunIntake to be RunIntakeContinous (because its used only with joysticks
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / intakearm / RunIntakeContinuous.java
diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeContinuous.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeContinuous.java
new file mode 100644 (file)
index 0000000..989cde6
--- /dev/null
@@ -0,0 +1,50 @@
+package org.usfirst.frc.team3501.robot.commands.intakearm;
+
+import org.usfirst.frc.team3501.robot.Constants.IntakeArm;
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class RunIntakeContinuous extends Command {
+  int direction;
+
+  public RunIntakeContinuous(int direction) {
+    requires(Robot.intakeArm);
+    this.direction = direction;
+  }
+
+  @Override
+  protected void initialize() {
+    if (direction == IntakeArm.IN)
+      Robot.intakeArm.intakeBall();
+    else if (direction == IntakeArm.OUT)
+      Robot.intakeArm.outputBall();
+    else
+      Robot.intakeArm.stopRollers();
+  }
+
+  @Override
+  protected void execute() {
+    if (Photogate.ballState())
+      Robot.intakeArm.outputBall();
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+  }
+
+  // while holding right trigger, intake intakes
+  // it intakes until it sees the ball with the photogate
+  // as soon as it sees the ball, it outtakes for 0.2 seconds.
+  // after this happens, the right trigger does nothing for 2 seconds
+
+}