Remove buttons pressed to change to command based, change getState() to actually...
authorKevin Zhang <icestormf1@gmail.com>
Sat, 23 Jan 2016 02:51:05 +0000 (18:51 -0800)
committerKevin Zhang <icestormf1@gmail.com>
Sat, 23 Jan 2016 03:37:35 +0000 (19:37 -0800)
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index 5727cc286cb6f1513b9c3c867af4f0468c1cb9b9..7376255d6e6eea2feb382c7186f48da30ec136ba 100755 (executable)
@@ -2,18 +2,15 @@ package org.usfirst.frc.team3501.robot.subsystems;
 \r
 import org.usfirst.frc.team3501.robot.Constants;\r
 import org.usfirst.frc.team3501.robot.Constants.Shooter.State;\r
-import org.usfirst.frc.team3501.robot.Robot;\r
 \r
 import edu.wpi.first.wpilibj.CANTalon;\r
 import edu.wpi.first.wpilibj.command.Subsystem;\r
 \r
 public class Shooter extends Subsystem {\r
   private CANTalon shooter;\r
-  private State state;\r
 \r
   public Shooter() {\r
     shooter = new CANTalon(Constants.Shooter.PORT);\r
-    state = State.STOPPED;\r
   }\r
 \r
   public double getCurrentSpeed() {\r
@@ -21,40 +18,15 @@ public class Shooter extends Subsystem {
   }\r
 \r
   public void setSpeed(double speed) {\r
-    state = State.RUNNING;\r
     shooter.set(speed);\r
   }\r
 \r
-  public void shooterButtonsPressed() {\r
-\r
-    if (Robot.oi.incrementSpeed.get()) {\r
-      changeSpeed(0.1);\r
-    }\r
-\r
-    if (Robot.oi.decrementSpeed.get()) {\r
-      changeSpeed(-0.1);\r
-    }\r
-\r
-    if (Robot.oi.trigger.get()) {\r
-      if (this.getState() == State.STOPPED)\r
-        this.setSpeed(0.5);\r
-    } else {\r
-      if (this.getState() == State.RUNNING) {\r
-        this.stop();\r
-      }\r
-    }\r
-\r
-    if (Robot.oi.outputCurrentShooterSpeed.get()) {\r
-      System.out.println("Current Shooter Speed: " + getCurrentSpeed());\r
-    }\r
-  }\r
-\r
-  private void stop() {\r
+  public void stop() {\r
     this.setSpeed(0.0);\r
   }\r
 \r
-  private State getState() {\r
-    return state;\r
+  public State getState() {\r
+    return (this.getCurrentSpeed() == 0) ? State.RUNNING : State.STOPPED;\r
   }\r
 \r
   // Use negative # for decrement. Positive for increment.\r
@@ -67,7 +39,6 @@ public class Shooter extends Subsystem {
       double newSpeed = getCurrentSpeed() + change;\r
       setSpeed(newSpeed);\r
     }\r
-    this.state = State.RUNNING;\r
   }\r
 \r
   @Override\r