Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coded and assigned panic button 🦟™️ #127

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public static class constLEDs {
public static final double LED_BRIGHTNESS = 1;

public static final int[] SHOOTER_UP_TO_SPEED_COLOR = { 36, 240, 83 };
public static final int[] INTAKE_GAME_PIECE_COLLECTED = { 240, 186, 36 };
public static final ColorFlowAnimation PANIC_ANIMATION = new ColorFlowAnimation(76, 22, 105, 0, 0.95, LED_NUMBER,
Direction.Forward);

public static final ColorFlowAnimation AMPLIFY_ANIMATION = new ColorFlowAnimation(160, 10, 247, 0, 0.95, LED_NUMBER,
Direction.Forward);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import frc.robot.commands.Shoot;
import frc.robot.commands.Climb;
import frc.robot.commands.LockTurret;
import frc.robot.commands.Panic;
import frc.robot.commands.TransferGamePiece;
import frc.robot.commands.ZeroPitch;
import frc.robot.subsystems.Climber;
Expand Down Expand Up @@ -115,7 +116,9 @@ private void configureOperatorBindings(SN_XboxController controller) {
controller.btn_A.onTrue(Commands.runOnce(() -> subPitch.setPitchAngle(0)));

controller.btn_LeftBumper.whileTrue(new TransferGamePiece(subTransfer));
controller.btn_LeftTrigger.whileTrue(new IntakeGamePiece(subIntake, subTransfer, subTurret));
controller.btn_LeftTrigger.whileTrue(new IntakeGamePiece(subIntake, subTransfer, subTurret, subLEDs));

controller.btn_North.whileTrue(new Panic(subLEDs));
}

public Command getAutonomousCommand() {
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/frc/robot/commands/IntakeGamePiece.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.RobotContainer;
import frc.robot.Constants.LockedLocation;
import frc.robot.Constants.constLEDs;
import frc.robot.RobotPreferences.prefIntake;
import frc.robot.RobotPreferences.prefTransfer;
import frc.robot.RobotPreferences.prefTurret;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.LEDs;
import frc.robot.subsystems.Transfer;
import frc.robot.subsystems.Turret;

public class IntakeGamePiece extends Command {
Intake subIntake;
Transfer subTransfer;
Turret subTurret;
LEDs subLEDs;

public IntakeGamePiece(Intake subIntake, Transfer subTransfer, Turret subTurret) {
public IntakeGamePiece(Intake subIntake, Transfer subTransfer, Turret subTurret, LEDs subLEDs) {
this.subIntake = subIntake;
this.subTransfer = subTransfer;
this.subTurret = subTurret;

this.subLEDs = subLEDs;
addRequirements(subIntake, subTransfer, subTurret);
}

Expand All @@ -32,6 +35,7 @@ public IntakeGamePiece(Intake subIntake, Transfer subTransfer, Turret subTurret)
public void initialize() {

subTurret.setTurretAngle(prefTurret.turretIntakePos.getValue());
subLEDs.clearAnimation();
}

// Called every time the scheduler runs while the command is scheduled.
Expand All @@ -53,6 +57,11 @@ public void end(boolean interrupted) {
subIntake.setNeutralMode();
subTransfer.setTransferNeutralOutput();
subTransfer.setFeederNeutralOutput();
if (!interrupted) {

subLEDs.setLEDs(constLEDs.INTAKE_GAME_PIECE_COLLECTED);
}

}

// Returns true when the command should end.
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/frc/robot/commands/Panic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Constants.constLEDs;
import frc.robot.subsystems.LEDs;

public class Panic extends Command {
LEDs subLEDs;

public Panic(LEDs subLEDs) {
// Use addRequirements() here to declare subsystem dependencies.
this.subLEDs = subLEDs;
}

// Called when the command is initially scheduled.
@Override
public void initialize() {
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
subLEDs.setLEDsToAnimation(constLEDs.PANIC_ANIMATION);

}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
subLEDs.clearAnimation();

}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
1 change: 1 addition & 0 deletions src/main/java/frc/robot/subsystems/LEDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void setLEDsToAnimation(Animation animation) {

public void clearAnimation() {
CANdle.clearAnimation(0);
CANdle.setLEDs(0, 0, 0);
}

@Override
Expand Down