X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fsubsystems%2FShooter.java;h=ef27bf92157dc341fef9f188634a94be34d9ffb3;hb=913142dea025d7127e9039e9bebabc62c4c16bc8;hp=ca09301c4162c69c690e22e8b66029892948197f;hpb=5585bd3152a10ee382cf7d1fc6b75299f96689a7;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 ca09301c..ef27bf92 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -1,15 +1,53 @@ -package org.usfirst.frc.team3501.robot.subsystems; - -import edu.wpi.first.wpilibj.command.Subsystem; - -public class Shooter extends Subsystem { - - public Shooter() { - - } - - @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 { + // TODO: check all files for control m characters + 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() { + } +}