From 4de3492ed0468644046f1ae7a0857a8b1c30a86a Mon Sep 17 00:00:00 2001 From: "Keenan D. Buckley" Date: Mon, 11 Mar 2019 18:13:46 -0600 Subject: [PATCH] Command to set LED pattern --- .../frc4388/robot/commands/setLEDPattern.java | 51 +++++++++++++++++++ .../usfirst/frc4388/robot/subsystems/LED.java | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 2019robot/src/main/java/org/usfirst/frc4388/robot/commands/setLEDPattern.java diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/setLEDPattern.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/setLEDPattern.java new file mode 100644 index 0000000..be3a88d --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/setLEDPattern.java @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------------*/ +/* 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.commands; + +import org.usfirst.frc4388.robot.Robot; +import org.usfirst.frc4388.robot.constants.LEDPatterns; + +import edu.wpi.first.wpilibj.command.Command; + +public class setLEDPattern extends Command { + + LEDPatterns pattern; + + public setLEDPattern(LEDPatterns pattern) { + requires(Robot.led); + this.pattern = pattern; + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.led.setPattern(pattern); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + @Override + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} 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 index 8ac441e..9c03553 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/LED.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/LED.java @@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.command.Subsystem; public static final int LED_SPARK_ID = 0; public static float currentLED; - public Spark LEDController = new Spark(LED_SPARK_ID); + public static Spark LEDController = new Spark(LED_SPARK_ID); public LED(){ setPattern(LEDPatterns.RED);