From b07e1f8b213319a6083372fa0596670c75ee8651 Mon Sep 17 00:00:00 2001 From: 0x5b62656e5d Date: Thu, 13 Mar 2025 17:33:42 +0800 Subject: [PATCH] Update LED flashing states --- .../robot/subsystems/LEDStrip/ArmStrip.java | 100 ++++++++++++++---- 1 file changed, 80 insertions(+), 20 deletions(-) diff --git a/src/main/java/raidzero/robot/subsystems/LEDStrip/ArmStrip.java b/src/main/java/raidzero/robot/subsystems/LEDStrip/ArmStrip.java index 15d74de..04d4dca 100644 --- a/src/main/java/raidzero/robot/subsystems/LEDStrip/ArmStrip.java +++ b/src/main/java/raidzero/robot/subsystems/LEDStrip/ArmStrip.java @@ -96,14 +96,14 @@ private void updateStates() { * The E-stopped loop of the CANdle LED strip */ private void loopEstopped() { - if (animationApplied || animation2Applied || animation3Applied) { + if (animation2Applied || animation3Applied) { resetAnimation(); } if (!animationApplied) { candle.clearAnimation(0); candle.clearAnimation(1); - candle.animate(new StrobeAnimation(25, 0, 0, 0, 0.001, -1)); + candle.animate(new StrobeAnimation(255, 0, 0, 0, 0.001, -1)); animationApplied = true; animation2Applied = false; animation3Applied = false; @@ -114,11 +114,24 @@ private void loopEstopped() { * The disabled loop of the CANdle LED strip */ private void loopDisabled() { - if (ClimbJoint.system().isDeployed().getAsBoolean()) { + if (DriverStation.isAutonomous() && DriverStation.getMatchTime() > 0.0) { + if (animation2Applied || animation3Applied) { + resetAnimation(); + } + + if (!animationApplied) { + candle.clearAnimation(0); + candle.clearAnimation(1); + candle.animate(new StrobeAnimation(255, 0, 0, 0, 0.001, -1)); + animationApplied = true; + animation2Applied = false; + animation3Applied = false; + } + } else if (ClimbJoint.system().isDeployed().getAsBoolean()) { if (!animation3Applied) { candle.clearAnimation(0); candle.clearAnimation(1); - candle.animate(new RainbowAnimation(255, 0.75, -1)); + candle.animate(new RainbowAnimation(255, 1.0, -1)); animationApplied = false; animation2Applied = false; animation3Applied = true; @@ -143,11 +156,15 @@ private void loopDisabled() { if (strobeTimer.hasElapsed(strobeInterval)) { if (strobeAlternate) { + candle.setLEDs(255, 0, 0, 0, 0, 4); + candle.setLEDs(0, 0, 0, 0, 4, 4); candle.setLEDs(255, 0, 0, 0, 8, 25); - candle.setLEDs(0, 0, 0, 0, 33, 25); + candle.setLEDs(0, 0, 0, 0, 33, 27); } else { + candle.setLEDs(0, 0, 0, 0, 0, 4); + candle.setLEDs(255, 0, 0, 0, 4, 4); candle.setLEDs(0, 0, 0, 0, 8, 25); - candle.setLEDs(255, 0, 0, 0, 33, 25); + candle.setLEDs(255, 0, 0, 0, 33, 27); } strobeAlternate = !strobeAlternate; @@ -172,13 +189,21 @@ private void loopDisabled() { * The autonomous loop of the CANdle LED strip */ private void loopAutonomous() { + if (animationApplied || animation2Applied || animation3Applied) { + resetAnimation(); + } + if (strobeTimer.hasElapsed(strobeInterval)) { if (strobeAlternate) { - candle.setLEDs(255, 165, 0, 0, 0, 25); - candle.setLEDs(0, 255, 0, 0, 33, 25); + candle.setLEDs(255, 165, 0, 0, 0, 4); + candle.setLEDs(0, 255, 0, 0, 4, 4); + candle.setLEDs(255, 165, 0, 0, 8, 25); + candle.setLEDs(0, 255, 0, 0, 33, 27); } else { - candle.setLEDs(0, 255, 0, 0, 0, 25); - candle.setLEDs(255, 165, 0, 0, 33, 25); + candle.setLEDs(0, 255, 0, 0, 0, 4); + candle.setLEDs(255, 165, 0, 0, 4, 4); + candle.setLEDs(0, 255, 0, 0, 8, 25); + candle.setLEDs(255, 165, 0, 0, 33, 27); } strobeAlternate = !strobeAlternate; @@ -197,7 +222,7 @@ private void loopTeleop() { candle.clearAnimation(0); candle.clearAnimation(1); candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Backward, 8), 0); - candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Forward, 33), 1); + candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 27, Direction.Forward, 33), 1); animationApplied = false; animation2Applied = true; animation3Applied = false; @@ -207,7 +232,7 @@ private void loopTeleop() { candle.clearAnimation(0); candle.clearAnimation(1); candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Forward, 8), 0); - candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Backward, 33), 1); + candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 27, Direction.Backward, 33), 1); animationApplied = false; animation2Applied = true; animation3Applied = false; @@ -219,11 +244,15 @@ private void loopTeleop() { if (strobeTimer.hasElapsed(strobeInterval)) { if (strobeAlternate) { + candle.setLEDs(0, 255, 0, 0, 0, 4); + candle.setLEDs(255, 0, 0, 0, 4, 4); candle.setLEDs(0, 255, 0, 0, 8, 25); - candle.setLEDs(255, 0, 0, 0, 33, 25); + candle.setLEDs(255, 0, 0, 0, 33, 27); } else { + candle.setLEDs(255, 0, 0, 0, 0, 4); + candle.setLEDs(0, 255, 0, 0, 4, 4); candle.setLEDs(255, 0, 0, 0, 8, 25); - candle.setLEDs(0, 255, 0, 0, 33, 25); + candle.setLEDs(0, 255, 0, 0, 33, 27); } strobeAlternate = !strobeAlternate; @@ -236,11 +265,15 @@ private void loopTeleop() { if (strobeTimer.hasElapsed(strobeInterval)) { if (strobeAlternate) { + candle.setLEDs(255, 10, 250, 0, 0, 4); + candle.setLEDs(255, 0, 0, 0, 4, 4); candle.setLEDs(255, 10, 250, 0, 8, 25); - candle.setLEDs(255, 0, 0, 0, 33, 25); + candle.setLEDs(255, 0, 0, 0, 33, 27); } else { + candle.setLEDs(255, 0, 0, 0, 0, 4); + candle.setLEDs(255, 10, 250, 0, 4, 4); candle.setLEDs(255, 0, 0, 0, 8, 25); - candle.setLEDs(255, 10, 250, 0, 33, 25); + candle.setLEDs(255, 10, 250, 0, 33, 27); } strobeAlternate = !strobeAlternate; @@ -253,11 +286,15 @@ private void loopTeleop() { if (strobeTimer.hasElapsed(strobeInterval)) { if (strobeAlternate) { + candle.setLEDs(255, 10, 250, 0, 0, 4); + candle.setLEDs(0, 255, 0, 0, 4, 4); candle.setLEDs(255, 10, 250, 0, 8, 25); - candle.setLEDs(0, 255, 0, 0, 33, 25); + candle.setLEDs(0, 255, 0, 0, 33, 27); } else { + candle.setLEDs(0, 255, 0, 0, 0, 4); + candle.setLEDs(255, 10, 250, 0, 4, 4); candle.setLEDs(0, 255, 0, 0, 8, 25); - candle.setLEDs(255, 10, 250, 0, 33, 25); + candle.setLEDs(255, 10, 250, 0, 33, 27); } strobeAlternate = !strobeAlternate; @@ -270,11 +307,15 @@ private void loopTeleop() { if (strobeTimer.hasElapsed(strobeInterval)) { if (strobeAlternate) { + candle.setLEDs(255, 10, 250, 0, 0, 4); + candle.setLEDs(0, 0, 0, 0, 4, 4); candle.setLEDs(255, 10, 250, 0, 8, 25); - candle.setLEDs(0, 0, 0, 0, 33, 25); + candle.setLEDs(0, 0, 0, 0, 33, 27); } else { + candle.setLEDs(0, 0, 0, 0, 0, 4); + candle.setLEDs(255, 10, 250, 0, 4, 4); candle.setLEDs(0, 0, 0, 0, 8, 25); - candle.setLEDs(255, 10, 250, 0, 33, 25); + candle.setLEDs(255, 10, 250, 0, 33, 27); } strobeAlternate = !strobeAlternate; @@ -313,6 +354,25 @@ public void matchEndAnimation() { candle.animate(new RainbowAnimation(255, 0.75, -1)); } + /** + * Sets the LED to red, green, blue in alternating sequence + */ + private void testCandleSequence() { + candle.setLEDs(255, 0, 0, 0, 0, 5); + candle.setLEDs(0, 255, 0, 0, 5, 5); + candle.setLEDs(0, 0, 255, 0, 10, 5); + candle.setLEDs(255, 0, 0, 0, 15, 5); + candle.setLEDs(0, 255, 0, 0, 20, 5); + candle.setLEDs(0, 0, 255, 0, 25, 5); + candle.setLEDs(255, 0, 0, 0, 30, 5); + candle.setLEDs(0, 255, 0, 0, 35, 5); + candle.setLEDs(0, 0, 255, 0, 40, 5); + candle.setLEDs(255, 0, 0, 0, 45, 5); + candle.setLEDs(0, 255, 0, 0, 50, 5); + candle.setLEDs(0, 0, 255, 0, 55, 5); + candle.setLEDs(255, 0, 0, 0, 60, 5); + } + /** * Gets a {@link CANdleConfiguration} for the CANdle LED strip *