Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 6 additions & 7 deletions OffSeasonBot2019/src/main/java/com/team2813/frc2019/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

import com.ctre.phoenix.CANifier;
import com.team2813.frc2019.loops.Loop;
import com.team2813.frc2019.subsystems.Drive;
import com.team2813.frc2019.subsystems.MainIntake;
import com.team2813.frc2019.subsystems.Subsystem;
import com.team2813.frc2019.subsystems.Subsystems;
import com.team2813.frc2019.subsystems.*;
import com.team2813.lib.config.MotorConfigs;
import com.team2813.lib.util.CrashTracker;
import edu.wpi.first.wpilibj.Compressor;
Expand All @@ -39,7 +36,7 @@ public class Robot extends TimedRobot {
private static final double MIN_DISABLED_VOLTAGE = 12.0;
private static boolean batteryTooLow = false;

private CANifier caNifier = new CANifier(0);
private static Lightshow lightshow = new Lightshow(9);

/**
* This function is run when the robot is first started up and should be
Expand All @@ -50,6 +47,7 @@ public void robotInit() {
try {
CrashTracker.logRobotInit();
MotorConfigs.read();
lightshow.enable();
Subsystems.initializeSubsystems();
for (Subsystem subsystem : allSubsystems) {
LOOPER.addLoop(subsystem);
Expand Down Expand Up @@ -109,8 +107,8 @@ public void autonomousInit() {
// A: Green
// B: Red
// C: Blue
caNifier.setLEDOutput(255, CANifier.LEDChannel.LEDChannelA);
CrashTracker.logAutoInit();
// caNifier.setLEDOutput(255, CANifier.LEDChannel.LEDChannelA);
// CrashTracker.logAutoInit();
Compressor compressor = new Compressor(); // FIXME: 11/02/2019 this shouldn't need to be here
compressor.start();
MAIN_INTAKE.setMode(MainIntake.GamePiece.HATCH_PANEL);
Expand Down Expand Up @@ -157,6 +155,7 @@ public void teleopPeriodic() {
* this calls every subsystem's controls method which
* should contain any code to invoke driver controls
*/
// lightshow.test();
for (Subsystem subsystem : allSubsystems) {
subsystem.teleopControls();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.team2813.frc2019.subsystems;

import com.ctre.phoenix.CANifier;
import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.PWM;

public class Lightshow {
private DigitalOutput out;

private double output = 0;

Thread thread;

public Lightshow(int channel) {
this.out = new DigitalOutput(channel);
}

public void enable() {
out.enablePWM(0);
out.setPWMRate(4200);
thread = new Thread(() -> {
try {
while (true) {
out.updateDutyCycle(0);
System.out.println();
Thread.sleep(1000);
out.updateDutyCycle(.2);
System.out.println(.2);
Thread.sleep(1000);
out.updateDutyCycle(.4);
System.out.println(.4);
Thread.sleep(1000);
out.updateDutyCycle(.6);
System.out.println(out.get());
Thread.sleep(1000);
out.updateDutyCycle(.8);
System.out.println(.8);
Thread.sleep(1000);
out.updateDutyCycle(1);
System.out.println(1);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
});

thread.start();
}

public Lightshow disable() {
thread.stop();
return this;
}

// public CANifier setR(int red) {
// caNifier.x
// }
}


// 14