From 6772023b8e05b414931d85a91ba7837a39141b03 Mon Sep 17 00:00:00 2001 From: BrodyKarr <145169276+BrodyKarr@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:29:03 -0700 Subject: [PATCH] Made LEDs not keep sending commands if its a repeat color --- src/main/java/frc/robot/RobotContainer.java | 33 +++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 81ce24dc..21b9aee7 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -88,7 +88,9 @@ public class RobotContainer implements Logged { int[] rotationColor; int[] XTranslationColor; int[] YTranslationColor; - + int[] previousRotationColor; + int[] previousXTranslationColor; + int[] previousYTranslationColor; // Poses @Log.NT static Pose3d currentRobotPose; @@ -402,17 +404,24 @@ public void setAutoPlacementLEDs(Optional alliance) { subLEDs.setAnimationChunk(8, constLEDs.LED_NUMBER - 8, constLEDs.AUTO_ALIGNED_COLOR); } else { - subLEDs.setIndividualLED(rotationColor, 0); - subLEDs.setIndividualLED(rotationColor, 3); - subLEDs.setIndividualLED(rotationColor, 4); - subLEDs.setIndividualLED(rotationColor, 7); - - subLEDs.setIndividualLED(XTranslationColor, 1); - subLEDs.setIndividualLED(XTranslationColor, 2); - - subLEDs.setIndividualLED(YTranslationColor, 5); - subLEDs.setIndividualLED(YTranslationColor, 6); - subLEDs.clearAnimationChunk(8, constLEDs.LED_NUMBER - 8); + if (previousRotationColor != rotationColor) { + subLEDs.setIndividualLED(rotationColor, 0); + subLEDs.setIndividualLED(rotationColor, 3); + subLEDs.setIndividualLED(rotationColor, 4); + subLEDs.setIndividualLED(rotationColor, 7); + previousRotationColor = rotationColor; + } + if (previousXTranslationColor != XTranslationColor) { + subLEDs.setIndividualLED(XTranslationColor, 1); + subLEDs.setIndividualLED(XTranslationColor, 2); + previousXTranslationColor = XTranslationColor; + } + if (previousYTranslationColor != YTranslationColor) { + subLEDs.setIndividualLED(YTranslationColor, 5); + subLEDs.setIndividualLED(YTranslationColor, 6); + subLEDs.clearAnimationChunk(8, constLEDs.LED_NUMBER - 8); + previousYTranslationColor = YTranslationColor; + } } }