mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[robotpy] Mirror robotpy's commands-v2 (#8369)
Project import generated by Copybara. GitOrigin-RevId: 715c8e8372d936f447f2937aab6b1a22dc619126
This commit is contained in:
20
commandsv2/src/main/python/commands2/button/povbutton.py
Normal file
20
commandsv2/src/main/python/commands2/button/povbutton.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# validated: 2024-01-20 DS 7a099cb02a33 button/POVButton.java
|
||||
from wpilib.interfaces import GenericHID
|
||||
|
||||
from .trigger import Trigger
|
||||
|
||||
|
||||
class POVButton(Trigger):
|
||||
"""
|
||||
A Button that gets its state from a POV on a :class:`wpilib.interfaces.GenericHID`.
|
||||
"""
|
||||
|
||||
def __init__(self, joystick: GenericHID, angle: int, povNumber: int = 0):
|
||||
"""
|
||||
Creates a POV button for triggering commands.
|
||||
|
||||
:param joystick: The GenericHID object that has the POV
|
||||
:param angle: The desired angle in degrees (e.g. 90, 270)
|
||||
:param povNumber: The POV number (see :func:`wpilib.interfaces.GenericHID.getPOV`)
|
||||
"""
|
||||
super().__init__(lambda: joystick.getPOV(povNumber) == angle)
|
||||
Reference in New Issue
Block a user