From e6e16b891e34c5c76d9a9b1c9b0ef42597e406af Mon Sep 17 00:00:00 2001 From: wildercayden Date: Tue, 21 Oct 2025 18:54:32 -0400 Subject: [PATCH] added LED --- .wpilib/wpilib_preferences.json | 2 +- simgui-ds.json | 92 ++++++++++++++++++++ src/main/java/frc/robot/RobotContainer.java | 13 ++- src/main/java/frc/robot/subsystems/LEDs.java | 46 ++++++++-- 4 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 simgui-ds.json diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json index 7004876..57c8058 100644 --- a/.wpilib/wpilib_preferences.json +++ b/.wpilib/wpilib_preferences.json @@ -2,5 +2,5 @@ "enableCppIntellisense": false, "currentLanguage": "java", "projectYear": "2025", - "teamNumber": 2648 + "teamNumber": 9998 } \ No newline at end of file diff --git a/simgui-ds.json b/simgui-ds.json new file mode 100644 index 0000000..73cc713 --- /dev/null +++ b/simgui-ds.json @@ -0,0 +1,92 @@ +{ + "keyboardJoysticks": [ + { + "axisConfig": [ + { + "decKey": 65, + "incKey": 68 + }, + { + "decKey": 87, + "incKey": 83 + }, + { + "decKey": 69, + "decayRate": 0.0, + "incKey": 82, + "keyRate": 0.009999999776482582 + } + ], + "axisCount": 3, + "buttonCount": 4, + "buttonKeys": [ + 90, + 88, + 67, + 86 + ], + "povConfig": [ + { + "key0": 328, + "key135": 323, + "key180": 322, + "key225": 321, + "key270": 324, + "key315": 327, + "key45": 329, + "key90": 326 + } + ], + "povCount": 1 + }, + { + "axisConfig": [ + { + "decKey": 74, + "incKey": 76 + }, + { + "decKey": 73, + "incKey": 75 + } + ], + "axisCount": 2, + "buttonCount": 4, + "buttonKeys": [ + 77, + 44, + 46, + 47 + ], + "povCount": 0 + }, + { + "axisConfig": [ + { + "decKey": 263, + "incKey": 262 + }, + { + "decKey": 265, + "incKey": 264 + } + ], + "axisCount": 2, + "buttonCount": 6, + "buttonKeys": [ + 260, + 268, + 266, + 261, + 269, + 267 + ], + "povCount": 0 + }, + { + "axisCount": 0, + "buttonCount": 0, + "povCount": 0 + } + ] +} diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 73ecb9e..5e84ad5 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,6 +4,8 @@ package frc.robot; +import static edu.wpi.first.units.Units.Second; + import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; @@ -11,6 +13,7 @@ import edu.wpi.first.wpilibj.util.Color; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.RunCommand; +import edu.wpi.first.wpilibj2.command.WaitCommand; import edu.wpi.first.wpilibj2.command.button.CommandPS5Controller; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.Trigger; @@ -64,9 +67,15 @@ public class RobotContainer { Trigger highFiveTrigger = new Trigger(highFive::SwitchDigitalInput); - highFiveTrigger.whileTrue( - new RunCommand(() -> leds.setAll(Color.kRed), leds) + highFiveTrigger.onFalse( + leds.blinkColorchange(Color.kGreen, Color.kRed, Color.kBlue, 0.5, 2) + .andThen( + //new WaitCommand(5), + leds.setAll(Color.kBlack) + ) ); + + Shuffleboard.getTab("HighFive") diff --git a/src/main/java/frc/robot/subsystems/LEDs.java b/src/main/java/frc/robot/subsystems/LEDs.java index fecf99c..70148a7 100644 --- a/src/main/java/frc/robot/subsystems/LEDs.java +++ b/src/main/java/frc/robot/subsystems/LEDs.java @@ -37,15 +37,47 @@ public class LEDs extends SubsystemBase { ); } - public Command blinkColor(Color color, double delayTime) { - return Commands.repeatingSequence( - setAll(color), - new WaitCommand(delayTime), - setAll(Color.kBlack), - new WaitCommand(delayTime) - ); + + + + public Command blinkColor(Color color, double delayTime, int times) { + Command sequence = Commands.none(); // start with an empty command + + for (int i = 0; i < times; i++) { + sequence = Commands.sequence( + sequence, + setAll(color), + new WaitCommand(delayTime), + setAll(Color.kBlack), + new WaitCommand(delayTime) + ); + } + + return sequence; } + public Command blinkColorchange(Color color, Color color2, Color color3, double delayTime, int times) { + Command sequence = Commands.none(); // start with an empty command + + for (int i = 0; i < times; i++) { + sequence = Commands.sequence( + sequence, + setAll(color), + new WaitCommand(delayTime), + setAll(color2), + new WaitCommand(delayTime), + setAll(color3), + new WaitCommand(delayTime) + ); + } + + return sequence; + } + + + + + public Command setAll(Color color) { return runOnce(() -> { for(int i = 0; i < buffer.getLength(); i++) {