-
Notifications
You must be signed in to change notification settings - Fork 8
Led subsystem and command #48
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
Open
SemblanceOfSense
wants to merge
11
commits into
fairviewrobotics:dev
Choose a base branch
from
SemblanceOfSense:led
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1657b6f
LED subsystem and command
SemblanceOfSense 841bc8b
remove tuning.json
SemblanceOfSense 978a1f9
Remove command edit out periodic
SemblanceOfSense b9fce00
Delete unnecessary imports
SemblanceOfSense 003c829
javadoc
SemblanceOfSense bcc0c75
spotless
SemblanceOfSense f076800
Add params to javadoc
SemblanceOfSense 6c64cf2
Remove code artifacts
SemblanceOfSense ed55215
remove unread variables
SemblanceOfSense 9bbd55c
Don't update if colors arent changed
SemblanceOfSense f520b6b
REMOVE TUNING.JSON
SemblanceOfSense 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* Black Knights Robotics (C) 2025 */ | ||
| package frc.robot.constants; | ||
|
|
||
| /** Constants for the LEDs */ | ||
| public class LEDConstants { | ||
| public static final int DEVICE_ID = 0; | ||
| } |
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,68 @@ | ||
| /* Black Knights Robotics (C) 2025 */ | ||
| package frc.robot.subsystems; | ||
|
|
||
| import com.ctre.phoenix.led.*; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
| import frc.robot.constants.LEDConstants; | ||
|
|
||
| /** Subsystem for LED colors and animations Thx Matero for half the code */ | ||
| public class LEDSubsystem extends SubsystemBase { | ||
| private final CANdle candle = new CANdle(LEDConstants.DEVICE_ID, "rio"); | ||
| private int r = 0; | ||
| private int g = 0; | ||
| private int b = 0; | ||
|
|
||
| /** Possible animation/colors */ | ||
| public enum AnimationTypes { | ||
| Red, | ||
| Green, | ||
| Yellow, | ||
| Blue, | ||
| Off | ||
| } | ||
|
|
||
| /** Create new LED subsystem */ | ||
| public LEDSubsystem() { | ||
TotalTaxAmount marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| CANdleConfiguration config = new CANdleConfiguration(); | ||
| config.statusLedOffWhenActive = true; | ||
| config.disableWhenLOS = false; | ||
| config.stripType = CANdle.LEDStripType.RGB; | ||
| config.brightnessScalar = 0.1; | ||
| } | ||
|
|
||
| /** | ||
| * Set LEDs to static color | ||
| * | ||
| * @param r LED red value 0-255 | ||
| * @param b LED blue value 0-255 | ||
| * @param g LED green value 0-255 | ||
| */ | ||
| private void setRGB(int r, int g, int b) { | ||
TotalTaxAmount marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (this.r != r || this.b != b || this.g != g) { | ||
| candle.setLEDs(r, g, b); | ||
| this.r = r; | ||
| this.g = g; | ||
| this.b = b; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Set animation/color of LEDs | ||
| * | ||
| * @param toChange Animation to change the animation to | ||
| */ | ||
| public void setAnimation(AnimationTypes toChange) { | ||
TotalTaxAmount marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| switch (toChange) { | ||
| case Red: | ||
| setRGB(255, 0, 0); | ||
| case Yellow: | ||
| setRGB(255, 255, 0); | ||
| case Blue: | ||
| setRGB(0, 0, 255); | ||
| case Green: | ||
| setRGB(0, 255, 0); | ||
| case Off: | ||
| setRGB(0, 0, 0); | ||
| } | ||
| } | ||
| } | ||
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.