From 7afa5bd93313897bc734d4653cdd97a035e731ce Mon Sep 17 00:00:00 2001 From: IanTapply22 Date: Wed, 10 Jan 2024 17:16:03 -0500 Subject: [PATCH] Fix leds not having the buffer data set --- .../java/frc/robot/subsystems/led/LEDSubsystem.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/led/LEDSubsystem.java b/src/main/java/frc/robot/subsystems/led/LEDSubsystem.java index 2107809..c7ecaf8 100644 --- a/src/main/java/frc/robot/subsystems/led/LEDSubsystem.java +++ b/src/main/java/frc/robot/subsystems/led/LEDSubsystem.java @@ -12,15 +12,23 @@ public class LEDSubsystem extends SubsystemBase { public static List ledSegments = new ArrayList<>(); + private static boolean initialized = false; + public static AddressableLED leds = new AddressableLED(0); // The PWM port the LEDs are plugged into public static AddressableLEDBuffer ledBuffer; // The buffer that holds the LED data @Override public void periodic() { + if (!initialized) { + System.out.println("LED Subsystem not initialized, initializing now..."); + this.initialize(); + } + // For every segment that is registered, run the periodic function for (LEDSegment ledSegment : ledSegments) { ledSegment.getLedMode().periodic(ledSegment.getSegmentIdentifier()); + leds.setData(ledBuffer); } } @@ -42,7 +50,11 @@ public void initialize() { leds.setLength( (ledSegments.size() * LEDConstants.ledsPerSegment)); // Set the length of the LED strip + leds.setData(ledBuffer); // Set the data of the LED strip + leds.start(); // Start the LED strip + + initialized = true; } /**