forked from int0x191f2/ford-java
Create LogEncoder and map j1b1 to start logging and j1b2 to stop logging
This commit is contained in:
parent
ca5ee1198c
commit
4717100d78
@ -1,30 +1,29 @@
|
|||||||
package org.usfirst.frc.team2059.robot;
|
package org.usfirst.frc.team2059.robot;
|
||||||
|
import edu.wpi.first.wpilibj.Joystick;
|
||||||
import edu.wpi.first.wpilibj.buttons.Button;
|
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
|
* 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.
|
* interface to the commands and command groups that allow control of the robot.
|
||||||
*/
|
*/
|
||||||
public class OI {
|
public class OI {
|
||||||
//// CREATING BUTTONS
|
JoystickButton[][] joystickButtons;
|
||||||
// One type of button is a joystick button which is any button on a joystick.
|
Joystick[] joysticks;
|
||||||
// You create one by telling it which joystick it's on and which button
|
public OI() {
|
||||||
// number it is.
|
// Create joysticks
|
||||||
// Joystick stick = new Joystick(port);
|
joysticks[0] = new Joystick(1);
|
||||||
// Button button = new JoystickButton(stick, buttonNumber);
|
joysticks[1] = new Joystick(2);
|
||||||
// There are a few additional built in buttons you can use. Additionally,
|
// Create buttons
|
||||||
// by subclassing Button you can create custom triggers and bind those to
|
for(int i=0;i<12;i++) {
|
||||||
// commands the same as any other Button.
|
joystickButtons[0][i] = new JoystickButton(joysticks[0], i + 1);
|
||||||
//// TRIGGERING COMMANDS WITH BUTTONS
|
joystickButtons[1][i] = new JoystickButton(joysticks[1], i + 1);
|
||||||
// Once you have a button, it's trivial to bind it to a button in one of
|
}
|
||||||
// three ways:
|
// Start logging with button1, stop with button2
|
||||||
// Start the command when the button is pressed and let it run the command
|
Command logEncoder = new LogEncoder();
|
||||||
// until it is finished as determined by it's isFinished method.
|
joystickButtons[0][0].whenPressed(logEncoder);
|
||||||
// button.whenPressed(new ExampleCommand());
|
joystickButtons[0][1].cancelWhenPressed(logEncoder);
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
// vim: sw=2:ts=2:sts=2
|
// vim: sw=2:ts=2:sts=2
|
||||||
|
@ -24,4 +24,4 @@ public class Drive extends Command {
|
|||||||
protected void interrupted() {
|
protected void interrupted() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// vim: sw=2:ts=2:sts=2
|
// vim: sw=2:ts=2:sts=2
|
||||||
|
18
src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java
Normal file
18
src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user