7376255d6e6eea2feb382c7186f48da30ec136ba
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
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 getCurrentSpeed() {
17 return shooter.get();
18 }
19
20 public void setSpeed(double speed) {
21 shooter.set(speed);
22 }
23
24 public void stop() {
25 this.setSpeed(0.0);
26 }
27
28 public State getState() {
29 return (this.getCurrentSpeed() == 0) ? State.RUNNING : State.STOPPED;
30 }
31
32 // Use negative # for decrement. Positive for increment.
33 public void changeSpeed(double change) {
34 if (getCurrentSpeed() + change >= 1.0)
35 shooter.set(1.0);
36 else if (getCurrentSpeed() + change <= -1.0)
37 shooter.set(-1.0);
38 else {
39 double newSpeed = getCurrentSpeed() + change;
40 setSpeed(newSpeed);
41 }
42 }
43
44 @Override
45 protected void initDefaultCommand() {
46 }
47 }