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

simple lights red when we are in endgame #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/com/team766/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;


/**
* This class is the glue that binds the controls on the physical operator
* interface to the code that allow control of the robot.
Expand Down Expand Up @@ -66,6 +67,7 @@ public void run(Context context) {
context.takeOwnership(Robot.drive);
// context.takeOwnership(Robot.intake);
context.takeOwnership(Robot.gyro);
context.takeOwnership(Robot.lights);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should only grab ownership of lights for the small chunk where needed (below) as other mechanisms will also use Lights.


while (true) {
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData());
Expand All @@ -87,6 +89,9 @@ public void run(Context context) {
// SmartDashboard.putString("Alliance", "NULLLLLLLLL");
// }

if(DriverStation.isTeleop() && DriverStation.getMatchTime() < 30){
Robot.lights.signalMalfunction();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why malfunction?

}

if (leftJoystick.getButtonPressed(InputConstants.RESET_GYRO)) {
Robot.gyro.resetGyro();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/team766/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public class Robot {
// public static Intake intake;
public static Drive drive;
public static Gyro gyro;
public static Lights lights;

public static void robotInit() {
// Initialize mechanisms here
// intake = new Intake();
drive = new Drive();
gyro = new Gyro();
lights = new Lights();
}
}
25 changes: 22 additions & 3 deletions src/main/java/com/team766/robot/mechanisms/Lights.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
package com.team766.robot.mechanisms;
import com.ctre.phoenix.led.CANdle;
import com.ctre.phoenix.led.RainbowAnimation;
import com.team766.framework.Mechanism;


public class Lights extends Mechanism{

private CANdle candle;
private static final int CANID = 5;
private int numLEDs = 8;
RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, numLEDs);

public Lights(){
candle = new CANdle(CANID);

}

public void purple(){
public void setNumLEDs(int num){
checkContextOwnership();
numLEDs = num;
rainbowAnim.setNumLed(num);
}

public void signalCube(){
checkContextOwnership();
candle.setLEDs(128, 0, 128);
}

public void white(){
public void resetLights(){
checkContextOwnership();
candle.setLEDs(255, 255, 255);
}

public void yellow(){
public void signalCone(){
checkContextOwnership();
candle.setLEDs(255, 255, 0);
}

public void signalMalfunction(){
checkContextOwnership();
candle.setLEDs(255, 0, 0);
}

public void signalBalance(){
checkContextOwnership();
candle.animate(rainbowAnim);
}
}