mirror of
https://github.com/Team4388/Robot-Essentials.git
synced 2026-06-09 08:48:02 -06:00
LED Command Based
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "edu.wpi.first.GradleRIO" version "2019.4.1"
|
id "edu.wpi.first.GradleRIO" version "2019.1.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
def ROBOT_MAIN_CLASS = "frc4388.robot.Main"
|
def ROBOT_MAIN_CLASS = "frc4388.robot.Main"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class GamerMove extends Command {
|
|||||||
// Called repeatedly when this Command is scheduled to run
|
// Called repeatedly when this Command is scheduled to run
|
||||||
@Override
|
@Override
|
||||||
protected void execute() {
|
protected void execute() {
|
||||||
Robot.m_Drive.gamerMove();
|
Robot.m_Drive.driveWithInput(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
// Make this return true when this Command no longer needs to run execute()
|
||||||
|
|||||||
+3
-3
@@ -5,18 +5,18 @@
|
|||||||
/* the project. */
|
/* the project. */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
package frc4388.robot.commands;
|
package frc4388.robot.commands.LED;
|
||||||
|
|
||||||
import frc4388.robot.Robot;
|
import frc4388.robot.Robot;
|
||||||
import frc4388.robot.constants.LEDPatterns;
|
import frc4388.robot.constants.LEDPatterns;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj.command.Command;
|
||||||
|
|
||||||
public class setLEDPattern extends Command {
|
public class SetLEDPattern extends Command {
|
||||||
|
|
||||||
public static LEDPatterns m_pattern;
|
public static LEDPatterns m_pattern;
|
||||||
|
|
||||||
public setLEDPattern(LEDPatterns pattern) {
|
public SetLEDPattern(LEDPatterns pattern) {
|
||||||
requires(Robot.m_led);
|
requires(Robot.m_led);
|
||||||
m_pattern = pattern;
|
m_pattern = pattern;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* 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.commands.LED;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.command.Command;
|
||||||
|
import frc4388.robot.Robot;
|
||||||
|
|
||||||
|
public class UpdateLED extends Command {
|
||||||
|
public UpdateLED() {
|
||||||
|
// Use requires() here to declare subsystem dependencies
|
||||||
|
requires(Robot.m_led);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.m_led.updateLED();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make this return true when this Command no longer needs to run execute()
|
||||||
|
@Override
|
||||||
|
protected boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,12 +67,8 @@ public class Drive extends Subsystem {
|
|||||||
m_driveTrain.arcadeDrive(move, steer);
|
m_driveTrain.arcadeDrive(move, steer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gamerMove(){
|
|
||||||
m_driveTrain.arcadeDrive(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initDefaultCommand() {
|
public void initDefaultCommand(){
|
||||||
// Set the default command for a subsystem here.
|
// Set the default command for a subsystem here.
|
||||||
// setDefaultCommand(new MySpecialCommand());
|
// setDefaultCommand(new MySpecialCommand());
|
||||||
setDefaultCommand(new DriveWithJoystick());
|
setDefaultCommand(new DriveWithJoystick());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
package frc4388.robot.subsystems;
|
package frc4388.robot.subsystems;
|
||||||
|
|
||||||
import frc4388.robot.RobotMap;
|
import frc4388.robot.RobotMap;
|
||||||
|
import frc4388.robot.commands.LED.UpdateLED;
|
||||||
import frc4388.robot.constants.LEDPatterns;
|
import frc4388.robot.constants.LEDPatterns;
|
||||||
import edu.wpi.first.wpilibj.Spark;
|
import edu.wpi.first.wpilibj.Spark;
|
||||||
import edu.wpi.first.wpilibj.command.Subsystem;
|
import edu.wpi.first.wpilibj.command.Subsystem;
|
||||||
@@ -27,9 +28,8 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
|||||||
LEDController.set(currentLED);
|
LEDController.set(currentLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void periodic() {
|
public void updateLED(){
|
||||||
LEDController.set(currentLED);
|
LEDController.set(currentLED);
|
||||||
SmartDashboard.putNumber("LED", currentLED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPattern(LEDPatterns pattern){
|
public void setPattern(LEDPatterns pattern){
|
||||||
@@ -37,7 +37,15 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
|||||||
LEDController.set(currentLED);
|
LEDController.set(currentLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void periodic(){
|
||||||
|
SmartDashboard.putNumber("LED", currentLED);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initDefaultCommand() {
|
public void initDefaultCommand() {
|
||||||
|
// Set the default command for a subsystem here.
|
||||||
|
// setDefaultCommand(new MySpecialCommand());
|
||||||
|
setDefaultCommand(new UpdateLED());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user