diff --git a/src/main/java/org/team1540/robot2024/Constants.java b/src/main/java/org/team1540/robot2024/Constants.java index d0d75e42..c1bf8e9a 100644 --- a/src/main/java/org/team1540/robot2024/Constants.java +++ b/src/main/java/org/team1540/robot2024/Constants.java @@ -20,7 +20,7 @@ public final class Constants { private static final Mode simMode = Mode.SIM; // Can also be Mode.REPLAY public static final Mode currentMode = Robot.isReal() ? Mode.REAL : simMode; - public static final int LED_STRIP_PORT_PWM = 1; + public static final int LED_STRIP_PORT_PWM = 9; public static final int LED_STRIP_LENGTH= 80; public enum Mode { /** diff --git a/src/main/java/org/team1540/robot2024/Robot.java b/src/main/java/org/team1540/robot2024/Robot.java index 62feab58..9f9f1772 100644 --- a/src/main/java/org/team1540/robot2024/Robot.java +++ b/src/main/java/org/team1540/robot2024/Robot.java @@ -11,6 +11,11 @@ import org.littletonrobotics.junction.wpilog.WPILOGReader; import org.littletonrobotics.junction.wpilog.WPILOGWriter; import org.team1540.robot2024.subsystems.led.*; +import org.team1540.robot2024.subsystems.led.patterns.LedPatternFlame; +import org.team1540.robot2024.subsystems.led.patterns.LedPatternRSLState; +import org.team1540.robot2024.subsystems.led.patterns.LedPatternRainbow; +import org.team1540.robot2024.subsystems.led.patterns.SimpleLedPattern; +import org.team1540.robot2024.util.LoggedTunableNumber; import org.team1540.robot2024.util.MechanismVisualiser; /** @@ -23,6 +28,10 @@ public class Robot extends LoggedRobot { private Command autonomousCommand; private RobotContainer robotContainer; + LoggedTunableNumber led_r = new LoggedTunableNumber("led/r", 0); + LoggedTunableNumber led_g = new LoggedTunableNumber("led/g", 0); + LoggedTunableNumber led_b = new LoggedTunableNumber("led/b", 0); + /** * This function is run when the robot is first started up and should be used for any * initialization code. @@ -104,8 +113,7 @@ public void robotPeriodic() { */ @Override public void disabledInit() { - robotContainer.leds.setPattern(Leds.Zone.ZONE1, SimpleLedPattern.solid(Color.kBlueViolet)); - robotContainer.leds.setPattern(Leds.Zone.ZONE2, SimpleLedPattern.solid(Color.kPaleVioletRed)); + robotContainer.leds.setPattern(Leds.Zone.ELEVATOR_BACK, new LedPatternFlame()); } /** @@ -120,7 +128,7 @@ public void disabledPeriodic() { */ @Override public void autonomousInit() { - robotContainer.leds.setPattern(Leds.Zone.ZONE1,SimpleLedPattern.alternating(Color.kBlueViolet, Color.kCrimson)); + robotContainer.leds.setPattern(Leds.Zone.ELEVATOR_BACK,LedPatternRSLState.matchingColors()); autonomousCommand = robotContainer.getAutonomousCommand(); // schedule the autonomous command (example) if (autonomousCommand != null) { @@ -164,8 +172,7 @@ public void teleopPeriodic() { */ @Override public void testInit() { - robotContainer.leds.setPattern(Leds.Zone.ZONE1,new LedPatternFlame(82)); - robotContainer.leds.setPattern(Leds.Zone.ZONE2,new LedPatternFlame(82)); + robotContainer.leds.setPattern(Leds.Zone.ELEVATOR_BACK,new LedPatternRainbow(1)); // Cancels all running commands at the start of test mode. CommandScheduler.getInstance().cancelAll(); } @@ -175,6 +182,7 @@ public void testInit() { */ @Override public void testPeriodic() { + robotContainer.leds.setPattern(Leds.Zone.ELEVATOR_BACK,SimpleLedPattern.solid(new Color(led_r.get(), led_g.get(), led_b.get()))); } /** diff --git a/src/main/java/org/team1540/robot2024/RobotContainer.java b/src/main/java/org/team1540/robot2024/RobotContainer.java index 20ef767d..73acdd58 100644 --- a/src/main/java/org/team1540/robot2024/RobotContainer.java +++ b/src/main/java/org/team1540/robot2024/RobotContainer.java @@ -169,11 +169,11 @@ public RobotContainer() { } private void configureLedBindings() { - leds.setFatalPattern(new LedPatternFlame()); + leds.setFatalPattern(LedPatternFlame::new); new Trigger(DriverStation::isDSAttached) .onTrue(Commands.runOnce(leds::clearFatalPattern) .ignoringDisable(true)) - .onFalse(Commands.runOnce(() -> leds.setFatalPattern(new LedPatternFlame())) + .onFalse(Commands.runOnce(() -> leds.setFatalPattern(LedPatternFlame::new)) .ignoringDisable(true)); } /** diff --git a/src/main/java/org/team1540/robot2024/subsystems/led/Leds.java b/src/main/java/org/team1540/robot2024/subsystems/led/Leds.java index c20b589d..8f7b7bdc 100644 --- a/src/main/java/org/team1540/robot2024/subsystems/led/Leds.java +++ b/src/main/java/org/team1540/robot2024/subsystems/led/Leds.java @@ -7,6 +7,8 @@ import org.team1540.robot2024.subsystems.led.patterns.LedPattern; +import java.util.function.Supplier; + import static org.team1540.robot2024.Constants.LED_STRIP_PORT_PWM; public class Leds extends SubsystemBase { @@ -20,8 +22,7 @@ public Leds() { strip.setData(ledBuffer); strip.start(); - buffers[Zone.ZONE1.ordinal()] = new ZonedAddressableLEDBuffer(ledBuffer, 1, 40, false); - buffers[Zone.ZONE2.ordinal()] = new ZonedAddressableLEDBuffer(ledBuffer, 40, 80, false); + buffers[Zone.ELEVATOR_BACK.ordinal()] = new ZonedAddressableLEDBuffer(ledBuffer, 1, 41, false); for (int i = 0; i < ZONE_COUNT;i++) { patterns[i] = new LedTriager(); } @@ -50,27 +51,24 @@ public void clearPattern(Zone zone, PatternCriticality criticality) { patterns[zone.ordinal()].clearPattern(criticality); } - public void setFatalPattern(LedPattern pattern) { - System.out.println("Setting criticality"); + public void setFatalPattern(Supplier patternSupplier) { for (int i = 0; i