-
Notifications
You must be signed in to change notification settings - Fork 0
Led code #14
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
abi-appusamy9932
wants to merge
14
commits into
master
Choose a base branch
from
led-code
base: master
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
Led code #14
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2ecdd4a
led code
abi-appusamy9932 8bdafce
Merge branch 'master' into led-code
Luddo183 950ed5e
Auto-format code
Phoenix2342-Bot 0a72ed6
finishing led code
abi-appusamy9932 eca6177
implementing requested changes
abi-appusamy9932 c5d69c0
minor fixes
abi-appusamy9932 d51c621
testing
abi-appusamy9932 ae7eca6
Auto-format code
Phoenix2342-Bot 32de1b8
update() fixes
abi-appusamy9932 9c230c8
Merge branch 'led-code' of https://github.com/FRCTeamPhoenix/Library …
abi-appusamy9932 8e111f8
Auto-format code
Phoenix2342-Bot c6fa5f8
more candle
abi-appusamy9932 fd874b7
Merge remote-tracking branch 'origin/master' into led-code
Luddo183 2a9c075
Auto-format code
Phoenix2342-Bot 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
186 changes: 186 additions & 0 deletions
186
src/main/java/org/team2342/frc/subsystems/CANdleSystem/CANdleSystem.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,186 @@ | ||
| // Copyright (c) 2026 Team 2342 | ||
| // https://github.com/FRCTeamPhoenix | ||
| // | ||
| // This source code is licensed under the MIT License. | ||
| // See the LICENSE file in the root directory of this project. | ||
|
|
||
| package org.team2342.frc.subsystems.CANdleSystem; | ||
|
|
||
| import com.ctre.phoenix6.CANBus; | ||
| import com.ctre.phoenix6.configs.CANdleConfiguration; | ||
| import com.ctre.phoenix6.controls.SolidColor; | ||
| import com.ctre.phoenix6.hardware.CANdle; | ||
| import com.ctre.phoenix6.signals.RGBWColor; | ||
| import com.ctre.phoenix6.signals.StatusLedWhenActiveValue; | ||
| import com.ctre.phoenix6.signals.StripTypeValue; | ||
| import edu.wpi.first.wpilibj.XboxController; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
|
||
| public class CANdleSystem extends SubsystemBase { | ||
| private final CANdle m_candle = new CANdle(22, new CANBus("rio")); | ||
| private final int LedCount = 300; | ||
| private XboxController joystick; | ||
|
|
||
| public enum AnimationTypes { | ||
| ColorFlow, | ||
| Fire, | ||
| Larson, | ||
| Rainbow, | ||
| RgbFade, | ||
| SingleFade, | ||
| Strobe, | ||
| Twinkle, | ||
| TwinkleOff, | ||
| SetAll | ||
| } | ||
|
|
||
| private AnimationTypes m_currentAnimation; | ||
|
|
||
| public CANdleSystem(XboxController joy) { | ||
| this.joystick = joy; | ||
| changeAnimation(AnimationTypes.SetAll); | ||
| CANdleConfiguration configAll = new CANdleConfiguration(); | ||
| configAll.CANdleFeatures.StatusLedWhenActive = StatusLedWhenActiveValue.Disabled; | ||
| configAll.LED.StripType = StripTypeValue.GRB; | ||
| m_candle.getConfigurator().apply(configAll); | ||
| } | ||
|
|
||
| public void incrementAnimation() { | ||
| switch (m_currentAnimation) { | ||
| case ColorFlow: | ||
| changeAnimation(AnimationTypes.Fire); | ||
| break; | ||
| case Fire: | ||
| changeAnimation(AnimationTypes.Larson); | ||
| break; | ||
| case Larson: | ||
| changeAnimation(AnimationTypes.Rainbow); | ||
| break; | ||
| case Rainbow: | ||
| changeAnimation(AnimationTypes.RgbFade); | ||
| break; | ||
| case RgbFade: | ||
| changeAnimation(AnimationTypes.SingleFade); | ||
| break; | ||
| case SingleFade: | ||
| changeAnimation(AnimationTypes.Strobe); | ||
| break; | ||
| case Strobe: | ||
| changeAnimation(AnimationTypes.Twinkle); | ||
| break; | ||
| case Twinkle: | ||
| changeAnimation(AnimationTypes.TwinkleOff); | ||
| break; | ||
| case TwinkleOff: | ||
| changeAnimation(AnimationTypes.ColorFlow); | ||
| break; | ||
| case SetAll: | ||
| changeAnimation(AnimationTypes.ColorFlow); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| public void decrementAnimation() { | ||
| switch (m_currentAnimation) { | ||
| case ColorFlow: | ||
| changeAnimation(AnimationTypes.TwinkleOff); | ||
| break; | ||
| case Fire: | ||
| changeAnimation(AnimationTypes.ColorFlow); | ||
| break; | ||
| case Larson: | ||
| changeAnimation(AnimationTypes.Fire); | ||
| break; | ||
| case Rainbow: | ||
| changeAnimation(AnimationTypes.Larson); | ||
| break; | ||
| case RgbFade: | ||
| changeAnimation(AnimationTypes.Rainbow); | ||
| break; | ||
| case SingleFade: | ||
| changeAnimation(AnimationTypes.RgbFade); | ||
| break; | ||
| case Strobe: | ||
| changeAnimation(AnimationTypes.SingleFade); | ||
| break; | ||
| case Twinkle: | ||
| changeAnimation(AnimationTypes.Strobe); | ||
| break; | ||
| case TwinkleOff: | ||
| changeAnimation(AnimationTypes.Twinkle); | ||
| break; | ||
| case SetAll: | ||
| changeAnimation(AnimationTypes.ColorFlow); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| public void setColors() { | ||
| changeAnimation(AnimationTypes.SetAll); | ||
| } | ||
|
|
||
| public void changeAnimation(AnimationTypes toChange) { | ||
| m_currentAnimation = toChange; | ||
|
|
||
| // switch(toChange) | ||
| // { | ||
| // case ColorFlow: | ||
| // m_toAnimate = new ColorFlowAnimation(128, 20, 70, 0, 0.7, LedCount, | ||
| // Direction.Forward); | ||
| // break; | ||
| // case Fire: | ||
| // m_toAnimate = new FireAnimation(0.5, 0.7, LedCount, 0.7, 0.5); | ||
| // break; | ||
| // case Larson: | ||
| // m_toAnimate = new LarsonAnimation(0, 255, 46, 0, 1, LedCount, BounceMode.Front, 3); | ||
| // break; | ||
| // case Rainbow: | ||
| // m_toAnimate = new RainbowAnimation(1, 0.1, LedCount); | ||
| // break; | ||
| // case RgbFade: | ||
| // m_toAnimate = new RgbFadeAnimation(0.7, 0.4, LedCount); | ||
| // break; | ||
| // case SingleFade: | ||
| // m_toAnimate = new SingleFadeAnimation(50, 2, 200, 0, 0.5, LedCount); | ||
| // break; | ||
| // case Strobe: | ||
| // m_toAnimate = new StrobeAnimation(240, 10, 180, 0, 98.0 / 256.0, LedCount); | ||
| // break; | ||
| // case Twinkle: | ||
| // m_toAnimate = new TwinkleAnimation(30, 70, 60, 0, 0.4, LedCount, | ||
| // TwinklePercent.Percent6); | ||
| // break; | ||
| // case TwinkleOff: | ||
| // m_toAnimate = new TwinkleOffAnimation(70, 90, 175, 0, 0.8, LedCount, | ||
| // TwinkleOffPercent.Percent100); | ||
| // break; | ||
| // case SetAll: | ||
| // m_toAnimate = null; | ||
| // break; | ||
| // } | ||
| // System.out.println("Changed to " + m_currentAnimation.toString()); | ||
| } | ||
|
|
||
| @Override | ||
| public void periodic() { | ||
| // This method will be called once per scheduler run | ||
| // SolidColor request = new SolidColor(0, 67); | ||
| // request.withColor(new RGBWColor(0, 255, 0,0)); | ||
|
|
||
| m_candle.setControl(new SolidColor(0, 67).withColor(new RGBWColor(0, 217, 0, 0))); | ||
|
|
||
| // if(m_toAnimate == null) { | ||
| // m_candle.setLEDs((int)(joystick.getLeftTriggerAxis() * 255), | ||
| // (int)(joystick.getRightTriggerAxis() * 255), | ||
| // (int)(joystick.getLeftX() * 255)); | ||
| // } else { | ||
| // m_candle.animate(m_toAnimate); | ||
| // } | ||
| // m_candle.modulateVBatOutput(joystick.getRightY()); | ||
| } | ||
|
|
||
| @Override | ||
| public void simulationPeriodic() { | ||
| // This method will be called once per scheduler run during simulation | ||
| } | ||
| } |
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
abi-appusamy9932 marked this conversation as resolved.
Show resolved
Hide resolved
|
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.