-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
182 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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
22 changes: 0 additions & 22 deletions
22
src/main/java/org/team1540/robot2024/subsystems/led/LedPatternRSLState.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/main/java/org/team1540/robot2024/subsystems/led/LedTriager.java
This file contains 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,38 @@ | ||
package org.team1540.robot2024.subsystems.led; | ||
|
||
import org.team1540.robot2024.subsystems.led.patterns.LedPattern; | ||
import org.team1540.robot2024.subsystems.led.patterns.LedPatternFlame; | ||
import org.team1540.robot2024.subsystems.led.patterns.LedPatternRainbow; | ||
|
||
|
||
public class LedTriager { | ||
private final LedPattern[] patterns = new LedPattern[Leds.CRITICALITY_COUNT]; | ||
private final LedPattern defaultPattern = new LedPatternRainbow(1); | ||
private boolean isNew = true; | ||
public LedPattern getPattern() { | ||
for (int i = patterns.length -1; i >= 0; i--) { | ||
if (patterns[i] != null) { | ||
return patterns[i]; | ||
} | ||
} | ||
return defaultPattern; | ||
} | ||
|
||
public boolean shouldRefresh() { | ||
final boolean val = isNew || getPattern().isDynamic(); | ||
isNew = false; | ||
return val; | ||
} | ||
|
||
public void clearPattern(Leds.PatternCriticality criticality) { | ||
patterns[criticality.ordinal()] = null; | ||
isNew = true; | ||
} | ||
|
||
public boolean addPattern(LedPattern pattern, Leds.PatternCriticality criticality) { | ||
patterns[criticality.ordinal()] = pattern; | ||
isNew = true; | ||
return getPattern() == pattern; | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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.