-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetBlinkinLEDPattern.java
More file actions
43 lines (35 loc) · 1.11 KB
/
SetBlinkinLEDPattern.java
File metadata and controls
43 lines (35 loc) · 1.11 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
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.blinkinled.BlinkinLEDSubsystem;
public class SetBlinkinLEDPattern extends Command {
private BlinkinLEDSubsystem ledSystem;
private double pattern;
/**
* @apiNote If this is -1, that means that this command is targeting the whole strip
*/
private int section;
private boolean invalid;
public SetBlinkinLEDPattern(BlinkinLEDSubsystem ledSystem, int section, double pattern) {
invalid = (section < -1 || section >= ledSystem.stripCount);
this.section = section;
this.ledSystem = ledSystem;
this.pattern = pattern;
}
public SetBlinkinLEDPattern(BlinkinLEDSubsystem led, double pattern) {
this(led, -1, pattern);
}
@Override
public void initialize() {
if (invalid) return;
if (section == -1) {
ledSystem.applyPatternToAll(pattern);
} else {
ledSystem.applyPatternTo(section, pattern);
}
}
// Since executing the command is a one-time thing, we always report being done instantly
@Override
public boolean isFinished() {
return true;
}
}