Files

88 lines
2.5 KiB
Java
Raw Permalink Normal View History

2020-01-09 23:55:46 +00:00
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc4388.robot.subsystems;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.robot.Constants.LEDConstants;
import frc4388.utility.LEDPatterns;
public class LED extends SubsystemBase {
public static float currentLED;
2020-03-09 17:56:52 -06:00
public static float defaultLED;
2020-01-09 23:55:46 +00:00
public static Spark LEDController;
/**
2020-01-30 22:00:52 -07:00
* Creates a new LED to run a 5v LED Strip using a Rev
* Robotics Blinkin LED Driver
2020-01-09 23:55:46 +00:00
*/
public LED(){
LEDController = new Spark(LEDConstants.LED_SPARK_ID);
2020-03-09 17:56:52 -06:00
defaultLED = LEDConstants.DEFAULT_PATTERN.getValue();
runDefaultLED();
2020-01-09 23:55:46 +00:00
LEDController.set(currentLED);
System.err.println("In the Beginning, there was Joe.\nAnd he said, 'Let there be LEDs.'\nAnd it was good.");
}
/**
2020-01-30 22:00:52 -07:00
* Sends an update to the LED Driver with the current LED value.
* This method should be run continously to keep the lights on.
2020-01-09 23:55:46 +00:00
*/
public void updateLED(){
LEDController.set(currentLED);
}
2020-03-09 17:56:52 -06:00
/**
*
*/
public void runDefaultLED() {
setPattern(defaultLED);
}
/**
* Changes the default LED by an amount
* @param amount the amount to increment led by
*/
public void incrementLED(float amount) {
defaultLED += amount;
if (defaultLED > 1) {
defaultLED -= 2;
}
if (defaultLED < -1) {
defaultLED += 2;
}
}
/**
* Sets the current LED pattern. This method should only be run
* whenever you want to change the current LED.
* @param pattern LEDPattern to set the Blinkin to.
*/
public void setPattern(float pattern){
currentLED = pattern;
LEDController.set(pattern);
}
2020-01-09 23:55:46 +00:00
/**
2020-01-30 22:00:52 -07:00
* Sets the current LED pattern. This method should only be run
* whenever you want to change the current LED.
* @param pattern LEDPattern to set the Blinkin to.
2020-01-09 23:55:46 +00:00
*/
public void setPattern(LEDPatterns pattern){
currentLED = pattern.getValue();
LEDController.set(currentLED);
}
@Override
public void periodic(){
2020-03-02 22:32:29 -07:00
//SmartDashboard.putNumber("LED", currentLED);
2020-01-09 23:55:46 +00:00
}
}