Fix formatting and stuff
authorKevin Zhang <icestormf1@gmail.com>
Mon, 15 Feb 2016 19:25:34 +0000 (11:25 -0800)
committerKevin Zhang <icestormf1@gmail.com>
Mon, 15 Feb 2016 19:25:34 +0000 (11:25 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/commands/scaler/ToggleScaling.java [new file with mode: 0644]

index 59bbcca3f1baf6561bcd3882aa8a0c4dfc3806b5..9c666016ae1b768cafebd34e3512bb890830bb6b 100644 (file)
@@ -17,7 +17,7 @@ public class Constants {
 
     public final static int PASS_PORTCULLIS_PORT = 0;
     public final static int PASS_CHEVAL_DE_FRISE_PORT = 0;
-    public final static int PASS_DRAWBRIDGE = 0;
+    public final static int PASS_DRAWBRIDGE_PORT = 0;
     public final static int PASS_SALLYPORT_PORT = 0;
 
     public final static int ARCADE_INTAKEARM_LEVEL_ONE_PORT = 0;
@@ -26,15 +26,16 @@ public class Constants {
     public final static int ARCADE_INTAKEARM_LEVEL_FOUR_PORT = 0;
 
     public final static int LEFT_JOYSTICK_TRIGGER_PORT = 0;
-    public final static int LEFT_JOYSTICK_TOP_LEFT_PORT = 4;
-    public final static int LEFT_JOYSTICK_TOP_RIGHT_PORT = 5;
+    public final static int SPIN1_PORT = 4;
+    public final static int SPIN2_PORT = 5;
     public final static int LEFT_JOYSTICK_TOP_CENTER_PORT = 3;
     public final static int LEFT_JOYSTICK_TOP_LOW_PORT = 2;
 
     public final static int RIGHT_JOYSTICK_TRIGGER_PORT = 0;
     public final static int RIGHT_JOYSTICK_THUMB_PORT = 2;
 
-    public final static int SCALING_BUTTON_PORT = 0;
+    public final static int TOGGLE_SCALING_PORT = 0;
+
   }
 
   public static class DriveTrain {
@@ -85,6 +86,9 @@ public class Constants {
     public final static double WINCH_STOP_SPEED = 0.0;
     public final static double WINCH_IN_SPEED = 0;
     public final static double SECONDS_TO_CLAMP = 2.0;
+
+    public static boolean SCALING = false;
+
   }
 
   public static class Shooter {
index 4cd6450fa6acda96b779658017c526d14a1e663f..f72a6043ba2394dd34921f5cb816f183d7eda6d5 100644 (file)
@@ -12,6 +12,7 @@ import org.usfirst.frc.team3501.robot.commands.scaler.ExtendLift;
 import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift;
 import org.usfirst.frc.team3501.robot.commands.scaler.RunWinchContinuous;
 import org.usfirst.frc.team3501.robot.commands.scaler.StopWinch;
+import org.usfirst.frc.team3501.robot.commands.scaler.ToggleScaling;
 import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
 import org.usfirst.frc.team3501.robot.commands.shooter.runShooter;
 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
@@ -20,7 +21,6 @@ import edu.wpi.first.wpilibj.DigitalInput;
 import edu.wpi.first.wpilibj.Joystick;
 import edu.wpi.first.wpilibj.buttons.Button;
 import edu.wpi.first.wpilibj.buttons.JoystickButton;
-import edu.wpi.first.wpilibj.command.Scheduler;
 
 public class OI {
   public static boolean isScalingMode = false;
@@ -54,7 +54,7 @@ public class OI {
   public static Button shootBoulder;
 
   // button to change robot to the scaling mode
-  public static DigitalButton toggleScalingMode;
+  public static DigitalButton toggleScaling;
 
   public OI() {
     leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
@@ -62,28 +62,50 @@ public class OI {
 
     passPortcullis = new DigitalButton(
         new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT));
+    passPortcullis.whenPressed(new PassPortcullis());
+
     passChevalDeFrise = new DigitalButton(
         new DigitalInput(Constants.OI.PASS_CHEVAL_DE_FRISE_PORT));
+    passChevalDeFrise.whenPressed(new PassChevalDeFrise());
+
     passDrawbridge = new DigitalButton(
-        new DigitalInput(Constants.OI.PASS_DRAWBRIDGE));
+        new DigitalInput(Constants.OI.PASS_DRAWBRIDGE_PORT));
+    passDrawbridge.whenPressed(new PassDrawBridge());
+
     passSallyPort = new DigitalButton(
         new DigitalInput(Constants.OI.PASS_SALLYPORT_PORT));
+    passSallyPort.whenPressed(new PassSallyPort());
 
     lowerChevalDeFrise = new DigitalButton(
         new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_ONE_PORT));
+    lowerChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
+        IntakeArm.potAngles[0], IntakeArm.moveIntakeArmSpeed));
+
     moveToIntakeBoulder = new DigitalButton(
         new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT));
+    moveToIntakeBoulder.whenPressed(new MoveIntakeArmToAngle(
+        IntakeArm.potAngles[1], IntakeArm.moveIntakeArmSpeed));
+
     poiseAboveChevalDeFrise = new DigitalButton(
         new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_THREE_PORT));
+    poiseAboveChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
+        IntakeArm.potAngles[2], IntakeArm.moveIntakeArmSpeed));
+
     moveIntakeArmInsideRobot = new DigitalButton(
         new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_FOUR_PORT));
+    moveIntakeArmInsideRobot.whenPressed(new MoveIntakeArmToAngle(
+        IntakeArm.potAngles[3], IntakeArm.moveIntakeArmSpeed));
 
     toggleShooter = new JoystickButton(leftJoystick,
         Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
     SpinRobot180_1 = new JoystickButton(leftJoystick,
-        Constants.OI.LEFT_JOYSTICK_TOP_LEFT_PORT);
+        Constants.OI.SPIN1_PORT);
+    SpinRobot180_1.whenPressed(new Turn180());
+
     SpinRobot180_2 = new JoystickButton(leftJoystick,
-        Constants.OI.LEFT_JOYSTICK_TOP_RIGHT_PORT);
+        Constants.OI.SPIN2_PORT);
+    SpinRobot180_2.whenPressed(new Turn180());
+
     compactRobot_1 = new JoystickButton(leftJoystick,
         Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
     compactRobot_2 = new JoystickButton(leftJoystick,
@@ -94,37 +116,11 @@ public class OI {
     shootBoulder = new JoystickButton(rightJoystick,
         Constants.OI.RIGHT_JOYSTICK_THUMB_PORT);
 
-    toggleScalingMode = new DigitalButton(
-        new DigitalInput(Constants.OI.SCALING_BUTTON_PORT));
-
-    passPortcullis.whenPressed(new PassPortcullis());
-    passChevalDeFrise.whenPressed(new PassChevalDeFrise());
-    passDrawbridge.whenPressed(new PassDrawBridge());
-    passSallyPort.whenPressed(new PassSallyPort());
-
-    lowerChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
-        IntakeArm.potAngles[0], IntakeArm.moveIntakeArmSpeed));
-    moveToIntakeBoulder.whenPressed(new MoveIntakeArmToAngle(
-        IntakeArm.potAngles[1], IntakeArm.moveIntakeArmSpeed));
-    poiseAboveChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
-        IntakeArm.potAngles[2], IntakeArm.moveIntakeArmSpeed));
-    moveIntakeArmInsideRobot.whenPressed(new MoveIntakeArmToAngle(
-        IntakeArm.potAngles[3], IntakeArm.moveIntakeArmSpeed));
-
-    if (toggleScalingMode.get()) {
-      if (!isScalingMode) {
-        isScalingMode = true;
-        if (!isCompactRobot) {
-          Scheduler.getInstance().add(new CompactRobot());
-          isCompactRobot = true;
-        }
-      } else if (isScalingMode) {
-        isScalingMode = false;
-        Scheduler.getInstance().add(new CompactRobot());
-      }
-    }
+    toggleScaling = new DigitalButton(
+        new DigitalInput(Constants.OI.TOGGLE_SCALING_PORT));
+    toggleScaling.whenPressed(new ToggleScaling());
 
-    if (!isScalingMode) {
+    if (!Constants.Scaler.SCALING) {
       toggleShooter.toggleWhenPressed(new runShooter());
       compactRobot_1.whenPressed(new CompactRobot());
       compactRobot_2.whenPressed(new CompactRobot());
@@ -133,6 +129,10 @@ public class OI {
       shootBoulder.whenPressed(new Shoot());
 
     } else if (isScalingMode) {
+      // toggleShooter becomes winch
+      // compact robot button 1 and 2 retracts the lift
+      // intake button stops the winch
+      // shoot button extends the lift
       toggleShooter.whenPressed(new RunWinchContinuous(
           Constants.Scaler.WINCH_IN_SPEED));
       compactRobot_1.whenPressed(new RetractLift());
@@ -141,8 +141,5 @@ public class OI {
       intakeBoulder.whenReleased(new StopWinch());
       shootBoulder.whenPressed(new ExtendLift());
     }
-
-    SpinRobot180_1.whenPressed(new Turn180());
-    SpinRobot180_2.whenPressed(new Turn180());
   }
 }
diff --git a/src/org/usfirst/frc/team3501/robot/commands/scaler/ToggleScaling.java b/src/org/usfirst/frc/team3501/robot/commands/scaler/ToggleScaling.java
new file mode 100644 (file)
index 0000000..a3ee9d4
--- /dev/null
@@ -0,0 +1,35 @@
+package org.usfirst.frc.team3501.robot.commands.scaler;
+
+import org.usfirst.frc.team3501.robot.Constants;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class ToggleScaling extends Command {
+  public ToggleScaling() {
+
+  }
+
+  @Override
+  protected void initialize() {
+    Constants.Scaler.SCALING = !Constants.Scaler.SCALING;
+  }
+
+  @Override
+  protected void execute() {
+
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+    end();
+  }
+}