-
Notifications
You must be signed in to change notification settings - Fork 1
Merge AddressableLED subsystem #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
6421de4
Add initial AddressableLED subsystem implementation
RobotLeopard86 fa8e40a
Fix missing imports and improper record access
RobotLeopard86 8b27e76
Add missing @Override declarations and add Javadoc
RobotLeopard86 b26a7b9
Merge branch 'main' into addressable-led
RobotLeopard86 b51bcd3
Merge branch 'main' into addressable-led
RobotLeopard86 e827996
Address code review feedback for AddressableLED subsystem and add sca…
RobotLeopard86 fad22db
Add AddressableLED testing command
RobotLeopard86 74fb53f
Actually apply the patterns for the AddressableLED test
RobotLeopard86 0cc78fe
Run Spotless!
RobotLeopard86 40c06ef
Merge branch 'main' into addressable-led
RobotLeopard86 7f0147c
Add Javadocs for AddressableLED subsystem
RobotLeopard86 13ba9fe
Merge branch 'addressable-led' of https://github.com/redshiftrobotics…
RobotLeopard86 6cf0918
Clarify separation between Blinkin and AddressableLED subsystems
RobotLeopard86 fd39f56
Main -> addressable-led merge
RobotLeopard86 e9c44d4
Fix Wrist build error resulting from main merge
RobotLeopard86 d3c6e7b
Add superstructure LED patterns
RobotLeopard86 9efff02
Fix errors
RobotLeopard86 650ee6b
Merge branch 'main' into addressable-led
RobotLeopard86 79bca46
Remove redundant null check
RobotLeopard86 0b9126f
Add appropriate Javadoc for subsystem
RobotLeopard86 ebcae4c
Run autoformatting
bforcum cead75c
Refactor LED pattern manipulation to be within subsystems instead of …
RobotLeopard86 e6fedd3
Merge branch 'main' into addressable-led
MichaelLesirge 8fcde4c
Merge branch 'main' into addressable-led
MichaelLesirge b5dda59
fix build
MichaelLesirge d3ffd09
Merge branch 'main' into addressable-led
AceiusRedshift 21a0484
fix
AceiusRedshift f2ed688
Integrate LEDs into robot container and superstructure
AceiusRedshift ed4e9b5
ok good enough
AceiusRedshift ea88276
Merge branch 'main' into addressable-led
RobotLeopard86 b545f59
Fix incorrect AddressableLED test end check and clarify Range record …
RobotLeopard86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/frc/robot/commands/SetAddressableLEDPattern.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 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; | ||
|
|
||
| /** | ||
| * @apiNote If this is empty, that means that this command is targeting the whole strip | ||
| */ | ||
| private final int[] sections; | ||
|
|
||
| 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... sections) { | ||
| this.sections = sections; | ||
| 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) { | ||
| sections = new int[0]; | ||
| this.pattern = pattern; | ||
| this.ledSystem = ledSystem; | ||
| addRequirements(ledSystem); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| if (sections.length <= 0) { | ||
| ledSystem.applyPattern(pattern); | ||
| } else { | ||
| for (int i = 0; i < sections.length; i++) { | ||
| ledSystem.applySectionedPattern(pattern, sections[i]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return true; | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/main/java/frc/robot/commands/SetBlinkinLEDPattern.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
src/main/java/frc/robot/commands/test/AddressableLEDTestCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package frc.robot.commands.test; | ||
|
|
||
| import static edu.wpi.first.units.Units.MetersPerSecond; | ||
| import static edu.wpi.first.units.Units.Seconds; | ||
|
|
||
| import edu.wpi.first.wpilibj.LEDPattern; | ||
| import edu.wpi.first.wpilibj.util.Color; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import frc.robot.subsystems.addressableled.AddressableLEDConstants; | ||
| import frc.robot.subsystems.addressableled.AddressableLEDSubsystem; | ||
|
|
||
| public class AddressableLEDTestCommand extends Command { | ||
| private final AddressableLEDSubsystem ledSystem; | ||
| private LEDPattern currentPattern; | ||
| private int ticker = 0; | ||
| private int testCount = 0; | ||
|
|
||
| public AddressableLEDTestCommand(AddressableLEDSubsystem ledSystem) { | ||
| this.ledSystem = ledSystem; | ||
| addRequirements(ledSystem); | ||
| } | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| ticker = 0; | ||
| testCount = 0; | ||
| currentPattern = | ||
| LEDPattern.rainbow(255, 128) | ||
| .scrollAtAbsoluteSpeed(MetersPerSecond.of(1), AddressableLEDConstants.LED_DENSITY); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| if (ticker < 500) { | ||
| ticker++; | ||
| } else { | ||
| ticker = 0; | ||
| ledSystem.applySectionedPattern(LEDPattern.kOff, testCount); | ||
| testCount++; | ||
| if (testCount == AddressableLEDConstants.SECTIONS.length) { | ||
| currentPattern = LEDPattern.solid(Color.kLimeGreen).breathe(Seconds.of(2)); | ||
| ledSystem.applyPattern(currentPattern); | ||
| } else { | ||
| ledSystem.applySectionedPattern(currentPattern, testCount); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return testCount >= (AddressableLEDConstants.SECTIONS.length + 1); | ||
| } | ||
|
|
||
| @Override | ||
| public void end(boolean interrupted) { | ||
| ledSystem.applyPattern(LEDPattern.kOff); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.