mirror of
https://github.com/Team4388/2019-Hit-or-Miss.git
synced 2026-06-09 00:28:05 -06:00
Code to test LEDs
When Y is pressed on the controller, the LEDs cycle through 3 modes. Just meant to test LEDs; final will probably be controlled differently.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "edu.wpi.first.GradleRIO" version "2019.1.1"
|
||||
id "edu.wpi.first.GradleRIO" version "2019.2.1"
|
||||
}
|
||||
|
||||
def ROBOT_MAIN_CLASS = "org.usfirst.frc4388.robot.Main"
|
||||
|
||||
@@ -60,7 +60,8 @@ public class OI
|
||||
JoystickButton shiftDown = new JoystickButton(m_driverXbox.getJoyStick(), XboxController.LEFT_BUMPER_BUTTON);
|
||||
shiftDown.whenPressed(new DriveSpeedShift(false));
|
||||
// shiftDown.whenPressed(new LEDIndicators(false));
|
||||
|
||||
|
||||
ledSwitch.whenPressed(new LedSwitch());
|
||||
|
||||
//Operator Xbox
|
||||
/*
|
||||
|
||||
@@ -17,15 +17,8 @@ public class RobotMap {
|
||||
public static final int DRIVETRAIN_RIGHT_MOTOR1_CAN_ID = 4;
|
||||
public static final int DRIVETRAIN_RIGHT_MOTOR2_CAN_ID = 5;
|
||||
|
||||
//carriage motors
|
||||
public static final int CARRIAGE_LEFT_MOTOR_CAN_ID = 8;
|
||||
public static final int CARRIAGE_RIGHT_MOTOR_CAN_ID = 9;
|
||||
|
||||
//Elevator Motors
|
||||
public static final int ELEVATOR_MOTOR1_ID = 6;
|
||||
public static final int ELEVATOR_MOTOR2_ID = 7;
|
||||
public static final int CLIMBER_CAN_ID = 10;
|
||||
|
||||
// LED
|
||||
public static final int LED_DRIVER = 0;
|
||||
|
||||
// Pneumatics
|
||||
public static final int DRIVETRAIN_SPEEDSHIFT_PCM_ID = 0;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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 edu.wpi.first.wpilibj.command.Command;
|
||||
|
||||
public class LedSwitch extends Command {
|
||||
public LedSwitch() {
|
||||
requires(LED);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
@Override
|
||||
protected void initialize() {
|
||||
float lastTime = System.currentTimeMillis;
|
||||
LED.mode1();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called repeatedly when this Command is scheduled to run. Cycles through 3 LED modes
|
||||
* before returning to begining
|
||||
*/
|
||||
@Override
|
||||
protected void execute() {
|
||||
if(System.currentTimeMillis>lastTime+30000){ //After 30 seconds
|
||||
LED.mode1();
|
||||
float lastTime = System.currentTimeMillis;
|
||||
}
|
||||
else if(System.currentTimeMillis>lastTime+20000){//After 20 seconds
|
||||
LED.mode3();
|
||||
}
|
||||
else if( System.currentTimeMillis>lastTime+10000){//After 10 seconds
|
||||
LED.mode2();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 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() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.usfirst.frc4388.robot.subsystems;
|
||||
|
||||
import org.usfirst.frc.team2848.robot.RobotMap;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.command.Subsystem;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class LED extends Subsystem {
|
||||
|
||||
//LED Spark controller
|
||||
public Spark LED1 = new Spark(RobotMap.LED_DRIVER);
|
||||
|
||||
|
||||
//public void initDefaultCommand() {}
|
||||
|
||||
//LED mode 1
|
||||
public void mode1() { ///TODO: name the modes
|
||||
LED1.set(-.57);
|
||||
}
|
||||
|
||||
//LED mode 2
|
||||
public void mode2() {
|
||||
LED1.set(.32);
|
||||
}
|
||||
|
||||
//LED mode 3
|
||||
public void mode3() {
|
||||
LED1.set(-.69);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user