From 6c410b88e724759d9d388931bf1fb0263d7688a7 Mon Sep 17 00:00:00 2001 From: Nate Bailey Date: Sat, 22 Feb 2025 08:13:18 -0500 Subject: [PATCH 1/4] [#191] update leds --- leds/ThunderStrip.java | 44 +++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/leds/ThunderStrip.java b/leds/ThunderStrip.java index f9fde96..e798033 100644 --- a/leds/ThunderStrip.java +++ b/leds/ThunderStrip.java @@ -48,21 +48,43 @@ public Command enableState(LEDStates state) { } /** - * @param state the state to enable + * @param state the state to enable * @param duration the duration to enable the state for - * @return a command that enables the state - */ - public Command enableStateFor(LEDStates state, int duration) { - return new StartEndCommand(() -> { - if (!unusedStates.contains(state)) { + * @return a command that enables the state + */ + public Command enableStateFor(LEDStates state, int duration) { + return new StartEndCommand(() -> { + if (!unusedStates.contains(state)) { states.add(state); } - }, () -> { - states.remove(state); - }) + }, () -> { + states.remove(state); + }) .withDeadline(new WaitCommand(duration)) .ignoringDisable(true); - } + } + + /** + * Sets the current state of the LED strip + * + * @param state the state to set + */ + public void setState(LEDStates state, boolean enabled) { + if (enabled) { + if (!unusedStates.contains(state)) { + states.add(state); + } + } else { + states.remove(state); + } + } + + /** + * @return the current state of the LED strip + */ + public LEDStates getState() { + return states.peek(); + } /** * Updates the LED strip @@ -71,7 +93,7 @@ public void update() { if (states.isEmpty()) { defaultLEDs(); } else { - updateLEDs(states.peek()); + updateLEDs(getState()); } } From 08c94ce02de9d2fd817af9b437cf30ed73ab2457 Mon Sep 17 00:00:00 2001 From: Nate Bailey Date: Sat, 22 Feb 2025 08:53:35 -0500 Subject: [PATCH 2/4] [#191] change set state to a command --- leds/ThunderStrip.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/leds/ThunderStrip.java b/leds/ThunderStrip.java index e798033..fc2f608 100644 --- a/leds/ThunderStrip.java +++ b/leds/ThunderStrip.java @@ -7,6 +7,7 @@ import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.StartEndCommand; import edu.wpi.first.wpilibj2.command.WaitCommand; import frc.robot.Constants.LEDConstants.LEDStates; @@ -68,15 +69,19 @@ public Command enableStateFor(LEDStates state, int duration) { * Sets the current state of the LED strip * * @param state the state to set + * @param enabled whether to enable or disable the state + * @return an InstantCommand that sets the state */ - public void setState(LEDStates state, boolean enabled) { - if (enabled) { - if (!unusedStates.contains(state)) { - states.add(state); + public Command setState(LEDStates state, boolean enabled) { + return new InstantCommand(() -> { + if (enabled) { + if (!unusedStates.contains(state)) { + states.add(state); + } + } else { + states.remove(state); } - } else { - states.remove(state); - } + }); } /** From cd9167f88414bf150167b48efd4c185f094af56f Mon Sep 17 00:00:00 2001 From: Nate Bailey Date: Mon, 24 Feb 2025 19:37:09 -0500 Subject: [PATCH 3/4] [#191] increase blink speed --- leds/ThunderStrip.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leds/ThunderStrip.java b/leds/ThunderStrip.java index fc2f608..e2eccc0 100644 --- a/leds/ThunderStrip.java +++ b/leds/ThunderStrip.java @@ -153,7 +153,7 @@ public void swirl(LightningColors color1, LightningColors color2, int segmentSiz * @param hue the hue to blink */ public void blink(LightningColors color) { - if ((int) (Timer.getFPGATimestamp() * 10) % 2 == 0) { + if ((int) (Timer.getFPGATimestamp() * 20) % 2 == 0) { // Increased the multiplier to 20 for faster strobe leds.setSolidHSV(color, length, startIndex); } else { leds.setSolidHSV(LightningColors.BLACK, length, startIndex); From c4003f2f74549097f0e2bc76f0d23c5651ebcbe7 Mon Sep 17 00:00:00 2001 From: Nate Bailey Date: Tue, 25 Feb 2025 19:54:17 -0500 Subject: [PATCH 4/4] [#191] fix color values --- leds/LightningColors.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/leds/LightningColors.java b/leds/LightningColors.java index 130c659..a3d355c 100644 --- a/leds/LightningColors.java +++ b/leds/LightningColors.java @@ -4,8 +4,8 @@ public enum LightningColors { BLACK(0, 0, 0), WHITE(0, 255, 255), RED(0, 255, 255), - ORANGE(15, 255, 255), - YELLOW(30, 255, 255), + ORANGE(5, 255, 255), + YELLOW(15, 255, 255), GREEN(60, 255, 255), LIGHT_BLUE(100, 255, 255), BLUE(120, 255, 255),