Skip to content

Commit 6b0abe9

Browse files
committed
fix
1 parent 148ff32 commit 6b0abe9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/org/trigon/hardware/misc/leds/LEDCommands.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ public static Command getRainbowCommand(double brightness, double speed, boolean
161161
).ignoringDisable(true).asProxy();
162162
}
163163

164+
/**
165+
* Gets a command that applies the specified animation settings to the LED strips.
166+
*
167+
* @param settings the settings for the desired animation
168+
* @param ledStrips the LED strips to be used
169+
* @return the command
170+
*/
171+
public static Command getDefaultAnimateCommand(LEDStripAnimationSettings.LEDAnimationSettings settings, LEDStrip... ledStrips) {
172+
return new StartEndCommand(
173+
() -> {
174+
runForLEDs(LEDStrip::clearLEDColors, ledStrips);
175+
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(LEDStrip.applyAnimation(ledStrip, settings)), ledStrips);
176+
},
177+
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
178+
ledStrips
179+
).ignoringDisable(true);
180+
}
181+
164182
/**
165183
* Runs an action on all LED strips.
166184
*/

src/main/java/org/trigon/hardware/misc/leds/LEDStrip.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static LEDStrip createCANdleLEDStrip(boolean inverted, int numberOfLEDs,
5151
*/
5252
public static void setDefaultAnimationForAllLEDS(LEDStripAnimationSettings.LEDAnimationSettings defaultAnimationSettings) {
5353
for (LEDStrip ledStrip : LED_STRIPS)
54-
ledStrip.setDefaultCommand(LEDCommands.getAnimateCommand(defaultAnimationSettings, ledStrip));
54+
ledStrip.setDefaultCommand(LEDCommands.getDefaultAnimateCommand(defaultAnimationSettings, ledStrip));
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)