create new command to record pot angle when button pressed
authorCindy Zhang <cindyzyx9@gmail.com>
Tue, 16 Feb 2016 23:30:20 +0000 (15:30 -0800)
committerCindy Zhang <cindyzyx9@gmail.com>
Wed, 17 Feb 2016 00:59:44 +0000 (16:59 -0800)
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java [new file with mode: 0644]

index 4eaf4dbf575d28cedccab77910af692a914c9caa..c2a09d209d6aee45ed212f56368396f3863f4d95 100644 (file)
@@ -1,11 +1,17 @@
 package org.usfirst.frc.team3501.robot;
 
+import org.usfirst.frc.team3501.robot.commands.intakearm.RecordPotAngle;
+
 import edu.wpi.first.wpilibj.Joystick;
+import edu.wpi.first.wpilibj.buttons.Button;
+import edu.wpi.first.wpilibj.buttons.JoystickButton;
 
 public class OI {
   public static Joystick leftJoystick;
   public static Joystick rightJoystick;
 
+  public static Button recordPotAngle;
+
   // // first column of arcade buttons - getting past defenses
   // public static DigitalButton passPortcullis;
   // public static DigitalButton passChevalDeFrise;
@@ -37,6 +43,10 @@ public class OI {
     leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
     rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
 
+    recordPotAngle = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
+    recordPotAngle.whenPressed(new RecordPotAngle());
+
     // passPortcullis = new DigitalButton(
     // new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT));
     // passPortcullis.whenPressed(new PassPortcullis());
index 2a48ffe5a6ce9290db767f1da6a5b34a3f398193..65f0313f97ea1c44f37aa44e4659ac8551a69d1f 100644 (file)
@@ -28,7 +28,7 @@ public class Robot extends IterativeRobot {
   // Sendable Choosers send a drop down menu to the Smart Dashboard.
   SendableChooser positionChooser;
   SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
-  positionFourDefense, positionFiveDefense;
+      positionFourDefense, positionFiveDefense;
 
   // Gyro stuff
   public GyroLib gyro;
@@ -36,7 +36,7 @@ public class Robot extends IterativeRobot {
   @Override
   public void robotInit() {
     // driveTrain = new DriveTrain();
-    // oi = new OI();
+    oi = new OI();
     // gyro = new GyroLib(I2C.Port.kOnboard, false);
     //
     // shooter = new Shooter();
diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java
new file mode 100644 (file)
index 0000000..bb9a012
--- /dev/null
@@ -0,0 +1,43 @@
+package org.usfirst.frc.team3501.robot.commands.intakearm;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+/**
+ *
+ */
+public class RecordPotAngle extends Command {
+
+  public RecordPotAngle() {
+    requires(Robot.intakeArm);
+  }
+
+  // Called just before this Command runs the first time
+  @Override
+  protected void initialize() {
+    Robot.intakeArm.potAngles[0] = Robot.intakeArm.getArmAngle();
+  }
+
+  // Called repeatedly when this Command is scheduled to run
+  @Override
+  protected void execute() {
+  }
+
+  // Make this return true when this Command no longer needs to run execute()
+  @Override
+  protected boolean isFinished() {
+    return false;
+  }
+
+  // Called once after isFinished returns true
+  @Override
+  protected void end() {
+  }
+
+  // Called when another command which requires one or more of the same
+  // subsystems is scheduled to run
+  @Override
+  protected void interrupted() {
+  }
+}