001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.wpilibj2.command.button; 006 007import static edu.wpi.first.util.ErrorMessages.requireNonNullParam; 008 009import edu.wpi.first.wpilibj.GenericHID; 010 011/** 012 * A {@link Button} that gets its state from a POV on a {@link GenericHID}. 013 * 014 * <p>This class is provided by the NewCommands VendorDep 015 */ 016@SuppressWarnings("deprecation") 017public class POVButton extends Button { 018 /** 019 * Creates a POV button for triggering commands. 020 * 021 * @param joystick The GenericHID object that has the POV 022 * @param angle The desired angle in degrees (e.g. 90, 270) 023 * @param povNumber The POV number (see {@link GenericHID#getPOV(int)}) 024 */ 025 public POVButton(GenericHID joystick, int angle, int povNumber) { 026 super(() -> joystick.getPOV(povNumber) == angle); 027 requireNonNullParam(joystick, "joystick", "POVButton"); 028 } 029 030 /** 031 * Creates a POV button for triggering commands. By default, acts on POV 0 032 * 033 * @param joystick The GenericHID object that has the POV 034 * @param angle The desired angle (e.g. 90, 270) 035 */ 036 public POVButton(GenericHID joystick, int angle) { 037 this(joystick, angle, 0); 038 } 039}