Fix compile error that wasn't caught
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
CommitLineData
416c4380
YN
1package org.usfirst.frc.team3501.robot.subsystems;\r
2\r
40348cab 3import org.usfirst.frc.team3501.robot.Constants;\r
e8986b9b
E
4import org.usfirst.frc.team3501.robot.Constants.Shooter.State;\r
5import org.usfirst.frc.team3501.robot.Robot;\r
40348cab
E
6\r
7import edu.wpi.first.wpilibj.CANTalon;\r
416c4380
YN
8import edu.wpi.first.wpilibj.command.Subsystem;\r
9\r
5585bd31 10public class Shooter extends Subsystem {\r
e8986b9b
E
11 private CANTalon shooter;\r
12 private State state;\r
5585bd31 13\r
40348cab 14 public Shooter() {\r
e9234163 15 shooter = new CANTalon(Constants.Shooter.PORT);\r
e8986b9b 16 state = State.STOPPED;\r
40348cab 17 }\r
416c4380 18\r
cb3389eb 19 public double getCurrentSpeed() {\r
9e247b05 20 return shooter.get();\r
cb3389eb
E
21 }\r
22\r
23 public void setSpeed(double speed) {\r
e8986b9b 24 state = State.RUNNING;\r
9e247b05 25 shooter.set(speed);\r
cb3389eb
E
26 }\r
27\r
e8986b9b
E
28 public void shooterButtonsPressed() {\r
29\r
2f17b006 30 if (Robot.oi.incrementSpeed.get()) {\r
e8986b9b
E
31 changeSpeed(0.1);\r
32 }\r
33\r
2f17b006 34 if (Robot.oi.decrementSpeed.get()) {\r
e8986b9b
E
35 changeSpeed(-0.1);\r
36 }\r
37\r
2f17b006 38 if (Robot.oi.trigger.get()) {\r
e8986b9b
E
39 if (this.getState() == State.STOPPED)\r
40 this.setSpeed(0.5);\r
41 } else {\r
42 if (this.getState() == State.RUNNING) {\r
43 this.stop();\r
44 }\r
45 }\r
46\r
2f17b006 47 if (Robot.oi.outputCurrentShooterSpeed.get()) {\r
e8986b9b
E
48 System.out.println("Current Shooter Speed: " + getCurrentSpeed());\r
49 }\r
50 }\r
51\r
52 private void stop() {\r
53 this.setSpeed(0.0);\r
54 }\r
55\r
56 private State getState() {\r
57 return state;\r
58 }\r
59\r
9e247b05
E
60 // Use negative # for decrement. Positive for increment.\r
61 public void changeSpeed(double change) {\r
b87f9700 62 if (getCurrentSpeed() + change >= 1.0)\r
9e247b05 63 shooter.set(1.0);\r
b87f9700 64 else if (getCurrentSpeed() + change <= -1.0)\r
9e247b05 65 shooter.set(-1.0);\r
8e5f83d9 66 else {\r
9e247b05 67 double newSpeed = getCurrentSpeed() + change;\r
e9234163 68 setSpeed(newSpeed);\r
cb3389eb 69 }\r
e8986b9b 70 this.state = State.RUNNING;\r
cb3389eb
E
71 }\r
72\r
40348cab
E
73 @Override\r
74 protected void initDefaultCommand() {\r
40348cab 75 }\r
416c4380 76}\r