-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLights.java
More file actions
81 lines (72 loc) · 2.12 KB
/
Lights.java
File metadata and controls
81 lines (72 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot.subsystems;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.commands.SetLight;
/**
* Add your docs here.
*/
public class Lights extends Subsystem {
public enum LightState {
OFF,
CARGO,
HATCH,
CLIMBER
}
// Put methods for controlling this subsystem
// here. Call these from Commands.
private Relay lights;
private LightState lightsState;
/**
* 0 is off 0.5 is orange 1 is yellow
*/
public Lights(Relay lights) {
this.lights = lights;
lightsState = LightState.HATCH;
}
public void setLights(LightState newState) {
String color = "";
switch (newState) {
case OFF:
lights.set(Relay.Value.kOff);
color = "None";
break;
case CARGO:
lights.set(Relay.Value.kForward);
color = "Orange";
break;
case HATCH:
lights.set(Relay.Value.kReverse);
color = "Blue";
break;
case CLIMBER:
lights.set(Relay.Value.kOn);
color = "Rainbow";
break;
}
lightsState = newState;
SmartDashboard.putString("Lights Current Color", color);
}
public void toggleLights() {
if (lightsState == LightState.OFF) {
lightsState = LightState.CARGO;
} else if (lightsState == LightState.CARGO) {
lightsState = LightState.HATCH;
} else if (lightsState == LightState.HATCH) {
lightsState = LightState.CLIMBER;
}
else {
lightsState = LightState.OFF;
}
}
@Override
public void initDefaultCommand() {
setDefaultCommand(new SetLight(this, LightState.HATCH));
}
}