\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
}\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
double newSpeed = getCurrentSpeed() + change;\r
setSpeed(newSpeed);\r
}\r
- this.state = State.RUNNING;\r
}\r
\r
@Override\r