-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
will be removed in the next update as i don't like redoing what the command scheduler already did. so will create a singleton LEDSubsystem and get the subsystem trough the LEDSystem.java by doing `LEDSystem.getInstance()`
- Loading branch information
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |