當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.whenPressed方法代碼示例

本文整理匯總了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());
    }
 
開發者ID:frc3946,項目名稱:Stronghold,代碼行數:29,代碼來源:OI.java

示例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());
}
 
開發者ID:steelhawks,項目名稱:ProjectShifter,代碼行數:9,代碼來源:OI.java

示例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());
}
 
開發者ID:SaintsRobotics,項目名稱:TreeShirtCannon-2015,代碼行數:8,代碼來源:OI.java

示例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());
}
 
開發者ID:SaintsRobotics,項目名稱:Vision,代碼行數:6,代碼來源:OI.java

示例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");
    }
}
 
開發者ID:BadRobots1014,項目名稱:BadRobot2013,代碼行數:50,代碼來源:OI.java

示例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);
}
 
開發者ID:Team2537,項目名稱:Cogsworth,代碼行數:13,代碼來源:HumanInput.java


注:本文中的edu.wpi.first.wpilibj.buttons.Button.whenPressed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。