22
33import static edu .wpi .first .units .Units .Seconds ;
44
5+ import java .util .Map ;
56import java .util .Set ;
67
78import org .strykeforce .telemetry .measurable .MeasurableSubsystem ;
89import org .strykeforce .telemetry .measurable .Measure ;
910
1011import edu .wpi .first .wpilibj .LEDPattern ;
1112import edu .wpi .first .wpilibj .util .Color ;
13+ import frc .robot .constants .LEDConstants ;
1214
1315public class LEDSubsystem extends MeasurableSubsystem {
1416 private LEDIO io ;
15- private LEDPattern base = LEDPattern .steps (map .of (0 , Color .kAqua , ));
16- LEDPattern red = LEDPattern .solid (Color .kRed );
17+ private LEDPattern base = LEDPattern .solid (Color .kBlack );
18+ private LEDPattern coral = LEDPattern .solid (LEDConstants .kCoralInRobot );
19+ private LEDPattern algea = LEDPattern .steps (Map .of (0 , LEDConstants .kHasAlgea , LEDConstants .stripLength /3 , Color .kBlack ));
20+
21+ private LEDPattern currentLimiting = LEDPattern .solid (LEDConstants .kCurrentLimiting ).blink (Seconds .of (1 ), Seconds .of (2 ));
22+ private LEDPattern autoplace = LEDPattern .steps (Map .of (LEDConstants .stripLength /3 *2 , LEDConstants .kAutoPlacing )).blink (Seconds .of (0.25 ));
1723 public LEDStates currState = LEDStates .OFF ;
1824 public CoralStates coralState = CoralStates .NO_PIECE ;
1925 public boolean autoPlacing = false ;
@@ -22,15 +28,41 @@ public class LEDSubsystem extends MeasurableSubsystem{
2228
2329 public LEDSubsystem (LEDIO io ) {
2430 this .io = io ;
25- red .blink (Seconds .of (1 ), Seconds .of (2 ));
31+ }
32+
33+ private void buildBase () {
34+ switch (coralState ) {
35+ case IN_FUNNEL :
36+ coral = LEDPattern .solid (LEDConstants .kCoralInFunnel );
37+ break ;
38+ case IN_ROBOT :
39+ coral = LEDPattern .solid (LEDConstants .kCoralInRobot );
40+ break ;
41+ case NO_PIECE :
42+ coral = LEDPattern .solid (LEDConstants .kCoralNotInRobot );
43+ break ;
44+ }
45+ algea = LEDPattern .steps (Map .of (0 , LEDConstants .kHasAlgea , LEDConstants .stripLength /3 , Color .kBlack ));
2646
2747 }
2848
2949 public void periodic () {
30- red .blink (Seconds .of (1 ), Seconds .of (2 ));
31- if (isLimiting ) {
32- red .overlayOn (base );
50+ switch (currState ) {
51+ case OFF :
52+ break ;
53+ case NORMAL :
54+ if (autoPlacing ) {
55+ base = autoplace .overlayOn (base );
56+ }
57+ if (isLimiting ) {
58+ base = currentLimiting .overlayOn (base );
59+ }
60+ io .setStrip (base );
61+ break ;
62+ case CLIMB :
63+ break ;
3364 }
65+ io .updateLEDs ();
3466 }
3567
3668 @ Override
@@ -46,8 +78,8 @@ public enum LEDStates {
4678 }
4779
4880 public enum CoralStates {
49- HAS_PIECE ,
50- IN_MECH ,
81+ IN_FUNNEL ,
82+ IN_ROBOT ,
5183 NO_PIECE ,
5284 }
5385}
0 commit comments