Skip to content

Commit

Permalink
Adds new LEDInstruction for the robot in the disabled state. (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
Material-Energy authored Mar 27, 2024
1 parent 6479fc4 commit 3cff974
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/com/stuypulse/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.stuypulse.robot.constants.Settings.RobotType;
import com.stuypulse.robot.constants.Settings.Amper.Lift;
import com.stuypulse.robot.constants.Settings.Amper.Score;
import com.stuypulse.robot.subsystems.leds.instructions.LED694;
import com.stuypulse.robot.subsystems.leds.instructions.LEDAlign;
import com.stuypulse.robot.subsystems.leds.instructions.LEDAutonChooser;
import com.stuypulse.robot.subsystems.leds.instructions.LEDRainbow;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void disabledInit() {
robot.intake.setIdleMode(IdleMode.kCoast);
robot.conveyor.setIdleMode(IdleMode.kCoast);

scheduler.schedule(new LEDSet(new LEDRainbow()));
scheduler.schedule(new LEDSet(new LED694()));

SmartDashboard.putString("Robot State", "DISABLED");
}
Expand Down
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;
}

}

0 comments on commit 3cff974

Please sign in to comment.