Set up LEDs

This commit is contained in:
Keenan D. Buckley
2019-03-11 18:06:51 -06:00
parent 76f696d5a6
commit 0d26188761
3 changed files with 53 additions and 7 deletions
@@ -32,15 +32,11 @@ public class Robot extends TimedRobot
public static final Drive drive = new Drive();
public static final Arm arm = new Arm();
public static final Wrist wrist = new Wrist();
public static final BallIntake ballIntake = new BallIntake();
public static final Climber climber = new Climber();
public static final Pneumatics pnumatics = new Pneumatics();
public static final Pneumatics pnumatics = new Pneumatics();
public static final LED led = new LED();
public static final long periodMS = 10;
public static final ControlLooper controlLoop = new ControlLooper("Main control loop", periodMS);
@@ -0,0 +1,9 @@
package org.usfirst.frc4388.robot.constants;
public enum LEDPatterns {
RED(0.61f), BLACK(0.99f);
private final float id;
LEDPatterns(float id) { this.id = id; }
public float getValue() { return id; }
}
@@ -0,0 +1,41 @@
/*----------------------------------------------------------------------------*/
/* 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 org.usfirst.frc4388.robot.subsystems;
import java.util.HashMap;
import org.usfirst.frc4388.robot.constants.LEDPatterns;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.command.Subsystem;
/**
* Add your docs here.
*/
public class LED extends Subsystem {
public static final int LED_SPARK_ID = 0;
public static float currentLED;
public Spark LEDController = new Spark(LED_SPARK_ID);
public LED(){
setPattern(LEDPatterns.RED);
}
public void periodic() {
LEDController.set(currentLED);
}
public void setPattern(LEDPatterns pattern){
currentLED = pattern.getValue();
}
@Override
public void initDefaultCommand() {
}
}