Skip to content

Commit 912f283

Browse files
committed
merge lights
2 parents 8f516bc + 6c1f3b0 commit 912f283

File tree

10 files changed

+1346
-197
lines changed

10 files changed

+1346
-197
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,24 @@
6262
| n/a | USB | CANivore |
6363

6464
## DIO
65-
| Subsystem | name | ID |
66-
| ---------- | --------- | --- |
67-
| BattMon | Batt V | 0 |
68-
| BattMon | Batt I | 1 |
69-
| BattMon | PDP V | 2 |
70-
| BattMon | Breaker T | 3 |
71-
| AutoSwitch | switch | 4 |
72-
| AutoSwitch | switch | 5 |
73-
| AutoSwitch | switch | 6 |
74-
| AutoSwitch | switch | 7 |
75-
| AutoSwitch | switch | 8 |
76-
| AutoSwitch | switch | 9 |
65+
| Subsystem | name | ID |
66+
| ---------- | ----------- | --- |
67+
| BattMon | Batt I | 0 |
68+
| BattMon | PDP V | 1 |
69+
| BattMon | Breaker T | 2 |
70+
| Climb | cageAligned | 3 |
71+
| AutoSwitch | switch | 4 |
72+
| AutoSwitch | switch | 5 |
73+
| AutoSwitch | switch | 6 |
74+
| AutoSwitch | switch | 7 |
75+
| AutoSwitch | switch | 8 |
76+
| AutoSwitch | switch | 9 |
7777

7878
## MXP
7979
| Subsystem | name | ID |
8080
| --------- | ----------- | --- |
8181
| TagServo | wallSense | 10 |
82-
| Climb | cageAligned | 11 |
82+
| TagServo | headLights | 11 |
8383
| | | 12 |
8484
| | | 13 |
8585
| | | 14 |

docs/.$reefscape-states.drawio.bkp

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.
102 KB
Loading

docs/reefscape-Tag Align-Light.png

207 KB
Loading

docs/reefscape-states.drawio

Lines changed: 360 additions & 173 deletions
Large diffs are not rendered by default.

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;
@@ -137,7 +138,7 @@ public RobotContainer() {
137138
funnelSubsystem = new FunnelSubsystem(funnelIO);
138139

139140
ledIO = new LEDIO();
140-
ledSubsystem = new LEDSubsystem();
141+
ledSubsystem = new LEDSubsystem(ledIO);
141142

142143
visionSubsystem = new VisionSubsystem(driveSubsystem);
143144

@@ -173,6 +174,7 @@ private void configureTelemetry() {
173174
elevatorSubsystem.registerWith(telemetryService);
174175
funnelSubsystem.registerWith(telemetryService);
175176
biscuitSubsystem.registerWith(telemetryService);
177+
ledSubsystem.registerWith(telemetryService);
176178
telemetryService.start();
177179
}
178180

@@ -405,6 +407,20 @@ public void configurePitDashboard() {
405407
.add("Zero Elevator", new ZeroElevatorCommand(elevatorSubsystem))
406408
.withPosition(2, 1)
407409
.withSize(1, 1);
410+
411+
Shuffleboard.getTab("Debug")
412+
.add(
413+
"Toggle LED autoplacing",
414+
new InstantCommand(() -> ledSubsystem.setAutoPlacing(!ledSubsystem.getAutoPlacing())))
415+
.withPosition(1, 1)
416+
.withSize(1, 1);
417+
Shuffleboard.getTab("Debug")
418+
.add(
419+
"Toggle LED Current Limiting",
420+
new InstantCommand(
421+
() -> ledSubsystem.setCurrentLimiting(!ledSubsystem.getCurrentLimiting())))
422+
.withPosition(2, 1)
423+
.withSize(1, 1);
408424
}
409425

410426
public Command getAutonomousCommand() {
Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
11
package frc.robot.constants;
22

3-
public class LEDConstants {}
3+
import edu.wpi.first.wpilibj.util.Color;
4+
5+
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;
11+
// Auto/Operator = 27
12+
// other = 21.5
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;
17+
public static final int kAlgeaEnd = kBottomStripLength / 3 + 1;
18+
19+
public static final int kLevelStart = kTopFirstIndex;
20+
public static final int kPlaceStart = kTopFirstIndex + kTopStripLength / 3;
21+
public static final int kGetAlgeaStart = kTopFirstIndex + kTopStripLength / 3 * 2;
22+
public static final int kAutoPlacingStart = kBottomStripLength / 3 * 2 + 1;
23+
24+
public static final Color kAlmostBlack = new Color(0, 0, 1);
25+
26+
// Normal LED Colors
27+
public static final Color kHasAlgea = invertRedGreen(Color.kTeal);
28+
public static final Color kNotHasAlgea = kAlmostBlack;
29+
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);
33+
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);
38+
39+
public static final Color kManual = kAlmostBlack;
40+
public static final Color kRight = invertRedGreen(Color.kOrangeRed);
41+
public static final Color kLeft = invertRedGreen(Color.kPurple);
42+
43+
public static final Color kGetAlgea = invertRedGreen(Color.kTeal);
44+
public static final Color kNotGetAlgea = kAlmostBlack;
45+
46+
public static final Color kCurrentLimiting = invertRedGreen(Color.kRed);
47+
48+
public static final Color kAutoPlacing = invertRedGreen(Color.kBlue);
49+
50+
// Climb LED Colors
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);
54+
public static final Color[] kGameColors = {
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)
62+
};
63+
}
Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,84 @@
11
package frc.robot.subsystems.led;
22

3-
public class LEDIO {}
3+
import edu.wpi.first.wpilibj.AddressableLED;
4+
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
5+
import edu.wpi.first.wpilibj.AddressableLEDBufferView;
6+
import edu.wpi.first.wpilibj.LEDPattern;
7+
import edu.wpi.first.wpilibj.util.Color;
8+
import frc.robot.constants.LEDConstants;
9+
10+
public class LEDIO {
11+
private AddressableLED ledBase;
12+
private AddressableLEDBuffer led;
13+
private AddressableLEDBufferView ledTop;
14+
15+
public LEDIO() {
16+
ledBase = new AddressableLED(LEDConstants.kLEDPort);
17+
ledBase.setLength(LEDConstants.kTotalStripLength);
18+
ledBase.start();
19+
led = new AddressableLEDBuffer(LEDConstants.kTotalStripLength);
20+
ledTop = led.createView(LEDConstants.kTopFirstIndex, LEDConstants.kTotalStripLength - 1);
21+
ledBase.setData(led);
22+
}
23+
24+
public void setPort(int port) {
25+
ledBase.close();
26+
ledBase = new AddressableLED(port);
27+
ledBase.setLength(led.getLength());
28+
ledBase.start();
29+
ledBase.setData(led);
30+
}
31+
32+
public void setLength(int length) {
33+
ledBase.setLength(length);
34+
led = new AddressableLEDBuffer(length);
35+
ledTop = led.createView(LEDConstants.kTopFirstIndex, LEDConstants.kTotalStripLength - 1);
36+
ledBase.setData(led);
37+
}
38+
39+
public void updateLEDs() {
40+
ledBase.setData(led);
41+
}
42+
43+
public void setLED(int index, Color color) {
44+
led.setLED(index, color);
45+
}
46+
47+
public void setLED(int index, int r, int g, int b) {
48+
led.setRGB(index, r, g, b);
49+
}
50+
51+
public Color getLED(int index) {
52+
return led.getLED(index);
53+
}
54+
55+
public void setLEDTop(int index, Color color) {
56+
ledTop.setLED(index, color);
57+
}
58+
59+
public void setLEDTop(int index, int r, int g, int b) {
60+
ledTop.setRGB(index, r, g, b);
61+
}
62+
63+
public Color getLEDTop(int index) {
64+
return ledTop.getLED(index);
65+
}
66+
67+
public void setOff() {
68+
for (int i = 0; i < led.getLength(); i++) {
69+
setLED(i, Color.kBlack);
70+
}
71+
ledBase.setData(led);
72+
}
73+
74+
public void setStrip(LEDPattern pattern) {
75+
pattern.applyTo(led);
76+
}
77+
78+
public void setStrip(Color color) {
79+
for (int i = 0; i < led.getLength(); i++) {
80+
setLED(i, color);
81+
}
82+
ledBase.setData(led);
83+
}
84+
}

0 commit comments

Comments
 (0)