Missed a <= addadded it
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
index c562b20adfb727295ddd8ffba19addba4133b6d2..68c1d51ab1bb3550ac4b49b9547839ecf0e99c82 100755 (executable)
@@ -1,52 +1,53 @@
-package org.usfirst.frc.team3501.robot.subsystems;\r
-\r
-import org.usfirst.frc.team3501.robot.Constants;\r
-\r
-import edu.wpi.first.wpilibj.CANTalon;\r
-import edu.wpi.first.wpilibj.command.Subsystem;\r
-\r
-public class Shooter extends Subsystem {\r
-  CANTalon wheel;\r
-\r
-  public Shooter() {\r
-    wheel = new CANTalon(Constants.Shooter.SHOOTER_WHEEL_PORT);\r
-  }\r
-\r
-  public double getCurrentSpeed() {\r
-    return wheel.get();\r
-  }\r
-\r
-  public void setSpeed(double speed) {\r
-    wheel.set(speed);\r
-  }\r
-\r
-  public void incrementSpeed(double increment) {\r
-    if (getCurrentSpeed() >= 1.0)\r
-      wheel.set(1.0);\r
-    else if (getCurrentSpeed() <= -1.0)\r
-      wheel.set(-1.0);\r
-    else {\r
-      double newSpeed = getCurrentSpeed() + increment;\r
-      wheel.set(newSpeed);\r
-    }\r
-  }\r
-\r
-  // THIS DECREMENT METHOD TAKES ONLY POSITIVE VALUES SINCE IT ACCOUNTS FOR\r
-  // SUBTRACTING THE CURRENT MOTOR SPEED!\r
-  public void decrementSpeed(double decrement) {\r
-\r
-    if (getCurrentSpeed() >= 1.0)\r
-      wheel.set(1.0);\r
-    else if (getCurrentSpeed() <= -1.0)\r
-      wheel.set(-1.0);\r
-    else {\r
-      double newSpeed = getCurrentSpeed() - decrement;\r
-      wheel.set(newSpeed);\r
-    }\r
-  }\r
-\r
-  @Override\r
-  protected void initDefaultCommand() {\r
-\r
-  }\r
-}\r
+package org.usfirst.frc.team3501.robot.subsystems;
+
+import org.usfirst.frc.team3501.robot.Constants;
+import org.usfirst.frc.team3501.robot.Constants.Shooter.State;
+
+import edu.wpi.first.wpilibj.CANTalon;
+import edu.wpi.first.wpilibj.command.Subsystem;
+
+public class Shooter extends Subsystem {
+  // TODO: check all files for control m characters
+  private CANTalon shooter;
+
+  public Shooter() {
+    shooter = new CANTalon(Constants.Shooter.PORT);
+  }
+
+  public double getCurrentSetPoint() {
+    return shooter.get();
+  }
+
+  public void setSpeed(double speed) {
+    if (speed > 1.0)
+      shooter.set(1.0);
+    else if (speed < -1.0)
+      shooter.set(-1.0);
+    else
+      shooter.set(speed);
+  }
+
+  public void stop() {
+    this.setSpeed(0.0);
+  }
+
+  public State getState() {
+    return (this.getCurrentSetPoint() == 0) ? State.RUNNING : State.STOPPED;
+  }
+
+  // Use negative # for decrement. Positive for increment.
+  public void changeSpeed(double change) {
+    double newSpeed = getCurrentSetPoint() + change;
+    if (newSpeed > 1.0)
+      shooter.set(1.0);
+    else if (newSpeed < -1.0)
+      shooter.set(-1.0);
+    else {
+      setSpeed(newSpeed);
+    }
+  }
+
+  @Override
+  protected void initDefaultCommand() {
+  }
+}