added the commands to buttons
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / OI.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.commandgroups.PrepareToShoot;
4 import org.usfirst.frc.team3501.robot.commandgroups.Shoot;
5 import org.usfirst.frc.team3501.robot.commands.climber.RunWinchContinuous;
6 import org.usfirst.frc.team3501.robot.commands.climber.StopWinch;
7 import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
8 import org.usfirst.frc.team3501.robot.commands.driving.Turn90Left;
9 import org.usfirst.frc.team3501.robot.commands.driving.Turn90Right;
10 import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
11 import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
12 import org.usfirst.frc.team3501.robot.commands.intake.StopIntake;
13 import org.usfirst.frc.team3501.robot.commands.shooter.DecreaseShootingSpeed;
14 import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed;
15 import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous;
16 import org.usfirst.frc.team3501.robot.commands.shooter.StopIndexWheel;
17
18 import edu.wpi.first.wpilibj.Joystick;
19 import edu.wpi.first.wpilibj.buttons.Button;
20 import edu.wpi.first.wpilibj.buttons.JoystickButton;
21
22 public class OI {
23 private static OI oi;
24 public static Joystick leftJoystick;
25 public static Joystick rightJoystick;
26
27 public static Button toggleWinch;
28
29 public static Button toggleIndexWheel;
30 public static Button toggleFlyWheel;
31
32 public static Button toggleIntake;
33 public static Button toggleReverseIntake;
34
35 public static Button toggleGearSpeed;
36
37 public static Button increaseShootSpeed;
38 public static Button decreaseShootSpeed;
39
40 public static Button turn90Right;
41 public static Button turn90Left;
42
43 public static Button readyShooter;
44 public static Button shootButton;
45
46 public OI() {
47 System.out.println("OI is open");
48 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
49 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
50
51 shootButton = new JoystickButton(rightJoystick,
52 Constants.OI.RIGHT_TRIGGER_BUTTON);
53 toggleWinch = new JoystickButton(rightJoystick,
54 Constants.OI.RIGHT_BUTTON_1);
55 readyShooter = new JoystickButton(rightJoystick,
56 Constants.OI.RIGHT_BUTTON_2);
57 increaseShootSpeed = new JoystickButton(rightJoystick,
58 Constants.OI.RIGHT_BUTTON_5);
59 decreaseShootSpeed = new JoystickButton(rightJoystick,
60 Constants.OI.RIGHT_BUTTON_6);
61
62 toggleIntake = new JoystickButton(leftJoystick,
63 Constants.OI.LEFT_TRIGGER_BUTTON);
64 toggleGearSpeed = new JoystickButton(leftJoystick,
65 Constants.OI.LEFT_BUTTON_2);
66 toggleIndexWheel = new JoystickButton(leftJoystick,
67 Constants.OI.LEFT_BUTTON_2);
68 toggleFlyWheel = new JoystickButton(leftJoystick,
69 Constants.OI.LEFT_BUTTON_2);
70 // toggleIntake = new JoystickButton(leftJoystick,
71 // Constants.OI.LEFT_BUTTON_3);
72 toggleReverseIntake = new JoystickButton(leftJoystick,
73 Constants.OI.LEFT_BUTTON_4);
74 turn90Right = new JoystickButton(leftJoystick, Constants.OI.LEFT_BUTTON_5);
75 turn90Left = new JoystickButton(leftJoystick, Constants.OI.LEFT_BUTTON_6);
76
77 toggleWinch.whenActive(new RunWinchContinuous(1));
78 toggleWinch.whenReleased(new StopWinch());
79
80 toggleIndexWheel.whenPressed(new RunIndexWheelContinuous(1));
81
82 toggleIntake.whenActive(new RunIntakeContinuous());
83 toggleReverseIntake.whenActive(new ReverseIntakeContinuous());
84 toggleIntake.whenReleased(new StopIntake());
85 toggleReverseIntake.whenReleased(new StopIntake());
86
87 toggleGearSpeed.whenPressed(new ToggleGear());
88
89 increaseShootSpeed.whenPressed(new IncreaseShootingSpeed());
90 decreaseShootSpeed.whenPressed(new DecreaseShootingSpeed());
91
92 turn90Right.whenPressed(new Turn90Right());
93 turn90Left.whenPressed(new Turn90Left());
94
95 readyShooter.whenPressed(new PrepareToShoot());
96 shootButton.whenActive(new Shoot());
97 shootButton.whenReleased(new StopIndexWheel());
98 }
99
100 public static OI getOI() {
101 if (oi == null)
102 oi = new OI();
103 return oi;
104 }
105 }