From 1b8d784bca3505ecbac2154bec0f45153390688f Mon Sep 17 00:00:00 2001 From: avidraccoon Date: Mon, 21 Oct 2024 19:01:33 -0400 Subject: [PATCH] Automated commit at 10/21/2024 19:01:33 --- src/main/java/frc/robot/RobotContainer.java | 12 +++ .../frc/robot/constants/FeatureFlags.java | 1 + .../frc/robot/constants/LEDConstants.java | 3 +- src/main/java/frc/robot/subsystems/LED.java | 77 ++----------------- 4 files changed, 19 insertions(+), 74 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 11f2719..4af5bd1 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -21,6 +21,7 @@ import frc.robot.constants.PhoenixDriveConstants.AlignTarget; import frc.robot.constants.ScoringConstants; import frc.robot.constants.VisionConstants; +import frc.robot.subsystems.LED; import frc.robot.subsystems.drive.PhoenixDrive; import frc.robot.subsystems.drive.PhoenixDrive.SysIdRoutineType; import frc.robot.subsystems.intake.IntakeIO; @@ -53,6 +54,7 @@ public class RobotContainer { ScoringSubsystem scoringSubsystem; IntakeSubsystem intakeSubsystem; + LED leds; CommandJoystick leftJoystick = new CommandJoystick(0); CommandJoystick rightJoystick = new CommandJoystick(1); @@ -114,6 +116,12 @@ private void configureSubsystems() { if (FeatureFlags.runIntake) { initIntake(); } + if (FeatureFlags.runScoring + && FeatureFlags.runIntake + && FeatureFlags.runVision + && FeatureFlags.runLEDS) { + initLEDs(); + } } private void initDrive() { @@ -205,6 +213,10 @@ private void initScoring() { } } + private void initLEDs() { + leds = new LED(scoringSubsystem, intakeSubsystem); + } + private void configureSuppliers() { if (FeatureFlags.runScoring) { Supplier poseSupplier; diff --git a/src/main/java/frc/robot/constants/FeatureFlags.java b/src/main/java/frc/robot/constants/FeatureFlags.java index 3e14c0c..6058022 100644 --- a/src/main/java/frc/robot/constants/FeatureFlags.java +++ b/src/main/java/frc/robot/constants/FeatureFlags.java @@ -8,4 +8,5 @@ public final class FeatureFlags { public static final boolean runLocalizer = false; public static final boolean runIntake = true; public static final boolean runScoring = true; + public static final boolean runLEDS = true; } diff --git a/src/main/java/frc/robot/constants/LEDConstants.java b/src/main/java/frc/robot/constants/LEDConstants.java index d113c5b..309b8af 100644 --- a/src/main/java/frc/robot/constants/LEDConstants.java +++ b/src/main/java/frc/robot/constants/LEDConstants.java @@ -4,6 +4,5 @@ public class LEDConstants { public static final int ledPort = 0; - public static final int ledLength = 17; - + public static final int ledLength = 30; } diff --git a/src/main/java/frc/robot/subsystems/LED.java b/src/main/java/frc/robot/subsystems/LED.java index 7f18d9e..5d2d89b 100644 --- a/src/main/java/frc/robot/subsystems/LED.java +++ b/src/main/java/frc/robot/subsystems/LED.java @@ -5,10 +5,11 @@ import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.constants.LEDConstants; +import frc.robot.constants.ModeConstants; import frc.robot.subsystems.intake.IntakeSubsystem; import frc.robot.subsystems.scoring.ScoringSubsystem; import java.util.function.Supplier; -import frc.robot.constants.LEDConstants; public class LED extends SubsystemBase { @@ -55,7 +56,7 @@ public void periodic() { if (!enabled) { // LEDs left cleared if not enabled } else if (DriverStation.isDisabled()) { - if (Constants.currentMode == Mode.REAL) { + if (ModeConstants.currentMode == ModeConstants.Mode.REAL) { rainbow(); if (!visionWorkingSupplier.get()) { @@ -84,77 +85,9 @@ public void periodic() { ledBuffer.setRGB(i, 0, 0, 255 / 3); } } - - // // idle - // if (scoringSubsystem.getCurrentState() == ScoringState.IDLE) { - // if (Constants.currentMode == Mode.REAL) - // setFlashingColorSection( - // 0, ledcount, new int[] {105, 29, 16}, new int[] {255, 123, 0}); - // else SmartDashboard.putString("current task", "idle"); - // } - - // // intake - // if (scoringSubsystem.getCurrentState() == ScoringState.INTAKE) { - // if (scoringSubsystem.hasNote()) { - // if (Constants.currentMode == Mode.REAL) - // setSolidColorSection(0, ledcount, new int[] {255, 174, 0}); - // else SmartDashboard.putString("current task", "intake, has note"); - // } else { - // if (Constants.currentMode == Mode.REAL) - // setFlashingColorSection( - // 0, ledcount, new int[] {255, 174, 0}, new int[] {0, 0, 0}); - // else SmartDashboard.putString("current task", "intake"); - // } - // } - - // // shooting amp - // if (scoringSubsystem.getCurrentState() == ScoringState.AMP_PRIME) { - // if (scoringSubsystem.readyToShoot()) { - // if (Constants.currentMode == Mode.REAL) - // setSolidColorSection(0, ledcount, new int[] {32, 227, 64}); - // else SmartDashboard.putString("current task", "amp, ready to shoot"); - // } else { - // if (Constants.currentMode == Mode.REAL) - // setFlashingColorSection( - // 0, ledcount, new int[] {32, 227, 64}, new int[] {0, 0, 0}); - // else SmartDashboard.putString("current task", "amp, preparing"); - // } - // } - - // // shooting speaker - // if (scoringSubsystem.getCurrentState() == ScoringState.PRIME) { - // int[] rgbCode = new int[3]; - // if (DriverStation.getAlliance().isEmpty() - // || DriverStation.getAlliance().get() == DriverStation.Alliance.Blue) { - // rgbCode[0] = 0; - // rgbCode[1] = 30; - // rgbCode[2] = 225; - // } else { - // rgbCode[0] = 225; - // rgbCode[1] = 0; - // rgbCode[2] = 0; - // } - - // if (scoringSubsystem.readyToShoot()) { - // if (Constants.currentMode == Mode.REAL) - // setSolidColorSection(0, ledcount, rgbCode); - // else SmartDashboard.putString("current task", "speaker, ready to shoot"); - // } else { - // if (Constants.currentMode == Mode.REAL) - // setFlashingColorSection(0, ledcount, rgbCode, new int[] {0, 0, 0}); - // else SmartDashboard.putString("current task", "speaker, preparing"); - // } - // } - - // // endgame - // if (scoringSubsystem.getCurrentState() == ScoringState.ENDGAME) { - // if (Constants.currentMode == Mode.REAL) - // setSolidColorSection(0, ledcount, new int[] {140, 0, 255}); - // else SmartDashboard.putString("current task", "endgame"); - // } } - if (Constants.currentMode == Mode.REAL) { + if (ModeConstants.currentMode == ModeConstants.Mode.REAL) { led.setData(ledBuffer); } } @@ -197,4 +130,4 @@ private void rainbow() { offset += rainbowSpeed; offset %= 180; } -} \ No newline at end of file +}