Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NoraZitnick committed Dec 5, 2024
1 parent 18b20e3 commit 31c447c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
5 changes: 0 additions & 5 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

package frc.robot;

import java.util.concurrent.LinkedTransferQueue;

import edu.wpi.first.wpilibj2.command.FunctionalCommand;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.WaitCommand;
Expand Down Expand Up @@ -59,7 +57,6 @@ public RobotContainer() {
Accelerator accelerator = null;
Serializer serializer = null;
RollerSensorsIO rollerSensorsIO = null;


if (Constants.getRobotMode() != Mode.REPLAY) {
switch (Constants.getRobotType()) {
Expand Down Expand Up @@ -138,8 +135,6 @@ private void configureBindings() {
driverA.getLeftTriggerAxis() - driverA.getRightTriggerAxis());
})
.withName("Drive Teleop"));



driverA.start().onTrue(swerve.zeroGyroCommand());

Expand Down
64 changes: 33 additions & 31 deletions src/main/java/frc/robot/subsystems/LightsSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,39 @@
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class LightsSubsystem extends SubsystemBase{
private final AddressableLED lights;
private final AddressableLEDBuffer buffer;
private int firstPixelHue;
public LightsSubsystem() {
lights = new AddressableLED(34);
// turn off the LEDs when the can chain fails
buffer = new AddressableLEDBuffer(227);
lights.setLength(buffer.getLength());
lights.setData(buffer);
lights.start();
firstPixelHue = 0;
}
private void rainbow() {
// For every pixel
for (var i = 0; i < buffer.getLength(); i++) {
// Calculate the hue - hue is easier for rainbows because the color
// shape is a circle so only one value needs to precess
final var hue = (firstPixelHue + (i * 180 / buffer.getLength())) % 180;
// Set the value
buffer.setHSV(i, hue, 255, 128);
}
// Increase by to make the rainbow "move"
firstPixelHue += 3;
// Check bounds
firstPixelHue %= 180;
}
public class LightsSubsystem extends SubsystemBase {
private final AddressableLED lights;
private final AddressableLEDBuffer buffer;
private int firstPixelHue;

@Override
public void periodic(){
rainbow();
lights.setData(buffer);
public LightsSubsystem() {
lights = new AddressableLED(34);
// turn off the LEDs when the can chain fails
buffer = new AddressableLEDBuffer(227);
lights.setLength(buffer.getLength());
lights.setData(buffer);
lights.start();
firstPixelHue = 0;
}

private void rainbow() {
// For every pixel
for (var i = 0; i < buffer.getLength(); i++) {
// Calculate the hue - hue is easier for rainbows because the color
// shape is a circle so only one value needs to precess
final var hue = (firstPixelHue + (i * 180 / buffer.getLength())) % 180;
// Set the value
buffer.setHSV(i, hue, 255, 128);
}
// Increase by to make the rainbow "move"
firstPixelHue += 3;
// Check bounds
firstPixelHue %= 180;
}

@Override
public void periodic() {
rainbow();
lights.setData(buffer);
}
}

0 comments on commit 31c447c

Please sign in to comment.