Skip to content

Commit 979b5f3

Browse files
committed
leds su
1 parent 673c931 commit 979b5f3

File tree

5 files changed

+59
-10
lines changed

5 files changed

+59
-10
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ public static class LEDConstants {
316316
public static final int PWM_PORT = 0;
317317
public static final int FRONT_LEFT_SIZE = 12;
318318
public static final int FRONT_RIGHT_SIZE = 12;
319+
public static final int STATUS_DEDICATED_SIZE = 2;
319320
public static final int BACK_LEFT_SIZE = 14;
320321
public static final int BACK_RIGHT_SIZE = 14;
321322

src/main/java/frc/robot/RobotContainer.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import frc.robot.utils.led.SlidePattern;
3737
import frc.robot.utils.led.SolidPattern;
3838
import java.util.List;
39+
import java.util.concurrent.atomic.AtomicBoolean;
3940
import java.util.function.DoubleSupplier;
4041

4142
/**
@@ -75,6 +76,8 @@ public class RobotContainer {
7576
private final ListenableSendableChooser<Command> driveCommandChooser =
7677
new ListenableSendableChooser<>();
7778

79+
private final AtomicBoolean signalHumanPlayer = new AtomicBoolean(false);
80+
7881
public RobotContainer() {
7982
configureDriverBindings();
8083
configureOperatorBindings();
@@ -87,16 +90,44 @@ public RobotContainer() {
8790
}
8891

8992
private void configureLEDs() {
93+
// Default state for homing lights
94+
ledSubsystem.setStatusLight(0, Color.kRed);
95+
ledSubsystem.setStatusLight(1, Color.kRed);
96+
97+
// Set homing lights to state
98+
new Trigger(slapdownSuperstructure.getSlapdownRotationSubsystem()::isHomed).onFalse(
99+
Commands.runOnce(() -> {
100+
ledSubsystem.setStatusLight(0, Color.kRed);
101+
}).ignoringDisable(true).withName("SlapdownLEDStatusFalse")
102+
).onTrue(
103+
Commands.runOnce(() -> {
104+
ledSubsystem.setStatusLight(0, Color.kGreen);
105+
}).ignoringDisable(true).withName("SlapdownLEDStatusTrue")
106+
);
107+
new Trigger(elevatorSubsystem::isHomed).onFalse(
108+
Commands.runOnce(() -> {
109+
ledSubsystem.setStatusLight(1, Color.kRed);
110+
}).ignoringDisable(true).withName("ElevatorLEDStatusFalse")
111+
).onTrue(
112+
Commands.runOnce(() -> {
113+
ledSubsystem.setStatusLight(1, Color.kGreen);
114+
}).ignoringDisable(true).withName("ElevatorLEDStatusTrue")
115+
);
116+
90117
List<LEDState> ledStates =
91118
List.of(
119+
new LEDState(
120+
signalHumanPlayer::get,
121+
new AlternatePattern(0.5, Color.kOrange, Color.kBlack)),
92122
// Red blink if we have any faults
93123
new LEDState(
94124
() -> Alert.getDefaultGroup().hasAnyErrors(),
95125
new AlternatePattern(2.0, Color.kRed, Color.kBlack)),
126+
// Green if we can go under the stage
96127
new LEDState(
97128
() ->
98129
DriverStation.isTeleopEnabled()
99-
&& elevatorSubsystem.atBottomLimit()
130+
&& elevatorSubsystem.atBottom()
100131
&& wristSubsystem.atBottom(),
101132
new SolidPattern(Color.kGreen)),
102133
// Default disabled pattern
@@ -129,9 +160,14 @@ private void configureDriverBindings() {
129160
.whileTrue(
130161
Commands.parallel(
131162
IntakingCommands.intakeUntilDetected(
132-
intakeSubsystem, slapdownSuperstructure, transportSubsystem)));
133-
driverController.rightTrigger().onFalse(slapdownSuperstructure.setUpCommand());
163+
intakeSubsystem, slapdownSuperstructure, transportSubsystem))).onFalse(
164+
slapdownSuperstructure.setUpCommand()
165+
);
134166
driverController.circle().whileTrue(new LockModulesCommand(driveSubsystem).repeatedly());
167+
168+
driverController.a().onTrue(Commands.runOnce(() -> signalHumanPlayer.set(true))).onFalse(
169+
Commands.sequence(Commands.waitSeconds(1.5), Commands.runOnce(() -> signalHumanPlayer.set(false)))
170+
);
135171
}
136172

137173
private void configureOperatorBindings() {
@@ -140,7 +176,7 @@ private void configureOperatorBindings() {
140176
.onTrue(
141177
Commands.parallel(
142178
ScoringCommands.shootSetpointAmpCommand(shooterSubsystem),
143-
transportSubsystem.setVoltageCommand(12)));
179+
transportSubsystem.setVoltageCommand(10)));
144180
operatorController
145181
.triangle()
146182
.onTrue(

src/main/java/frc/robot/subsystems/elevator/ElevatorSubsystem.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public boolean atGoal() {
195195
return controller.atGoal();
196196
}
197197

198+
public boolean atBottom() {
199+
return controller.getGoal().position == ELEVATOR_MIN_HEIGHT && atGoal();
200+
}
201+
198202
public Command setFollowerCommand(double voltage) {
199203
return this.run(() -> elevatorMotorFollower.setVoltage(voltage));
200204
}

src/main/java/frc/robot/subsystems/led/LEDSubsystem.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class LEDSubsystem extends SubsystemBase {
1717
private final ParentAddressableLEDBuffer ledBuffer = new ParentAddressableLEDBuffer(TOTAL_SIZE);
1818
private final RaiderAddressableLEDBuffer[] splitBuffers;
1919
private final Pattern[] patterns;
20+
private final RaiderAddressableLEDBuffer statusDedicatedBuffer;
2021
private double patternStartTime = 0.0;
2122

2223
public LEDSubsystem() {
@@ -29,21 +30,24 @@ public LEDSubsystem() {
2930
}
3031
i += FRONT_LEFT_SIZE;
3132

32-
splitBuffers[1] = ledBuffer.split(i, i + BACK_LEFT_SIZE);
33-
splitBuffers[1] = splitBuffers[1].reversed();
33+
int effectiveBackLeftSize = BACK_LEFT_SIZE - STATUS_DEDICATED_SIZE;
34+
// Pre-concatenate a buffer for the status dedicated LEDs so it appears the saem as the rest
35+
splitBuffers[1] = ledBuffer.split(i, i + effectiveBackLeftSize).reversed().preConcatenate(new FakeLEDBuffer(STATUS_DEDICATED_SIZE));
3436
if (BACK_LEFT_SIZE < MAX_SIZE) {
3537
splitBuffers[1] = splitBuffers[1].concatenate(new FakeLEDBuffer(MAX_SIZE - BACK_LEFT_SIZE));
3638
}
37-
i += BACK_LEFT_SIZE;
39+
i += effectiveBackLeftSize;
40+
41+
statusDedicatedBuffer = ledBuffer.split(i, i + STATUS_DEDICATED_SIZE);
42+
i += STATUS_DEDICATED_SIZE;
3843

3944
splitBuffers[2] = ledBuffer.split(i, i + BACK_RIGHT_SIZE);
4045
if (BACK_RIGHT_SIZE < MAX_SIZE) {
4146
splitBuffers[2] = splitBuffers[2].concatenate(new FakeLEDBuffer(MAX_SIZE - BACK_RIGHT_SIZE));
4247
}
4348
i += BACK_RIGHT_SIZE;
4449

45-
splitBuffers[3] = ledBuffer.split(i, i + FRONT_RIGHT_SIZE);
46-
splitBuffers[3] = splitBuffers[3].reversed();
50+
splitBuffers[3] = ledBuffer.split(i, i + FRONT_RIGHT_SIZE).reversed();
4751
if (FRONT_RIGHT_SIZE < MAX_SIZE) {
4852
splitBuffers[3] = splitBuffers[3].concatenate(new FakeLEDBuffer(MAX_SIZE - FRONT_RIGHT_SIZE));
4953
}
@@ -59,6 +63,10 @@ public LEDSubsystem() {
5963
led.start();
6064
}
6165

66+
public void setStatusLight(int i, Color color) {
67+
statusDedicatedBuffer.setLED(i, color);
68+
}
69+
6270
public void setAllPattern(Pattern pattern, boolean forceRestart) {
6371
setPatterns(forceRestart, pattern, pattern, pattern, pattern);
6472
}

src/main/java/frc/robot/subsystems/slapdown/SlapdownRotationSubsystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private boolean atLimit() {
146146
return !rotationLimitSwitch.get();
147147
}
148148

149-
private boolean isHomed() {
149+
public boolean isHomed() {
150150
return isHomed;
151151
}
152152

0 commit comments

Comments
 (0)