diff --git a/src/main/java/frc/robot/subsystems/LEDSubsystem.java b/src/main/java/frc/robot/subsystems/LEDSubsystem.java new file mode 100644 index 0000000..d16e068 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/LEDSubsystem.java @@ -0,0 +1,17 @@ +package frc.robot.subsystems; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Constants.LEDConstants; +import frc.utils.BetterLED; + +public class LEDSubsystem extends SubsystemBase { + BetterLED strip; + + public LEDSubsystem() { + strip = new BetterLED(LEDConstants.kLedPin, LEDConstants.kLedCount); + } + + public BetterLED getStrip() { + return strip; + } +} diff --git a/src/main/java/frc/robot/subsystems/LEDSystem.java b/src/main/java/frc/robot/subsystems/LEDSystem.java index 5e45804..8ecf41f 100644 --- a/src/main/java/frc/robot/subsystems/LEDSystem.java +++ b/src/main/java/frc/robot/subsystems/LEDSystem.java @@ -1,18 +1,51 @@ package frc.robot.subsystems; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.util.Color; import frc.robot.Constants.LEDConstants; import frc.utils.BetterLED; +import java.util.function.BooleanSupplier; public final class LEDSystem { private static final BetterLED strip = new BetterLED(LEDConstants.kLedPin, LEDConstants.kLedCount); + private static boolean isRunningACommand = false; + + public static void init() { + System.out.println("Startup LED System!"); + } public static void setLEDColorRGB(int r, int g, int b) { strip.fill(new Color(r, g, b)); } - public static void init() { - System.out.println("Startup LED System!"); + public static boolean isRunningACommand() { + return isRunningACommand; + } + + public static void setRunningACommand(boolean isRunningACommand) { + LEDSystem.isRunningACommand = isRunningACommand; + } + + public static void addTimedCommand(double timeSeconds) { + isRunningACommand = true; + new Thread( + () -> { + Timer.delay(timeSeconds); + isRunningACommand = false; + }) + .start(); + } + + public static void addBooleanSupplierCommand(BooleanSupplier hasEnded) { + isRunningACommand = true; + new Thread( + () -> { + while (!hasEnded.getAsBoolean()) { + Timer.delay(0.1); + } + isRunningACommand = false; + }) + .start(); } }