| 1 | package org.usfirst.frc.team3501.robot.subsystems; |
| 2 | |
| 3 | import org.usfirst.frc.team3501.robot.Constants; |
| 4 | import org.usfirst.frc.team3501.robot.Constants.Shooter.State; |
| 5 | |
| 6 | import edu.wpi.first.wpilibj.CANTalon; |
| 7 | import edu.wpi.first.wpilibj.command.Subsystem; |
| 8 | |
| 9 | public class Shooter extends Subsystem { |
| 10 | private CANTalon shooter; |
| 11 | |
| 12 | public Shooter() { |
| 13 | shooter = new CANTalon(Constants.Shooter.PORT); |
| 14 | } |
| 15 | |
| 16 | public double getCurrentSetPoint() { |
| 17 | return shooter.get(); |
| 18 | } |
| 19 | |
| 20 | public void setSpeed(double speed) { |
| 21 | if (speed > 1.0) |
| 22 | shooter.set(1.0); |
| 23 | else if (speed < -1.0) |
| 24 | shooter.set(-1.0); |
| 25 | else |
| 26 | shooter.set(speed); |
| 27 | } |
| 28 | |
| 29 | public void stop() { |
| 30 | this.setSpeed(0.0); |
| 31 | } |
| 32 | |
| 33 | public State getState() { |
| 34 | return (this.getCurrentSetPoint() == 0) ? State.RUNNING : State.STOPPED; |
| 35 | } |
| 36 | |
| 37 | // Use negative # for decrement. Positive for increment. |
| 38 | public void changeSpeed(double change) { |
| 39 | double newSpeed = getCurrentSetPoint() + change; |
| 40 | if (newSpeed > 1.0) |
| 41 | shooter.set(1.0); |
| 42 | else if (newSpeed < -1.0) |
| 43 | shooter.set(-1.0); |
| 44 | else { |
| 45 | setSpeed(newSpeed); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | protected void initDefaultCommand() { |
| 51 | } |
| 52 | } |