Skip to content
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

Better led -> master #79

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
27 changes: 13 additions & 14 deletions src/main/java/edu/greenblitz/tobyDetermined/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public void robotInit() {
SwerveChassis.getInstance().resetAllEncoders();
// SwerveChassis.getInstance().resetEncodersByCalibrationRod();


}

@Override
Expand All @@ -64,7 +63,7 @@ private static void initSubsystems() {
IntakeExtender.init();
IntakeRoller.init();
OI.init();

LED.init();
initToggleAbleSubsystems();
}

Expand Down Expand Up @@ -100,6 +99,7 @@ public void robotPeriodic() {
@Override
public void disabledInit() {
CommandScheduler.getInstance().cancelAll();
LED.getInstance().turnOff();
}


Expand Down Expand Up @@ -170,26 +170,25 @@ public void disabledPeriodic() {
// LED.getInstance().setColor(Color.kGreen);
// }

BreakCoastSwitch.getInstance().toggleBreakCoast();
if(Extender.getInstance().DidReset()){
LED.getInstance().setColor(Color.kGreen, RobotMap.LED.Sections.ARM_ENCODER_BROKEN);
}else{
LED.getInstance().setColor(Color.kRed, RobotMap.LED.Sections.ARM_ENCODER_BROKEN);
}

if (SwerveChassis.getInstance().isEncoderBroken()){
if (Extender.getInstance().DidReset()){
LED.getInstance().setColor(new Color(136, 8 ,90)); //dark red
} else {
LED.getInstance().setColor(Color.kRed);
}

} else if (!Extender.getInstance().DidReset()){
LED.getInstance().setColor(Color.kOrangeRed);
} else {
LED.getInstance().setColor(Color.kGreen);
if(SwerveChassis.getInstance().isEncoderBroken()){
LED.getInstance().setColor(Color.kRed, RobotMap.LED.Sections.SWERVE_ENCODER_BROKEN);
}else{
LED.getInstance().setColor(Color.kGreen, RobotMap.LED.Sections.SWERVE_ENCODER_BROKEN);
}


if(Extender.getInstance().getLimitSwitch()){
if (Extender.getInstance().getLength() > 0 || !Extender.getInstance().DidReset()) {
Extender.getInstance().resetLength();
}
}

SwerveChassis.getInstance().isEncoderBroken();
Elbow.getInstance().resetEncoder();
}
Expand Down
625 changes: 321 additions & 304 deletions src/main/java/edu/greenblitz/tobyDetermined/RobotMap.java

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import edu.greenblitz.tobyDetermined.commands.rotatingBelly.RotateOutDoorDirection;
import edu.greenblitz.tobyDetermined.subsystems.LED;
import edu.greenblitz.tobyDetermined.subsystems.RotatingBelly.RotatingBelly;
import edu.greenblitz.tobyDetermined.subsystems.telescopicArm.ObjectSelector;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.*;

Expand All @@ -26,7 +24,7 @@ public FullAlign(){
new RotateOutDoorDirection().until(()-> RotatingBelly.getInstance().isLimitSwitchPressed()),
new RotateOutDoorDirection().raceWith(new WaitCommand(EXTRA_TIME)),

new InstantCommand(()-> LED.getInstance().setColor(Color.kOrchid))
new InstantCommand(()-> LED.getInstance().setColor(Color.kOrchid, RobotMap.LED.Sections.ALL))
NoamRosenberg08 marked this conversation as resolved.
Show resolved Hide resolved
).raceWith(new WaitCommand(FINAL_TIME)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public void end(boolean interrupted) {
super.end(interrupted);
extender.resetLength();
extender.stop();
LED.getInstance().setColor(Color.kGreen);
LED.getInstance().setColor(Color.kGreen, RobotMap.LED.Sections.ALL);
NoamRosenberg08 marked this conversation as resolved.
Show resolved Hide resolved
}
}
41 changes: 25 additions & 16 deletions src/main/java/edu/greenblitz/tobyDetermined/subsystems/LED.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import edu.greenblitz.tobyDetermined.RobotMap;
import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.util.Color;

public class LED extends GBSubsystem {
Expand Down Expand Up @@ -31,45 +30,55 @@ public static void init(){
}
}

public void setColor(Color color) {
NoamRosenberg08 marked this conversation as resolved.
Show resolved Hide resolved
for (int i = 0; i < this.ledBuffer.getLength(); i++) {
this.ledBuffer.setLED(i, color);
SmartDashboard.putNumber("led num", i);
}
this.addressableLED.setData(ledBuffer);

public void setColor (Color color){
NoamRosenberg08 marked this conversation as resolved.
Show resolved Hide resolved
setColor(color, RobotMap.LED.Sections.ALL);
}
public void setColor(int i, Color color) {
this.ledBuffer.setLED(i, color);
this.addressableLED.setData(ledBuffer);
public void setColor(Color color, int index) {
this.ledBuffer.setLED(index, color);
}

public void setColor ( Color color,int startIndex,int endIndex){
for (int i = startIndex; i < endIndex; i++) {
setColor(color,i);
}
}

public void setColor (Color color, RobotMap.LED.Sections section){
setColor(color,section.start,section.end);
}

public void turnOff (){
setColor(new Color(0,0,0));
setColor(new Color(0,0,0),RobotMap.LED.Sections.ALL);
}

public void turnOff (int index){
setColor(index,new Color(0,0,0));
setColor(new Color(0,0,0),index);
}
public void turnoff (int startIndex,int endIndex){
public void turnOff (int startIndex,int endIndex){
for (int i = startIndex; i < endIndex; i++) {
setColor(i,new Color(0,0,0));
turnOff(i);
}
}
public void turnOff (RobotMap.LED.Sections section){
turnOff(section.start,section.end);
}



public void setHSV(int h, int s, int v) {
for (int i = 0; i < this.ledBuffer.getLength(); i++) {
this.ledBuffer.setHSV(i, h, s, v);
}
this.addressableLED.setData(ledBuffer);
}


public void setHSV(int index, int h, int s, int v) {
this.ledBuffer.setHSV(index, h, s, v);
this.addressableLED.setData(ledBuffer);
}

@Override
public void periodic() {
tnrz135 marked this conversation as resolved.
Show resolved Hide resolved
this.addressableLED.setData(ledBuffer);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.greenblitz.tobyDetermined.subsystems.telescopicArm;

import edu.greenblitz.tobyDetermined.RobotMap;
import edu.greenblitz.tobyDetermined.subsystems.LED;
import edu.wpi.first.wpilibj.util.Color;

Expand All @@ -8,13 +9,13 @@ public class ObjectSelector {

public static void selectCone(){
isCone = true;
LED.getInstance().setColor(Color.kYellow);
LED.getInstance().setColor(Color.kYellow, RobotMap.LED.Sections.ALL);
Claw.getInstance().coneCatchMode();
}

public static void selectCube(){
isCone = false;
LED.getInstance().setColor(Color.kMagenta);
LED.getInstance().setColor(Color.kYellow, RobotMap.LED.Sections.ALL);
Claw.getInstance().cubeCatchMode();
}

Expand Down