X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fsubsystems%2FShooter.java;h=07948f2f144579922ccf35da7fdc11507fe16630;hb=5932d8339e4e4f02a0689aecf77cd7fd9b72e854;hp=7376255d6e6eea2feb382c7186f48da30ec136ba;hpb=1f0a8a1fdcd06236105d4651bc15552b37da6716;p=3501%2Fstronghold-2016 diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 7376255d..07948f2f 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -1,47 +1,52 @@ -package org.usfirst.frc.team3501.robot.subsystems; - -import org.usfirst.frc.team3501.robot.Constants; -import org.usfirst.frc.team3501.robot.Constants.Shooter.State; - -import edu.wpi.first.wpilibj.CANTalon; -import edu.wpi.first.wpilibj.command.Subsystem; - -public class Shooter extends Subsystem { - private CANTalon shooter; - - public Shooter() { - shooter = new CANTalon(Constants.Shooter.PORT); - } - - public double getCurrentSpeed() { - return shooter.get(); - } - - public void setSpeed(double speed) { - shooter.set(speed); - } - - public void stop() { - this.setSpeed(0.0); - } - - public State getState() { - return (this.getCurrentSpeed() == 0) ? State.RUNNING : State.STOPPED; - } - - // Use negative # for decrement. Positive for increment. - public void changeSpeed(double change) { - if (getCurrentSpeed() + change >= 1.0) - shooter.set(1.0); - else if (getCurrentSpeed() + change <= -1.0) - shooter.set(-1.0); - else { - double newSpeed = getCurrentSpeed() + change; - setSpeed(newSpeed); - } - } - - @Override - protected void initDefaultCommand() { - } -} +package org.usfirst.frc.team3501.robot.subsystems; + +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.Constants.Shooter.State; + +import edu.wpi.first.wpilibj.CANTalon; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class Shooter extends Subsystem { + private CANTalon shooter; + + public Shooter() { + shooter = new CANTalon(Constants.Shooter.PORT); + } + + public double getCurrentSetPoint() { + return shooter.get(); + } + + public void setSpeed(double speed) { + if (speed > 1.0) + shooter.set(1.0); + else if (speed < -1.0) + shooter.set(-1.0); + else + shooter.set(speed); + } + + public void stop() { + this.setSpeed(0.0); + } + + public State getState() { + return (this.getCurrentSetPoint() == 0) ? State.RUNNING : State.STOPPED; + } + + // Use negative # for decrement. Positive for increment. + public void changeSpeed(double change) { + double newSpeed = getCurrentSetPoint() + change; + if (newSpeed > 1.0) + shooter.set(1.0); + else if (newSpeed < -1.0) + shooter.set(-1.0); + else { + setSpeed(newSpeed); + } + } + + @Override + protected void initDefaultCommand() { + } +}