CommandGenericHID
- class commands2.button.CommandGenericHID(port: int)[source]
Bases:
object
A version of
wpilib.interfaces.GenericHID
withTrigger
factories for command-based.Construct an instance of a device.
- Parameters:
port – The port on the Driver Station that the device is plugged into.
- axisGreaterThan(axis: int, threshold: float, loop: EventLoop | None = None) Trigger [source]
Constructs a Trigger instance that is true when the axis value is greater than
threshold
, attached to the given loop.- Parameters:
axis – The axis to read, starting at 0
threshold – The value above which this trigger should return true.
loop – the event loop instance to attach the trigger to.
- Returns:
a Trigger instance that is true when the axis value is greater than the provided threshold.
- axisLessThan(axis: int, threshold: float, loop: EventLoop | None = None) Trigger [source]
Constructs a Trigger instance that is true when the axis value is less than
threshold
, attached to the given loop.- Parameters:
axis – The axis to read, starting at 0
threshold – The value below which this trigger should return true.
loop – the event loop instance to attach the trigger to
- Returns:
a Trigger instance that is true when the axis value is less than the provided threshold.
- button(button: int, loop: EventLoop | None = None) Trigger [source]
Constructs an event instance around this button’s digital signal.
- Parameters:
button – The button index
loop – the event loop instance to attach the event to, defaults to
commands2.CommandScheduler.getDefaultButtonLoop()
- Returns:
A trigger instance attached to the event loop
- getHID() GenericHID [source]
Get the underlying GenericHID object.
- getRawAxis(axis: int) float [source]
Get the value of the axis.
- Parameters:
axis – The axis to read, starting at 0.
- Returns:
The value of the axis.
- pov(angle: int, *, pov: int = 0, loop: EventLoop | None = None) Trigger [source]
Constructs a Trigger instance based around this angle of a POV on the HID.
The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90, upper-left is 315).
- Parameters:
angle – POV angle in degrees, or -1 for the center / not pressed.
pov – index of the POV to read (starting at 0). Defaults to 0.
loop – the event loop instance to attach the event to, defaults to
commands2.CommandScheduler.getDefaultButtonLoop()
- Returns:
a Trigger instance based around this angle of a POV on the HID.
- povCenter() Trigger [source]
Constructs a Trigger instance based around the center (not pressed) position of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the center position of a POV on the HID.
- povDown() Trigger [source]
Constructs a Trigger instance based around the 180 degree angle (down) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 180 degree angle of a POV on the HID.
- povDownLeft() Trigger [source]
Constructs a Trigger instance based around the 225 degree angle (down left) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 225 degree angle of a POV on the HID.
- povDownRight() Trigger [source]
Constructs a Trigger instance based around the 135 degree angle (right down) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 135 degree angle of a POV on the HID.
- povLeft() Trigger [source]
Constructs a Trigger instance based around the 270 degree angle (left) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 270 degree angle of a POV on the HID.
- povRight() Trigger [source]
Constructs a Trigger instance based around the 90 degree angle (right) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 90 degree angle of a POV on the HID.
- povUp() Trigger [source]
Constructs a Trigger instance based around the 0 degree angle (up) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
- Returns:
a Trigger instance based around the 0 degree angle of a POV on the HID.
- povUpLeft() Trigger [source]
Constructs a Trigger instance based around the 315 degree angle (left up) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 315 degree angle of a POV on the HID.
- povUpRight() Trigger [source]
Constructs a Trigger instance based around the 45 degree angle (right up) of the default (index 0) POV on the HID, attached to
commands2.CommandScheduler.getDefaultButtonLoop()
.- Returns:
a Trigger instance based around the 45 degree angle of a POV on the HID.