diff --git a/src/org/usfirst/frc/team2059/robot/OI.java b/src/org/usfirst/frc/team2059/robot/OI.java index 2aedf35..75f0cbd 100644 --- a/src/org/usfirst/frc/team2059/robot/OI.java +++ b/src/org/usfirst/frc/team2059/robot/OI.java @@ -1,30 +1,29 @@ package org.usfirst.frc.team2059.robot; +import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.buttons.JoystickButton; +import org.usfirst.frc.team2059.robot.commands.LogEncoder; /** * This class is the glue that binds the controls on the physical operator * interface to the commands and command groups that allow control of the robot. */ public class OI { - //// CREATING BUTTONS - // One type of button is a joystick button which is any button on a joystick. - // You create one by telling it which joystick it's on and which button - // number it is. - // Joystick stick = new Joystick(port); - // Button button = new JoystickButton(stick, buttonNumber); - // There are a few additional built in buttons you can use. Additionally, - // by subclassing Button you can create custom triggers and bind those to - // commands the same as any other Button. - //// TRIGGERING COMMANDS WITH BUTTONS - // Once you have a button, it's trivial to bind it to a button in one of - // three ways: - // Start the command when the button is pressed and let it run the command - // until it is finished as determined by it's isFinished method. - // button.whenPressed(new ExampleCommand()); - // Run the command while the button is being held down and interrupt it once - // the button is released. - // button.whileHeld(new ExampleCommand()); - // Start the command when the button is released and let it run the command - // until it is finished as determined by it's isFinished method. - // button.whenReleased(new ExampleCommand()); + JoystickButton[][] joystickButtons; + Joystick[] joysticks; + public OI() { + // Create joysticks + joysticks[0] = new Joystick(1); + joysticks[1] = new Joystick(2); + // Create buttons + for(int i=0;i<12;i++) { + joystickButtons[0][i] = new JoystickButton(joysticks[0], i + 1); + joystickButtons[1][i] = new JoystickButton(joysticks[1], i + 1); + } + // Start logging with button1, stop with button2 + Command logEncoder = new LogEncoder(); + joystickButtons[0][0].whenPressed(logEncoder); + joystickButtons[0][1].cancelWhenPressed(logEncoder); + } } // vim: sw=2:ts=2:sts=2 diff --git a/src/org/usfirst/frc/team2059/robot/commands/Drive.java b/src/org/usfirst/frc/team2059/robot/commands/Drive.java index fdb1fe9..eeb9918 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/Drive.java +++ b/src/org/usfirst/frc/team2059/robot/commands/Drive.java @@ -24,4 +24,4 @@ public class Drive extends Command { protected void interrupted() { } } -// vim: sw=2:ts=2:sts=2 \ No newline at end of file +// vim: sw=2:ts=2:sts=2 diff --git a/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java b/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java new file mode 100644 index 0000000..76fa364 --- /dev/null +++ b/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java @@ -0,0 +1,18 @@ +package org.usfirst.frc.team2059.robot.commands; +import edu.wpi.first.wpilibj.command.Command; +public class LogEncoder extends Command { + public LogEncoder() { + } + protected void initialize() { + } + protected boolean isFinished() { + return false; + } + protected void execute() { + } + protected void end() { + } + protected void interrupted() { + } +} +// vim: sw=2:ts=2:sts=2