Skip to content

Commit

Permalink
LED Subsys
Browse files Browse the repository at this point in the history
  • Loading branch information
AceiusRedshift committed Feb 29, 2024
1 parent 44d9f6b commit 55cbc85
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,8 @@ public static class VisionConstants {
public static final Transform3d CAMERA_POSE = new Transform3d(0.5, 0, 0.25, new Rotation3d());
public static final String CAMERA_NAME = "Arducam_OV9281_USB_Camera";
}

public static class LightConstants {
public static final int LED_CONTROLLER_PWM_SLOT = 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.commands;
package frc.robot.commands.deprecated;

import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
Expand Down Expand Up @@ -45,6 +45,8 @@ public void initialize() {
}

@Override
public boolean isFinished() { return true; }
public boolean isFinished() {
return true;
}

}
33 changes: 33 additions & 0 deletions src/main/java/frc/robot/subsystems/LightStrip.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class LightStrip extends SubsystemBase {
private AddressableLED ledStrip;
private AddressableLEDBuffer ledBuffer;

public LightStrip(AddressableLED ledstrip) {
ledStrip = ledstrip;
ledBuffer = new AddressableLEDBuffer(60);

// Docs say this is an expensive operation so future maintainers should avoid
// modifying this excessibely
ledStrip.setLength(ledBuffer.getLength());
ledStrip.setData(ledBuffer);

ledStrip.start();
}

public void setColor(int r, int g, int b) {
for (int i = 0; i < ledBuffer.getLength(); i++) {
ledBuffer.setRGB(i, r, g, b);
}
}

@Override
public void periodic() {
ledStrip.setData(ledBuffer);
}
}

0 comments on commit 55cbc85

Please sign in to comment.