Skip to content

Commit

Permalink
small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
quackitsquinn committed Apr 3, 2024
1 parent 6974d0a commit d1a48e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static class LightStrips {

public static final class Colors {
/** The color for the lights when the robot is disabled. */
public static final Color DISABLED_COLOR = Color.fromHSV(15, 255, 100);
public static final Color DISABLED_COLOR = Color.fromHSV(15, 255, 50);

/** The color for the pulse during the boot sequence. */
public static final Color BOOT_SEQUENCE_PULSE_COLOR = Color.fromHSV(0, 0, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ public void initialize() {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
final int loopCount = 4;
if (firstStart) {
rainbowTick++;
for (int led = 0; led < ledCount; led++) {
robotLights.setColorLight(
led, Color.fromHSV((led + rainbowTick) % 180, 255, rainbowTick - led));
led, Color.fromHSV((led + rainbowTick) % 180, 255, (rainbowTick - led) / loopCount));
}
robotLights.flush();
if ((rainbowTick >= robotLights.getLength() * 2)) {
if ((rainbowTick >= robotLights.getLength() * loopCount)) {
firstStart = false;
robotLights.setStripColorRaw(Constants.LightStrips.Colors.BOOT_SEQUENCE_PULSE_COLOR);
robotLights.setStripColor(Constants.LightStrips.Colors.DISABLED_COLOR);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/frc/robot/subsystems/AddressableLightStrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

package frc.robot.subsystems;

import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
Expand All @@ -26,6 +28,7 @@ public class AddressableLightStrip extends SubsystemBase {
private int rainbowHue = 0;
private double fadeSpeed = Constants.LightStrips.STRIP_FADE_SPEED;
@Nullable private Color targetStripColor = null;
private GenericEntry targetLightEntry;

/**
* Creates a new AddressableLightStrip
Expand All @@ -36,8 +39,8 @@ public class AddressableLightStrip extends SubsystemBase {
public AddressableLightStrip(int pwmPort, int lightCount) {
this.ledStrip = new AddressableLED(pwmPort);
this.buffer = new AddressableLEDBuffer(lightCount);
this.targetLightEntry = Shuffleboard.getTab("Debug").add("Lights at target?", false).getEntry();
this.ledStrip.setLength(lightCount);
updateRainbow();
}

/**
Expand Down Expand Up @@ -196,7 +199,9 @@ public void resetFadeSpeed() {

@Override
public void periodic() {
if (!stripAtTargetColor()) {
boolean atTarget = stripAtTargetColor();
this.targetLightEntry.setBoolean(atTarget);
if (!atTarget) {
for (int led = 0; led < this.buffer.getLength(); led++) {
Color c = lerpColors(this.buffer.getLED(led), targetStripColor, fadeSpeed);
this.buffer.setLED(led, c);
Expand Down

0 comments on commit d1a48e7

Please sign in to comment.