-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBlinkinLEDTestCommand.java
More file actions
49 lines (39 loc) · 1.24 KB
/
BlinkinLEDTestCommand.java
File metadata and controls
49 lines (39 loc) · 1.24 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
package frc.robot.commands.test;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.blinkinled.BlinkinLEDConstants;
import frc.robot.subsystems.blinkinled.BlinkinLEDSubsystem;
public class BlinkinLEDTestCommand extends Command {
private BlinkinLEDSubsystem ledSystem;
private double currentPattern;
private int ticker;
private final int delay;
/**
* @param led LED subsystem object to use
* @param time Time in robot updates to wait between changes (each update is 20ms, so 50 updates
* is 1 second)
*/
public BlinkinLEDTestCommand(BlinkinLEDSubsystem led, int time) {
ledSystem = led;
delay = time;
}
@Override
public void initialize() {
currentPattern = BlinkinLEDConstants.Patterns.BLACK;
ticker = 0;
}
@Override
public void execute() {
if (ticker++ < delay) return;
// 0.02 is the difference between each state, so we go down the list of all possible colors
currentPattern -= 0.02;
ledSystem.applyPatternToAll(currentPattern);
}
@Override
public boolean isFinished() {
return currentPattern <= BlinkinLEDConstants.Patterns.HOT_PINK;
}
@Override
public void end(boolean interrupted) {
currentPattern = BlinkinLEDConstants.Patterns.BLACK;
}
}