-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetAddressableLEDPattern.java
More file actions
52 lines (44 loc) · 1.43 KB
/
SetAddressableLEDPattern.java
File metadata and controls
52 lines (44 loc) · 1.43 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
package frc.robot.commands;
import edu.wpi.first.wpilibj.LEDPattern;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.addressableled.AddressableLEDSubsystem;
public class SetAddressableLEDPattern extends Command {
private final AddressableLEDSubsystem ledSystem;
// If this is -1, that means that this command is targeting the whole strip
private final int section;
private final LEDPattern pattern;
/**
* @param led Addressable LED subsystem to use
* @param pattern Pattern to apply when command run
* @param section Section of LED strip to apply pattern to (index into
* AddressableLEDConstants.SECTIONS)
*/
public SetAddressableLEDPattern(AddressableLEDSubsystem ledSystem, LEDPattern pattern, int section) {
this.section = section;
this.pattern = pattern;
this.ledSystem = ledSystem;
addRequirements(ledSystem);
}
/**
* @param led Addressable LED subsystem to use
* @param pattern Pattern to apply when command run
*/
public SetAddressableLEDPattern(AddressableLEDSubsystem ledSystem, LEDPattern pattern) {
section = -1;
this.pattern = pattern;
this.ledSystem = ledSystem;
addRequirements(ledSystem);
}
@Override
public void execute() {
if (section < 0) {
ledSystem.applyPattern(pattern);
} else {
ledSystem.applySectionedPattern(pattern, section);
}
}
@Override
public boolean isFinished() {
return true;
}
}