Skip to content

Commit 52f009e

Browse files
committed
tweak buttons
1 parent 0c2f564 commit 52f009e

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

src/main/java/frc/robot/RobotContainer.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import edu.wpi.first.wpilibj2.command.Command;
1010
import edu.wpi.first.wpilibj2.command.Commands;
1111
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
12+
import frc.robot.commands.coral.EnableEjectBeamCommand;
1213
import frc.robot.commands.coral.OpenLoopCoralCommand;
1314
import frc.robot.commands.drive.DriveTeleopCommand;
1415
import frc.robot.controllers.FlyskyJoystick;
@@ -58,10 +59,19 @@ private void configureDriverBindings() {
5859
}
5960

6061
private void configureOperatorBindings() {
61-
new JoystickButton(xboxController, XboxController.Button.kA.value)
62-
.onTrue(new OpenLoopCoralCommand(coralSubsystem, 0.5));
62+
// Stop Coral
6363
new JoystickButton(xboxController, XboxController.Button.kB.value)
64-
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5));
64+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, 0));
65+
66+
// Intake Coral
67+
new JoystickButton(xboxController, XboxController.Button.kY.value)
68+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5))
69+
.onTrue(new EnableEjectBeamCommand(false, coralSubsystem));
70+
71+
// Eject Coral
72+
new JoystickButton(xboxController, XboxController.Button.kA.value)
73+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5))
74+
.onTrue(new EnableEjectBeamCommand(true, coralSubsystem));
6575
}
6676

6777
public Command getAutonomousCommand() {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package frc.robot.commands.coral;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.coral.CoralSubsystem;
5+
6+
public class EnableEjectBeamCommand extends InstantCommand {
7+
private CoralSubsystem coralSubsystem;
8+
private Boolean enable;
9+
10+
public EnableEjectBeamCommand(Boolean enable, CoralSubsystem coralSubsystem) {
11+
this.coralSubsystem = coralSubsystem;
12+
this.enable = enable;
13+
}
14+
15+
@Override
16+
public void initialize() {
17+
coralSubsystem.enableEjectBeam(enable);
18+
}
19+
}

src/main/java/frc/robot/subsystems/coral/CoralSubsystem.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public void setPct(double percentOutput) {
4747
io.setPct(percentOutput);
4848
}
4949

50+
public void enableEjectBeam(boolean enable) {
51+
io.enableRevLimitSwitch(enable);
52+
}
53+
5054
@Override
5155
public boolean atSpeed() {
5256
return setpoint.minus(inputs.velocity).abs(RotationsPerSecond)

0 commit comments

Comments
 (0)