Skip to content

QOL: Update LED flashing states #38

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

Merged
merged 3 commits into from
Mar 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 80 additions & 20 deletions src/main/java/raidzero/robot/subsystems/LEDStrip/ArmStrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ private void updateStates() {
* The E-stopped loop of the CANdle LED strip
*/
private void loopEstopped() {
if (animationApplied || animation2Applied || animation3Applied) {
if (animation2Applied || animation3Applied) {
resetAnimation();
}

if (!animationApplied) {
candle.clearAnimation(0);
candle.clearAnimation(1);
candle.animate(new StrobeAnimation(25, 0, 0, 0, 0.001, -1));
candle.animate(new StrobeAnimation(255, 0, 0, 0, 0.001, -1));
animationApplied = true;
animation2Applied = false;
animation3Applied = false;
Expand All @@ -112,11 +112,24 @@ private void loopEstopped() {
* The disabled loop of the CANdle LED strip
*/
private void loopDisabled() {
if (ClimbJoint.system().isDeployed().getAsBoolean()) {
if (DriverStation.isAutonomous() && DriverStation.getMatchTime() > 0.0) {
if (animation2Applied || animation3Applied) {
resetAnimation();
}

if (!animationApplied) {
candle.clearAnimation(0);
candle.clearAnimation(1);
candle.animate(new StrobeAnimation(255, 0, 0, 0, 0.001, -1));
animationApplied = true;
animation2Applied = false;
animation3Applied = false;
}
} else if (ClimbJoint.system().isDeployed().getAsBoolean()) {
if (!animation3Applied) {
candle.clearAnimation(0);
candle.clearAnimation(1);
candle.animate(new RainbowAnimation(255, 0.75, -1));
candle.animate(new RainbowAnimation(255, 1.0, -1));
animationApplied = false;
animation2Applied = false;
animation3Applied = true;
Expand All @@ -141,11 +154,15 @@ private void loopDisabled() {

if (strobeTimer.hasElapsed(strobeInterval)) {
if (strobeAlternate) {
candle.setLEDs(255, 0, 0, 0, 0, 4);
candle.setLEDs(0, 0, 0, 0, 4, 4);
candle.setLEDs(255, 0, 0, 0, 8, 25);
candle.setLEDs(0, 0, 0, 0, 33, 25);
candle.setLEDs(0, 0, 0, 0, 33, 27);
} else {
candle.setLEDs(0, 0, 0, 0, 0, 4);
candle.setLEDs(255, 0, 0, 0, 4, 4);
candle.setLEDs(0, 0, 0, 0, 8, 25);
candle.setLEDs(255, 0, 0, 0, 33, 25);
candle.setLEDs(255, 0, 0, 0, 33, 27);
}

strobeAlternate = !strobeAlternate;
Expand All @@ -170,13 +187,21 @@ private void loopDisabled() {
* The autonomous loop of the CANdle LED strip
*/
private void loopAutonomous() {
if (animationApplied || animation2Applied || animation3Applied) {
resetAnimation();
}

if (strobeTimer.hasElapsed(strobeInterval)) {
if (strobeAlternate) {
candle.setLEDs(255, 165, 0, 0, 0, 25);
candle.setLEDs(0, 255, 0, 0, 33, 25);
candle.setLEDs(255, 165, 0, 0, 0, 4);
candle.setLEDs(0, 255, 0, 0, 4, 4);
candle.setLEDs(255, 165, 0, 0, 8, 25);
candle.setLEDs(0, 255, 0, 0, 33, 27);
} else {
candle.setLEDs(0, 255, 0, 0, 0, 25);
candle.setLEDs(255, 165, 0, 0, 33, 25);
candle.setLEDs(0, 255, 0, 0, 0, 4);
candle.setLEDs(255, 165, 0, 0, 4, 4);
candle.setLEDs(0, 255, 0, 0, 8, 25);
candle.setLEDs(255, 165, 0, 0, 33, 27);
}

strobeAlternate = !strobeAlternate;
Expand All @@ -195,7 +220,7 @@ private void loopTeleop() {
candle.clearAnimation(0);
candle.clearAnimation(1);
candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Backward, 8), 0);
candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Forward, 33), 1);
candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 27, Direction.Forward, 33), 1);
animationApplied = false;
animation2Applied = true;
animation3Applied = false;
Expand All @@ -205,7 +230,7 @@ private void loopTeleop() {
candle.clearAnimation(0);
candle.clearAnimation(1);
candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Forward, 8), 0);
candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 25, Direction.Backward, 33), 1);
candle.animate(new ColorFlowAnimation(250, 160, 10, 0, 0.75, 27, Direction.Backward, 33), 1);
animationApplied = false;
animation2Applied = true;
animation3Applied = false;
Expand All @@ -217,11 +242,15 @@ private void loopTeleop() {

if (strobeTimer.hasElapsed(strobeInterval)) {
if (strobeAlternate) {
candle.setLEDs(0, 255, 0, 0, 0, 4);
candle.setLEDs(255, 0, 0, 0, 4, 4);
candle.setLEDs(0, 255, 0, 0, 8, 25);
candle.setLEDs(255, 0, 0, 0, 33, 25);
candle.setLEDs(255, 0, 0, 0, 33, 27);
} else {
candle.setLEDs(255, 0, 0, 0, 0, 4);
candle.setLEDs(0, 255, 0, 0, 4, 4);
candle.setLEDs(255, 0, 0, 0, 8, 25);
candle.setLEDs(0, 255, 0, 0, 33, 25);
candle.setLEDs(0, 255, 0, 0, 33, 27);
}

strobeAlternate = !strobeAlternate;
Expand All @@ -234,11 +263,15 @@ private void loopTeleop() {

if (strobeTimer.hasElapsed(strobeInterval)) {
if (strobeAlternate) {
candle.setLEDs(255, 10, 250, 0, 0, 4);
candle.setLEDs(255, 0, 0, 0, 4, 4);
candle.setLEDs(255, 10, 250, 0, 8, 25);
candle.setLEDs(255, 0, 0, 0, 33, 25);
candle.setLEDs(255, 0, 0, 0, 33, 27);
} else {
candle.setLEDs(255, 0, 0, 0, 0, 4);
candle.setLEDs(255, 10, 250, 0, 4, 4);
candle.setLEDs(255, 0, 0, 0, 8, 25);
candle.setLEDs(255, 10, 250, 0, 33, 25);
candle.setLEDs(255, 10, 250, 0, 33, 27);
}

strobeAlternate = !strobeAlternate;
Expand All @@ -251,11 +284,15 @@ private void loopTeleop() {

if (strobeTimer.hasElapsed(strobeInterval)) {
if (strobeAlternate) {
candle.setLEDs(255, 10, 250, 0, 0, 4);
candle.setLEDs(0, 255, 0, 0, 4, 4);
candle.setLEDs(255, 10, 250, 0, 8, 25);
candle.setLEDs(0, 255, 0, 0, 33, 25);
candle.setLEDs(0, 255, 0, 0, 33, 27);
} else {
candle.setLEDs(0, 255, 0, 0, 0, 4);
candle.setLEDs(255, 10, 250, 0, 4, 4);
candle.setLEDs(0, 255, 0, 0, 8, 25);
candle.setLEDs(255, 10, 250, 0, 33, 25);
candle.setLEDs(255, 10, 250, 0, 33, 27);
}

strobeAlternate = !strobeAlternate;
Expand All @@ -268,11 +305,15 @@ private void loopTeleop() {

if (strobeTimer.hasElapsed(strobeInterval)) {
if (strobeAlternate) {
candle.setLEDs(255, 10, 250, 0, 0, 4);
candle.setLEDs(0, 0, 0, 0, 4, 4);
candle.setLEDs(255, 10, 250, 0, 8, 25);
candle.setLEDs(0, 0, 0, 0, 33, 25);
candle.setLEDs(0, 0, 0, 0, 33, 27);
} else {
candle.setLEDs(0, 0, 0, 0, 0, 4);
candle.setLEDs(255, 10, 250, 0, 4, 4);
candle.setLEDs(0, 0, 0, 0, 8, 25);
candle.setLEDs(255, 10, 250, 0, 33, 25);
candle.setLEDs(255, 10, 250, 0, 33, 27);
}

strobeAlternate = !strobeAlternate;
Expand Down Expand Up @@ -311,6 +352,25 @@ public void matchEndAnimation() {
candle.animate(new RainbowAnimation(255, 0.75, -1));
}

/**
* Sets the LED to red, green, blue in alternating sequence
*/
private void testCandleSequence() {
candle.setLEDs(255, 0, 0, 0, 0, 5);
candle.setLEDs(0, 255, 0, 0, 5, 5);
candle.setLEDs(0, 0, 255, 0, 10, 5);
candle.setLEDs(255, 0, 0, 0, 15, 5);
candle.setLEDs(0, 255, 0, 0, 20, 5);
candle.setLEDs(0, 0, 255, 0, 25, 5);
candle.setLEDs(255, 0, 0, 0, 30, 5);
candle.setLEDs(0, 255, 0, 0, 35, 5);
candle.setLEDs(0, 0, 255, 0, 40, 5);
candle.setLEDs(255, 0, 0, 0, 45, 5);
candle.setLEDs(0, 255, 0, 0, 50, 5);
candle.setLEDs(0, 0, 255, 0, 55, 5);
candle.setLEDs(255, 0, 0, 0, 60, 5);
}

/**
* Gets a {@link CANdleConfiguration} for the CANdle LED strip
*
Expand Down