import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.Command;
+import frc.robot.constants.Constants;
import frc.robot.subsystems.LED.LED;
+import lib.controllers.PS5Controller;
+import lib.controllers.PS5Controller.PS5Button;
public class LEDDefaultCommand extends Command {
private LED led;
private boolean allianceIsRed = DriverStation.getAlliance().get() == DriverStation.Alliance.Red;
+ private final PS5Controller controller = new PS5Controller(Constants.DRIVER_JOY);
+ private int counter = 0;
public LEDDefaultCommand(LED led) {
this.led = led;
if (fiveSecondsBeforeChange() && allianceIsRed) {
// blink alliance color and rumble if red alliance 5 seconds before hub shifts
led.setStrobeLights(255, 0, 0);
+ counter = 0;
} else if (fiveSecondsBeforeChange()) {
// blink alliance color and rumble if blue alliance 5 seconds before hub shifts
led.setStrobeLights(0, 0, 255);
- } else if (playingDefense()) {
- led.alternate(255, 0, 0, 0, 0, 255, 5, 0, 67);
- } else if (DriverStation.isAutonomous() && allianceIsRed) {
+ counter = 0;
+ } else if(controller.get(PS5Button.LB).getAsBoolean()){
+ counter++;
+
+ if (counter == 1) {
+ led.alternate(255, 0, 0, 0, 0, 255, 5, 0, 67);
+ } else if (counter == 20) {
+ led.alternate(0, 0, 255, 255, 0, 0, 5, 0, 67);
+ }
+ if (counter >= 40) {
+ counter = 0;
+ }
+ }else if (DriverStation.isAutonomous() && allianceIsRed) {
// Dimmer light for auto in red alliance
led.setLEDs(50, 0, 0);
+ counter = 0;
} else if (DriverStation.isAutonomous()) {
// Dimmer light for auto in blue alliance
led.setLEDs(0, 0, 50);
+ counter = 0;
} else if (gameData != null && ((allianceIsRed && gameData.equals("B") && matchTime <= 105 && matchTime >= 80)
|| (allianceIsRed && gameData.equals("B") && matchTime <= 55 && matchTime >= 30))) {
// turn light off for inactive hub if red alliance and blue inactive first
led.setLEDs(0, 0, 0);
+ counter = 0;
} else if (gameData != null && ((allianceIsRed && gameData.equals("R") && matchTime <= 130 && matchTime >= 105)
|| (allianceIsRed && gameData.equals("R") && matchTime <= 80 && matchTime >= 55))) {
// turn light off for inactive hub if red alliance and red inactive first
led.setLEDs(0, 0, 0);
+ counter = 0;
} else if (gameData != null && ((!allianceIsRed && gameData.equals("B") && matchTime <= 130 && matchTime >= 105)
|| (!allianceIsRed && gameData.equals("B") && matchTime <= 80 && matchTime >= 55))) {
// turn off lights for inactive hub if blue alliance and blue inactive first
led.setLEDs(0, 0, 0);
+ counter = 0;
} else if (gameData != null && ((!allianceIsRed && gameData.equals("R") && matchTime <= 105 && matchTime >= 80)
|| (!allianceIsRed && gameData.equals("R") && matchTime <= 55 && matchTime >= 30))) {
// turn light off for inactive hub if blue alliance and red inactive first
led.setLEDs(0, 0, 0);
+ counter = 0;
} else if (allianceIsRed) {
// Red alliance
led.setTwoColorWave(255, 0, 0, 255, 255, 255);
+ counter = 0;
} else {
// Blue alliance
led.setTwoColorWave(0, 0, 255, 255, 255, 255);
+ counter = 0;
}
}
}
return false;
}
-
- private boolean playingDefense() {
- // TODO: add automatic defense lights
- return false;
- }
}
import frc.robot.commands.gpm.ReverseMotors;
import frc.robot.commands.gpm.RunSpindexer;
import frc.robot.commands.gpm.Superstructure;
+import frc.robot.commands.led_comm.DefenseLightsCommand;
+import frc.robot.commands.led_comm.LEDDefaultCommand;
import frc.robot.constants.Constants;
import frc.robot.subsystems.Climb.LinearClimb;
import frc.robot.subsystems.Intake.Intake;
+import frc.robot.subsystems.LED.LED;
import frc.robot.subsystems.drivetrain.Drivetrain;
import frc.robot.subsystems.hood.Hood;
import frc.robot.subsystems.shooter.Shooter;
private Intake intake;
private Spindexer spindexer;
private LinearClimb climb;
+ private LED led;
public PS5ControllerDriverConfig(
Drivetrain drive,
Hood hood,
Intake intake,
Spindexer spindexer,
- LinearClimb climb) {
+ LinearClimb climb,
+ LED led) {
super(drive);
this.shooter = shooter;
this.turret = turret;
this.intake = intake;
this.spindexer = spindexer;
this.climb = climb;
+ this.led = led;
}
public void configureControls() {