Make style edits
[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
5 import edu.wpi.first.wpilibj.CANTalon;
6 import edu.wpi.first.wpilibj.command.Subsystem;
7
8 public class Shooter extends Subsystem {
9 CANTalon wheel;
10
11 public Shooter() {
12 wheel = new CANTalon(Constants.Shooter.SHOOTER_WHEEL_PORT);
13 }
14
15 public double getCurrentSpeed() {
16 return wheel.get();
17 }
18
19 public void setSpeed(double speed) {
20 wheel.set(speed);
21 }
22
23 public void incrementSpeed(double increment) {
24 if (getCurrentSpeed() >= 1.0)
25 wheel.set(1.0);
26 else if (getCurrentSpeed() <= -1.0)
27 wheel.set(-1.0);
28 else {
29 double newSpeed = getCurrentSpeed() + increment;
30 wheel.set(newSpeed);
31 }
32 }
33
34 // THIS DECREMENT METHOD TAKES ONLY POSITIVE VALUES SINCE IT ACCOUNTS FOR
35 // SUBTRACTING THE CURRENT MOTOR SPEED!
36 public void decrementSpeed(double decrement) {
37
38 if (getCurrentSpeed() >= 1.0)
39 wheel.set(1.0);
40 else if (getCurrentSpeed() <= -1.0)
41 wheel.set(-1.0);
42 else {
43 double newSpeed = getCurrentSpeed() - decrement;
44 wheel.set(newSpeed);
45 }
46 }
47
48 @Override
49 protected void initDefaultCommand() {
50
51 }
52 }