From 1f0a8a1fdcd06236105d4651bc15552b37da6716 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Fri, 22 Jan 2016 18:51:05 -0800 Subject: [PATCH] Remove buttons pressed to change to command based, change getState() to actually calculate the state and change methods from private to public --- .../team3501/robot/subsystems/Shooter.java | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 5727cc28..7376255d 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -2,18 +2,15 @@ package org.usfirst.frc.team3501.robot.subsystems; import org.usfirst.frc.team3501.robot.Constants; import org.usfirst.frc.team3501.robot.Constants.Shooter.State; -import org.usfirst.frc.team3501.robot.Robot; import edu.wpi.first.wpilibj.CANTalon; import edu.wpi.first.wpilibj.command.Subsystem; public class Shooter extends Subsystem { private CANTalon shooter; - private State state; public Shooter() { shooter = new CANTalon(Constants.Shooter.PORT); - state = State.STOPPED; } public double getCurrentSpeed() { @@ -21,40 +18,15 @@ public class Shooter extends Subsystem { } public void setSpeed(double speed) { - state = State.RUNNING; shooter.set(speed); } - public void shooterButtonsPressed() { - - if (Robot.oi.incrementSpeed.get()) { - changeSpeed(0.1); - } - - if (Robot.oi.decrementSpeed.get()) { - changeSpeed(-0.1); - } - - if (Robot.oi.trigger.get()) { - if (this.getState() == State.STOPPED) - this.setSpeed(0.5); - } else { - if (this.getState() == State.RUNNING) { - this.stop(); - } - } - - if (Robot.oi.outputCurrentShooterSpeed.get()) { - System.out.println("Current Shooter Speed: " + getCurrentSpeed()); - } - } - - private void stop() { + public void stop() { this.setSpeed(0.0); } - private State getState() { - return state; + public State getState() { + return (this.getCurrentSpeed() == 0) ? State.RUNNING : State.STOPPED; } // Use negative # for decrement. Positive for increment. @@ -67,7 +39,6 @@ public class Shooter extends Subsystem { double newSpeed = getCurrentSpeed() + change; setSpeed(newSpeed); } - this.state = State.RUNNING; } @Override -- 2.30.2