Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix led subsystem index out of bounds #67

Merged
merged 6 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ private void configureBindings() {
}

public RobotContainer() {
configureBindings();
ledSubsystem = new LEDSubsystem();
intakeSubsystem = new IntakeSubsystem(pdp);

configureBindings(); // configure bindings after we initialize our subsystems
}

public Command getAutonomousCommand() {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/frc/robot/subsystems/led/LEDSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public class LEDSubsystem extends SubsystemBase {

public static AddressableLED leds =
new AddressableLED(0); // The PWM port the LEDs are plugged into
public static AddressableLEDBuffer ledBuffer =
new AddressableLEDBuffer(
(ledSegments.size() * LEDConstants.ledsPerSegment)); // The buffer that holds the LED data
public static AddressableLEDBuffer ledBuffer; // The buffer that holds the LED data

@Override
public void periodic() {
Expand All @@ -34,6 +32,13 @@ public void initialize() {
ledSegments.add(LEDSegment.BackRight);
ledSegments.add(LEDSegment.FrontRight);

ledBuffer =
new AddressableLEDBuffer(
(ledSegments.size()
* LEDConstants
.ledsPerSegment)); // Set the buffer size after we know how many segments there
// are

leds.setLength(
(ledSegments.size() * LEDConstants.ledsPerSegment)); // Set the length of the LED strip

Expand Down