diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index d5ab37e..933908d 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -7,6 +7,8 @@ package frc4388.robot; +import frc4388.utility.LEDPatterns; + /** * The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean * constants. This class should not be used for any other purpose. All constants should be @@ -25,6 +27,8 @@ public final class Constants { public static final class LEDConstants { public static final int LED_SPARK_ID = 0; + + public static final LEDPatterns DEFAULT_PATTERN = LEDPatterns.FOREST_WAVES; } public static final class OIConstants { diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index ee3506c..5421acf 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -13,9 +13,9 @@ import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.button.JoystickButton; import frc4388.robot.Constants.*; -import frc4388.robot.commands.LED.UpdateLED; import frc4388.robot.subsystems.Drive; import frc4388.robot.subsystems.LED; +import frc4388.utility.LEDPatterns; import frc4388.utility.controller.IHandController; import frc4388.utility.controller.XboxController; @@ -47,7 +47,7 @@ public class RobotContainer { getDriverController().getLeftYAxis(), getDriverController().getRightXAxis()))); // continually sends updates to the Blinkin LED controller to keep the lights on - m_robotLED.setDefaultCommand(new UpdateLED(m_robotLED)); + m_robotLED.setDefaultCommand(new RunCommand(() -> m_robotLED.updateLED())); } /** @@ -58,11 +58,15 @@ public class RobotContainer { */ private void configureButtonBindings() { /* Driver Buttons */ - //Test command to spin the robot while pressing A on the driver controller + // test command to spin the robot while pressing A on the driver controller new JoystickButton(getDriverJoystick(), XboxController.A_BUTTON) .whileHeld(() -> m_robotDrive.driveWithInput(0, 1)); /* Operator Buttons */ + // activates "Lit Mode" + new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON) + .whenPressed(() -> m_robotLED.setPattern(LEDPatterns.LAVA_RAINBOW)) + .whenReleased(() -> m_robotLED.setPattern(LEDConstants.DEFAULT_PATTERN)); } /** diff --git a/src/main/java/frc4388/robot/commands/LED/SetLEDPattern.java b/src/main/java/frc4388/robot/commands/LED/SetLEDPattern.java deleted file mode 100644 index a7e793e..0000000 --- a/src/main/java/frc4388/robot/commands/LED/SetLEDPattern.java +++ /dev/null @@ -1,37 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc4388.robot.commands.LED; - -import edu.wpi.first.wpilibj2.command.InstantCommand; - -import frc4388.robot.subsystems.LED; -import frc4388.utility.LEDPatterns; - -// NOTE: Consider using this command inline, rather than writing a subclass. For more -// information, see: -// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html -public class SetLEDPattern extends InstantCommand { - - private final LED m_led; - public static LEDPatterns m_pattern; - - /** - * Add your docs here. - */ - public SetLEDPattern(LED subsystem, LEDPatterns pattern) { - m_led = subsystem; - m_pattern = pattern; - addRequirements(m_led); - } - - // Called when the command is initially scheduled. - @Override - public void initialize() { - m_led.setPattern(m_pattern); - } -} diff --git a/src/main/java/frc4388/robot/commands/LED/UpdateLED.java b/src/main/java/frc4388/robot/commands/LED/UpdateLED.java deleted file mode 100644 index 7baab4e..0000000 --- a/src/main/java/frc4388/robot/commands/LED/UpdateLED.java +++ /dev/null @@ -1,47 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc4388.robot.commands.LED; - -import edu.wpi.first.wpilibj2.command.CommandBase; - -import frc4388.robot.subsystems.LED; - -public class UpdateLED extends CommandBase { - - private final LED m_LED; - - /** - * Creates a new UpdateLED that continually runs updateLED in the LED subsystem. - */ - public UpdateLED(LED subsystem) { - m_LED = subsystem; - addRequirements(m_LED); - } - - // 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() { - m_LED.updateLED(); - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc4388/robot/subsystems/LED.java b/src/main/java/frc4388/robot/subsystems/LED.java index 1b9008c..a68c124 100644 --- a/src/main/java/frc4388/robot/subsystems/LED.java +++ b/src/main/java/frc4388/robot/subsystems/LED.java @@ -28,7 +28,7 @@ public class LED extends SubsystemBase { */ public LED(){ LEDController = new Spark(LEDConstants.LED_SPARK_ID); - setPattern(LEDPatterns.FOREST_WAVES); + setPattern(LEDConstants.DEFAULT_PATTERN); LEDController.set(currentLED); System.err.println("In the Beginning, there was Joe.\nAnd he said, 'Let there be LEDs.'\nAnd it was good."); }