Skip to content

Commit 6c1f3b0

Browse files
committed
Merge branch 'lights' of https://github.com/strykeforce/reefscape into lights
2 parents 0778ab5 + 5af022c commit 6c1f3b0

File tree

5 files changed

+214
-155
lines changed

5 files changed

+214
-155
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import edu.wpi.first.wpilibj2.command.Command;
1414
import edu.wpi.first.wpilibj2.command.Commands;
1515
import edu.wpi.first.wpilibj2.command.ConditionalCommand;
16+
import edu.wpi.first.wpilibj2.command.InstantCommand;
1617
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
1718
import edu.wpi.first.wpilibj2.command.button.Trigger;
1819
import frc.robot.commands.algae.IntakeAlgaeCommand;
@@ -135,7 +136,7 @@ public RobotContainer() {
135136
funnelSubsystem = new FunnelSubsystem(funnelIO);
136137

137138
ledIO = new LEDIO();
138-
ledSubsystem = new LEDSubsystem();
139+
ledSubsystem = new LEDSubsystem(ledIO);
139140

140141
visionSubsystem = new VisionSubsystem(driveSubsystem);
141142

@@ -171,6 +172,7 @@ private void configureTelemetry() {
171172
elevatorSubsystem.registerWith(telemetryService);
172173
funnelSubsystem.registerWith(telemetryService);
173174
biscuitSubsystem.registerWith(telemetryService);
175+
ledSubsystem.registerWith(telemetryService);
174176
telemetryService.start();
175177
}
176178

@@ -427,6 +429,20 @@ public void configurePitDashboard() {
427429
.add("Zero Elevator", new ZeroElevatorCommand(elevatorSubsystem))
428430
.withPosition(2, 1)
429431
.withSize(1, 1);
432+
433+
Shuffleboard.getTab("Debug")
434+
.add(
435+
"Toggle LED autoplacing",
436+
new InstantCommand(() -> ledSubsystem.setAutoPlacing(!ledSubsystem.getAutoPlacing())))
437+
.withPosition(1, 1)
438+
.withSize(1, 1);
439+
Shuffleboard.getTab("Debug")
440+
.add(
441+
"Toggle LED Current Limiting",
442+
new InstantCommand(
443+
() -> ledSubsystem.setCurrentLimiting(!ledSubsystem.getCurrentLimiting())))
444+
.withPosition(2, 1)
445+
.withSize(1, 1);
430446
}
431447

432448
public Command getAutonomousCommand() {

src/main/java/frc/robot/constants/LEDConstants.java

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,61 @@
33
import edu.wpi.first.wpilibj.util.Color;
44

55
public class LEDConstants {
6+
public static final Color invertRedGreen(Color color) {
7+
return new Color(color.green, color.red, color.blue);
8+
}
9+
10+
public static final int kLEDPort = 0;
611
// Auto/Operator = 27
712
// other = 21.5
8-
public static final int kTotalStripLength = 70;
9-
public static final int kBottomStripLength = 43;
10-
public static final int kTopStripLength = 27;
11-
public static final int kTopFirstIndex = kBottomStripLength + 1;
12-
13+
public static final int kTotalStripLength = 51;
14+
public static final int kBottomStripLength = 34;
15+
public static final int kTopStripLength = 17;
16+
public static final int kTopFirstIndex = kBottomStripLength;
1317
public static final int kAlgeaEnd = kBottomStripLength / 3 + 1;
18+
1419
public static final int kLevelStart = kTopFirstIndex;
1520
public static final int kPlaceStart = kTopFirstIndex + kTopStripLength / 3;
1621
public static final int kGetAlgeaStart = kTopFirstIndex + kTopStripLength / 3 * 2;
17-
public static final int kAutoPlacingStart = kTopFirstIndex;
22+
public static final int kAutoPlacingStart = kBottomStripLength / 3 * 2 + 1;
1823

1924
public static final Color kAlmostBlack = new Color(0, 0, 1);
2025

2126
// Normal LED Colors
22-
public static final Color kHasAlgea = Color.kAquamarine;
27+
public static final Color kHasAlgea = invertRedGreen(Color.kTeal);
2328
public static final Color kNotHasAlgea = kAlmostBlack;
2429

25-
public static final Color kCoralNotInRobot = Color.kOrange;
26-
public static final Color kCoralInFunnel = Color.kHotPink;
27-
public static final Color kCoralInRobot = Color.kWhite;
30+
public static final Color kCoralNotInRobot = invertRedGreen(Color.kOrange);
31+
public static final Color kCoralInFunnel = invertRedGreen(Color.kPurple);
32+
public static final Color kCoralInRobot = invertRedGreen(Color.kAntiqueWhite);
2833

29-
public static final Color kL1 = Color.kBlue;
30-
public static final Color kL2 = Color.kGreen;
31-
public static final Color kL3 = Color.kYellow;
32-
public static final Color kL4 = Color.kRed;
34+
public static final Color kL1 = invertRedGreen(Color.kRed);
35+
public static final Color kL2 = invertRedGreen(Color.kLightYellow);
36+
public static final Color kL3 = invertRedGreen(Color.kGreen);
37+
public static final Color kL4 = invertRedGreen(Color.kBlue);
3338

3439
public static final Color kManual = kAlmostBlack;
35-
public static final Color kRight = Color.kSaddleBrown;
36-
public static final Color kLeft = Color.kGreenYellow;
40+
public static final Color kRight = invertRedGreen(Color.kOrangeRed);
41+
public static final Color kLeft = invertRedGreen(Color.kPurple);
3742

38-
public static final Color kGetAlgea = Color.kAquamarine;
43+
public static final Color kGetAlgea = invertRedGreen(Color.kTeal);
3944
public static final Color kNotGetAlgea = kAlmostBlack;
4045

41-
public static final Color kCurrentLimiting = Color.kRed;
46+
public static final Color kCurrentLimiting = invertRedGreen(Color.kRed);
4247

43-
public static final Color kAutoPlacing = Color.kPurple;
48+
public static final Color kAutoPlacing = invertRedGreen(Color.kBlue);
4449

4550
// Climb LED Colors
46-
public static final Color kWaitingForCage = Color.kRed;
47-
public static final Color kHasCage = Color.kGreen;
48-
public static final Color kClimbed = Color.kGoldenrod;
51+
public static final Color kWaitingForCage = invertRedGreen(Color.kRed);
52+
public static final Color kHasCage = invertRedGreen(Color.kGreen);
53+
public static final Color kClimbed = invertRedGreen(Color.kGoldenrod);
4954
public static final Color[] kGameColors = {
50-
Color.kBlack, // a dummy color
51-
Color.kDarkRed,
52-
Color.kDarkGreen,
53-
Color.kDarkBlue,
54-
Color.kPink,
55-
Color.kLightGreen,
56-
Color.kLightBlue
55+
invertRedGreen(Color.kBlack), // a dummy color
56+
invertRedGreen(Color.kDarkRed),
57+
invertRedGreen(Color.kDarkGreen),
58+
invertRedGreen(Color.kDarkBlue),
59+
invertRedGreen(Color.kPink),
60+
invertRedGreen(Color.kLightGreen),
61+
invertRedGreen(Color.kLightBlue)
5762
};
5863
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public class LEDIO {
1212
private AddressableLEDBuffer led;
1313
private AddressableLEDBufferView ledTop;
1414

15-
public LEDIO(int port, int length) {
16-
ledBase = new AddressableLED(port);
17-
ledBase.setLength(length);
15+
public LEDIO() {
16+
ledBase = new AddressableLED(LEDConstants.kLEDPort);
17+
ledBase.setLength(LEDConstants.kTotalStripLength);
1818
ledBase.start();
19-
led = new AddressableLEDBuffer(length);
20-
ledTop = led.createView(LEDConstants.kTopFirstIndex, LEDConstants.kTotalStripLength + 1);
19+
led = new AddressableLEDBuffer(LEDConstants.kTotalStripLength);
20+
ledTop = led.createView(LEDConstants.kTopFirstIndex, LEDConstants.kTotalStripLength - 1);
2121
ledBase.setData(led);
2222
}
2323

@@ -32,7 +32,7 @@ public void setPort(int port) {
3232
public void setLength(int length) {
3333
ledBase.setLength(length);
3434
led = new AddressableLEDBuffer(length);
35-
ledTop = led.createView(LEDConstants.kTopFirstIndex, LEDConstants.kTotalStripLength + 1);
35+
ledTop = led.createView(LEDConstants.kTopFirstIndex, LEDConstants.kTotalStripLength - 1);
3636
ledBase.setData(led);
3737
}
3838

0 commit comments

Comments
 (0)