From 0d261887618f3391fcbeddf8f8f4efb47645699f Mon Sep 17 00:00:00 2001 From: "Keenan D. Buckley" Date: Mon, 11 Mar 2019 18:06:51 -0600 Subject: [PATCH] Set up LEDs --- .../java/org/usfirst/frc4388/robot/Robot.java | 10 ++--- .../frc4388/robot/constants/LEDPatterns.java | 9 ++++ .../usfirst/frc4388/robot/subsystems/LED.java | 41 +++++++++++++++++++ 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 2019robot/src/main/java/org/usfirst/frc4388/robot/constants/LEDPatterns.java create mode 100644 2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/LED.java diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java index 340d148..864d3ce 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java @@ -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); diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/constants/LEDPatterns.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/constants/LEDPatterns.java new file mode 100644 index 0000000..44ecddc --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/constants/LEDPatterns.java @@ -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; } + } \ No newline at end of file diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/LED.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/LED.java new file mode 100644 index 0000000..8ac441e --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/LED.java @@ -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() { + } +} \ No newline at end of file