generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new LEDInstruction for the robot in the disabled state. (#93)
- Loading branch information
1 parent
6479fc4
commit 3cff974
Showing
2 changed files
with
57 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/stuypulse/robot/subsystems/leds/instructions/LED694.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,55 @@ | ||
/************************ PROJECT IZZI *************************/ | ||
/* Copyright (c) 2024 StuyPulse Robotics. All rights reserved. */ | ||
/* Use of this source code is governed by an MIT-style license */ | ||
/* that can be found in the repository LICENSE file. */ | ||
/***************************************************************/ | ||
|
||
package com.stuypulse.robot.subsystems.leds.instructions; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
||
import com.stuypulse.robot.constants.Settings; | ||
import com.stuypulse.robot.util.SLColor; | ||
import com.stuypulse.stuylib.util.StopWatch; | ||
|
||
import edu.wpi.first.wpilibj.AddressableLEDBuffer; | ||
|
||
public class LED694 implements LEDInstruction { | ||
private SLColor[] colorMap = {SLColor.RED, SLColor.WHITE}; | ||
private ArrayList<Integer> colorArray = initColors(); | ||
private StopWatch stopWatch = new StopWatch(); | ||
|
||
@Override | ||
public void setLED(AddressableLEDBuffer ledBuffer) { | ||
double pulseTime = 0.01; | ||
|
||
|
||
for (int i = 0; i < ledBuffer.getLength(); i++) { | ||
ledBuffer.setLED(i, colorMap[colorArray.get(i)]); | ||
} | ||
|
||
if (pulseTime < stopWatch.getTime()){ | ||
int firstColor = colorArray.get(0); | ||
for (int i = 1; i < colorArray.size(); i++){ | ||
colorArray.set(i - 1, colorArray.get(i)); | ||
} | ||
colorArray.set(colorArray.size() - 1, firstColor); | ||
|
||
stopWatch.reset(); | ||
} | ||
} | ||
|
||
|
||
private static ArrayList<Integer> initColors() { | ||
ArrayList<Integer> colors = new ArrayList<>(); | ||
for (int i = 0; i < 6; i++) colors.add(0); | ||
for (int i = 0; i < 6; i++) colors.add(1); | ||
for (int i = 0; i < 9; i++) colors.add(0); | ||
for (int i = 0; i < 9; i++) colors.add(1); | ||
for (int i = 0; i < 4; i++) colors.add(0); | ||
for (int i = 0; i < 4; i++) colors.add(1); | ||
return colors; | ||
} | ||
|
||
} |