Skip to content

Commit

Permalink
Fix leds not having the buffer data set (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Tapply authored Jan 10, 2024
1 parent 20eae65 commit 1109061
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/frc/robot/subsystems/led/LEDSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ public class LEDSubsystem extends SubsystemBase {

public static List<LEDSegment> 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);
}
}

Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 1109061

Please sign in to comment.