From 99930d533f8497ea86da1efb36847efe7ec5914c Mon Sep 17 00:00:00 2001 From: Rohan Rodrigues Date: Thu, 2 Mar 2017 17:16:34 -0800 Subject: [PATCH] Fix ChangeCameraView --- src/org/usfirst/frc/team3501/robot/OI.java | 23 +++++++++++- src/org/usfirst/frc/team3501/robot/Robot.java | 8 ++++- .../robot/utils/ChangeCameraView.java | 36 +++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/org/usfirst/frc/team3501/robot/utils/ChangeCameraView.java diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index 243e330..bf3c20f 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -1,5 +1,8 @@ package org.usfirst.frc.team3501.robot; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch; import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear; import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous; @@ -9,12 +12,13 @@ import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed; import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuous; import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous; import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous; +import org.usfirst.frc.team3501.robot.utils.ChangeCameraView; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.buttons.JoystickButton; -public class OI { +public class OI implements KeyListener { private static OI oi; public static Joystick leftJoystick; public static Joystick rightJoystick; @@ -83,4 +87,21 @@ public class OI { oi = new OI(); return oi; } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + + } } diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 1278a33..e72f07e 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -16,6 +16,7 @@ public class Robot extends IterativeRobot { private static Shooter shooter; private static OI oi; private static Intake intake; + private static CameraServer server; @Override public void robotInit() { @@ -23,7 +24,7 @@ public class Robot extends IterativeRobot { oi = OI.getOI(); shooter = Shooter.getShooter(); intake = Intake.getIntake(); - CameraServer server = CameraServer.getInstance(); + server = CameraServer.getInstance(); UsbCamera climberCam = server.startAutomaticCapture("climbercam", 0); UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 1); } @@ -45,6 +46,11 @@ public class Robot extends IterativeRobot { return Intake.getIntake(); } + public static void swapCameraFeed() { + UsbCamera climberCam = server.startAutomaticCapture("climbercam", 1); + UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 0); + } + // If the gear values do not match in the left and right piston, then they are // both set to high gear @Override diff --git a/src/org/usfirst/frc/team3501/robot/utils/ChangeCameraView.java b/src/org/usfirst/frc/team3501/robot/utils/ChangeCameraView.java new file mode 100644 index 0000000..9615c4e --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/utils/ChangeCameraView.java @@ -0,0 +1,36 @@ +package org.usfirst.frc.team3501.robot.utils; + +import org.usfirst.frc.team3501.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class ChangeCameraView extends Command { + + public ChangeCameraView() { + } + + @Override + protected void initialize() { + } + + @Override + protected void execute() { + Robot.swapCameraFeed(); + } + + @Override + protected boolean isFinished() { + return true; + } + + @Override + protected void end() { + } + + @Override + protected void interrupted() { + } +} -- 2.30.2