本文整理汇总了Java中edu.wpi.first.wpilibj.buttons.Trigger类的典型用法代码示例。如果您正苦于以下问题:Java Trigger类的具体用法?Java Trigger怎么用?Java Trigger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Trigger类属于edu.wpi.first.wpilibj.buttons包,在下文中一共展示了Trigger类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LimitSwitchedMotor
import edu.wpi.first.wpilibj.buttons.Trigger; //导入依赖的package包/类
/**
*
* @param controller The {@link SpeedController} that controls the motor.
* @param top The top {@link Trigger} (trigger at the positive end of the motor's output).
* @param topOnValue The value from the top {@link Trigger} where you want the motor to stop.
* @param bottom The bottom {@link Trigger} (trigger at the negative end of the motor's output).
* @param bottomOnValue The value from the bottom {@link Trigger} where you want the motor to stop.
*/
public LimitSwitchedMotor(SpeedController controller,Trigger top,boolean topOnValue,
Trigger bottom,boolean bottomOnValue) {
_controller = controller;
_top = top;
_bottom = bottom;
_bgThread.schedule(_bgTask, 0, (long)(DEFAULT_PERIOD*1000));
_topOn = topOnValue;
_bottomOn = bottomOnValue;
}
示例2: MultiTrigger
import edu.wpi.first.wpilibj.buttons.Trigger; //导入依赖的package包/类
public MultiTrigger(Trigger[] triggers){
this.triggers = triggers;
}
示例3: OI
import edu.wpi.first.wpilibj.buttons.Trigger; //导入依赖的package包/类
public OI() {
this.joystick = new XboxController(RobotMap.XBOX_CONTROLLER);
this.joystick2 = new XboxController(RobotMap.XBOX_CONTROLLER2);
this.buttonA2 = new JoystickButton(this.joystick2, 1);
this.buttonB2 = new JoystickButton(this.joystick2, 2);
this.buttonX2 = new JoystickButton(this.joystick2, 3);
this.buttonY2 = new JoystickButton(this.joystick2, 4);
this.buttonLeftBumper2 = new JoystickButton(this.joystick2, 5);
this.buttonRightBumper2 = new JoystickButton(this.joystick2, 6);
this.buttonBack2 = new JoystickButton(this.joystick2, 7);
this.buttonStart2 = new JoystickButton(this.joystick2, 8);
this.buttonLeftThumb2 = new JoystickButton(this.joystick2, 9);
this.buttonRightThumb2 = new JoystickButton(this.joystick2, 10);
this.dpadUp2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 0;}};
this.dpadUpRight2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 45;}};
this.dpadRight2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 90;}};
this.dpadDownRight2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 135;}};
this.dpadDown2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 180;}};
this.dpadDownLeft2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 225;}};
this.dpadLeft2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 270;}};
this.dpadUpLeft2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 315;}};
// mappings based on this post from CD...
// https://www.chiefdelphi.com/forums/attachment.php?attachmentid=20028&d=1455109186
this.buttonA = new JoystickButton(this.joystick, 1);
this.buttonB = new JoystickButton(this.joystick, 2);
this.buttonX = new JoystickButton(this.joystick, 3);
this.buttonY = new JoystickButton(this.joystick, 4);
this.buttonLeftBumper = new JoystickButton(this.joystick, 5);
this.buttonRightBumper = new JoystickButton(this.joystick, 6);
this.buttonBack = new JoystickButton(this.joystick, 7);
this.buttonStart = new JoystickButton(this.joystick, 8);
this.buttonLeftThumb = new JoystickButton(this.joystick, 9);
this.buttonRightThumb = new JoystickButton(this.joystick, 10);
this.dpadUp = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 0;}};
this.dpadUpRight = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 45;}};
this.dpadRight = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 90;}};
this.dpadDownRight = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 135;}};
this.dpadDown = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 180;}};
this.dpadDownLeft = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 225;}};
this.dpadLeft = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 270;}};
this.dpadUpLeft = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 315;}};
//this.buttonA.whenPressed(new DriveHeadingAndDistance(0, 1));
//this.buttonA.whenPressed(new DriveStraightCommand(5));
// this.buttonA.whenPressed(new DriveStraightCommand(5));
//this.buttonB.whenPressed(new TurnToHeading(180));
this.buttonRightBumper.whileHeld(new DeliverGearCommand());
this.buttonA2.whenPressed(new FeederCommand());
this.buttonB2.toggleWhenPressed(new ShooterCommand());
//this.buttonX2.whenPressed(new PushGear());
}