Skip to content

Commit

Permalink
took a while to figure that trigger out
Browse files Browse the repository at this point in the history
  • Loading branch information
taran-duba committed Mar 7, 2025
1 parent 9d10070 commit c6a0145
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
5 changes: 2 additions & 3 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public RobotContainer() {
new CommandXboxController(Constants.SECONDARY_XBOX_CONTROLLER_PORT);
drivetrain = TunerConstants.createDrivetrain();
coralManipulator = new CoralManipulatorSystem();
leds = new LEDSubsystem(coralManipulator);
leds = new LEDSubsystem();
climber = new ClimberSubsystem();
configureBindings();
assembleMechanisms();
Expand Down Expand Up @@ -140,8 +140,7 @@ private void configureTriggers() {
new Trigger(coralManipulator.grabber::hasCoral)
.and(DriverStation::isEnabled)
.onTrue(runOnce(() -> leds.setAnimation(Events.CORALINTAKE)));
new Trigger(coralManipulator::isTransitioning).onTrue(leds.selectAnimationCommand());
new Trigger(coralManipulator::isTransitioning).onTrue(leds.selectAnimationCommand());
new Trigger(coralManipulator::isTransitioning).onFalse(leds.selectAnimationCommand(coralManipulator::getCurrentState));
}

private void assembleMechanisms() {
Expand Down
18 changes: 4 additions & 14 deletions src/main/java/frc/robot/subsystems/led/LEDSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SelectCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.constants.Constants;
import frc.robot.subsystems.coral.CoralManipulatorState;
import frc.robot.subsystems.coral.CoralManipulatorSystem;
import java.util.Map;
import java.util.function.Supplier;

public class LEDSubsystem extends SubsystemBase {
public final CANdle candle = new CANdle(0, Constants.RIO_BUS);
Expand All @@ -20,9 +19,8 @@ public class LEDSubsystem extends SubsystemBase {
private CANdleConfiguration configAll;
public ProgressBar progressBar;
private Events event;
private final CoralManipulatorSystem cms;

public LEDSubsystem(CoralManipulatorSystem cms) {
public LEDSubsystem() {
configAll = new CANdleConfiguration();
configAll.statusLedOffWhenActive = false;
configAll.disableWhenLOS = false;
Expand All @@ -31,8 +29,6 @@ public LEDSubsystem(CoralManipulatorSystem cms) {
configAll.vBatOutputMode = CANdle.VBatOutputMode.On;
candle.configAllSettings(configAll, 100);
progressBar = new ProgressBar(this);
this.cms = cms;
new Trigger(cms::isTransitioning).onTrue(selectAnimationCommand());
}

public void clearAnimation() {
Expand Down Expand Up @@ -155,13 +151,7 @@ public void setAnimation(Events animation) {
candle.animate(toAnimate);
}

private CoralManipulatorState queuedState = CoralManipulatorState.IDLE;

private void queueState(CoralManipulatorState state) {
queuedState = state;
}

public Command selectAnimationCommand() {
public Command selectAnimationCommand(Supplier<CoralManipulatorState> getCMS) {
return new SelectCommand<>(
Map.ofEntries(
Map.entry(
Expand Down Expand Up @@ -197,7 +187,7 @@ public Command selectAnimationCommand() {
Map.entry(
CoralManipulatorState.STOWED,
runOnce(() -> setAnimation(Events.CORALSTOWED)))),
cms::getQueuedState);
getCMS);
}

@Override
Expand Down

0 comments on commit c6a0145

Please sign in to comment.