本文整理汇总了Java中edu.wpi.first.wpilibj.buttons.Button.whenPressed方法的典型用法代码示例。如果您正苦于以下问题:Java Button.whenPressed方法的具体用法?Java Button.whenPressed怎么用?Java Button.whenPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.buttons.Button
的用法示例。
在下文中一共展示了Button.whenPressed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OI
import edu.wpi.first.wpilibj.buttons.Button; //导入方法依赖的package包/类
public OI() {
leftController.setDeadband(0.2);
rightController.setDeadband(0.2);
//Catapult
Button launch = new JoystickButton(leftController, XboxController.RightBumper);
//Button autoAim = new JoystickButton(driveController, XboxController.Start);
Button lockLatch = new JoystickButton(leftController, XboxController.LeftBumper);
Button LaunchGroup = new JoystickButton(leftController, XboxController.Back);
launch.whenPressed(new Launch());
lockLatch.whenPressed(new LockLatch());
//autoAim.whenPressed(new AutoAim());
LaunchGroup.whenPressed(new LaunchGroup());
//Intake
Button lowerIntake = new JoystickButton(leftController, XboxController.X);
Button raiseIntake = new JoystickButton(leftController, XboxController.Y);
Button posCatForLoad = new JoystickButton(leftController, XboxController.B);
Button posCatForLaunch = new JoystickButton(leftController, XboxController.A);
lowerIntake.whenPressed(new LowerIntake());
raiseIntake.whenPressed(new RaiseIntake());
posCatForLoad.whenPressed(new PosCatForLoad());
posCatForLaunch.whenPressed(new PosCatForLaunch()) ;
// //Driving
// Button switchDirection = new JoystickButton(driveController, XboxController.Start);
// switchDirection.whenPressed(new SwitchDirection());
}
示例2: OI
import edu.wpi.first.wpilibj.buttons.Button; //导入方法依赖的package包/类
public OI(){
leftStick = new Joystick(1);
rightStick = new Joystick(2);
Button leftShift = new JoystickButton(leftStick, 1);
Button rightShift = new JoystickButton(rightStick, 1);
leftShift.whenPressed(new Shift());
rightShift.whenPressed(new Shift());
}
示例3: OI
import edu.wpi.first.wpilibj.buttons.Button; //导入方法依赖的package包/类
public OI() {
xbox = new Joystick(JOYSTICK_PORT);
Button a = new JoystickButton(xbox, BUTTON_A);
Button rb = new JoystickButton(xbox, BUTTON_RB);
a.whenPressed(new FireCommand());
rb.whenPressed(new ReloadCommand());
}
示例4: OI
import edu.wpi.first.wpilibj.buttons.Button; //导入方法依赖的package包/类
public OI() {
xbox = new Joystick(JOYSTICK_PORT);
Button a = new JoystickButton(xbox, BUTTON_A);
a.whenPressed(new TurnToFaceTapeCommand());
}
示例5: init
import edu.wpi.first.wpilibj.buttons.Button; //导入方法依赖的package包/类
public void init() {
primaryXboxController = new Joystick(PRIMARY_JOY);
secondaryXboxController = new Joystick(SECONDARY_JOY);
ALLIANCE_COLOR = DriverStation.getInstance().getAlliance().value;
SmartDashboard.putBoolean("Alliance", ALLIANCE_COLOR == DriverStation.Alliance.kBlue_val);
preferencesManagers = BadPreferences.getInstance();
//button that senses seconadry Right bumper press for shooter injection
/*if (CommandBase.frisbeePusher != null)
{
Button injectFrisbee = new Button() {
public boolean get()
{
return (secondaryXboxController.getRawButton(RB));
}
};
injectFrisbee.whenPressed(new InjectFrisbee());
}*/
//press A to climb
//if (CommandBase.climberArticulator != null) {
Button climb = new Button() {
public boolean get() {
return (OI.getPrimaryRightTrigger() > 0);
}
};
climb.whenPressed(new ClimbForTenPoints());
//}
if (CommandBase.shooterArticulator != null)
{
Button aim = new Button()
{
public boolean get()
{
return (isPrimaryYButtonPressed());
}
};
aim.whenPressed(new AimWithCamera());
}
if (!this.CONSOLE_OUTPUT_ENABLED) {
System.out.println("Console output has been disabled from OI");
}
}
示例6: registerWhenPressedCommand
import edu.wpi.first.wpilibj.buttons.Button; //导入方法依赖的package包/类
/**
* Register button to command
*
* @param b
* button to register command to
*
* @param c
* command to register to button
*/
public static void registerWhenPressedCommand(Button b, Command c) {
b.whenPressed(c);
}