2019-08-04 16:19:40 -06: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.command.Subsystem;
|
|
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
|
|
|
|
|
2020-01-05 17:35:52 -07:00
|
|
|
import frc4388.robot.Constants.LEDConstants;
|
|
|
|
|
import frc4388.robot.commands.LED.UpdateLED;
|
|
|
|
|
import frc4388.robot.constants.LEDPatterns;
|
|
|
|
|
|
2019-08-04 16:19:40 -06:00
|
|
|
/**
|
|
|
|
|
* Allows for the control of a 5v LED Strip using a Rev Robotics Blinkin LED Driver
|
|
|
|
|
*/
|
|
|
|
|
public class LED extends Subsystem {
|
|
|
|
|
|
|
|
|
|
public static float currentLED;
|
|
|
|
|
public static Spark LEDController;
|
|
|
|
|
|
|
|
|
|
public LED(){
|
2020-01-05 17:35:52 -07:00
|
|
|
LEDController = new Spark(LEDConstants.LED_SPARK_ID);
|
2019-08-04 16:19:40 -06:00
|
|
|
setPattern(LEDPatterns.FOREST_WAVES);
|
|
|
|
|
LEDController.set(currentLED);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-21 20:41:34 -07:00
|
|
|
public void updateLED(){
|
2019-08-04 16:19:40 -06:00
|
|
|
LEDController.set(currentLED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPattern(LEDPatterns pattern){
|
|
|
|
|
currentLED = pattern.getValue();
|
|
|
|
|
LEDController.set(currentLED);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-21 20:41:34 -07:00
|
|
|
@Override
|
|
|
|
|
public void periodic(){
|
|
|
|
|
SmartDashboard.putNumber("LED", currentLED);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-04 16:19:40 -06:00
|
|
|
@Override
|
|
|
|
|
public void initDefaultCommand() {
|
2019-12-21 20:41:34 -07:00
|
|
|
// Set the default command for a subsystem here.
|
|
|
|
|
// setDefaultCommand(new MySpecialCommand());
|
|
|
|
|
setDefaultCommand(new UpdateLED());
|
2019-08-04 16:19:40 -06:00
|
|
|
}
|
|
|
|
|
}
|