CommandGenericHID

final class commands2.button.CommandGenericHID(hid: int | GenericHID)[source]

Bases: object

A version of wpilib.GenericHID with Trigger factories for command-based.

Construct an instance of a device.

Parameters:

hid – The port on the Driver Station that the device is plugged into, or the GenericHID object to use for this command HID.

axis_greater_than(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.

axis_less_than(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.

axis_magnitude_greater_than(axis: int, threshold: float, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance that is true when the axis magnitude 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 magnitude is greater than the provided threshold.

button(button: int, loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around this button’s digital signal.

Parameters:
Returns:

A trigger instance attached to the event loop

classmethod get_command_generic_hid(port: int) CommandGenericHID[source]

Gets the CommandGenericHID object for the given port.

get_hid() GenericHID[source]

Get the underlying GenericHID object.

get_raw_axis(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.

is_connected()[source]

Get if the HID is connected.

Returns:

True if the HID is connected.

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:
Returns:

a Trigger instance based around this angle of a POV on the HID.

pov_center() 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.get_default_button_loop().

Returns:

a Trigger instance based around the center position of a POV on the HID.

pov_down() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 180 degree angle of a POV on the HID.

pov_down_left() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 225 degree angle of a POV on the HID.

pov_down_right() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 135 degree angle of a POV on the HID.

pov_left() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 270 degree angle of a POV on the HID.

pov_right() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 90 degree angle of a POV on the HID.

pov_up() 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.get_default_button_loop()

Returns:

a Trigger instance based around the 0 degree angle of a POV on the HID.

pov_up_left() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 315 degree angle of a POV on the HID.

pov_up_right() 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.get_default_button_loop().

Returns:

a Trigger instance based around the 45 degree angle of a POV on the HID.

set_rumble(type: RumbleType, value: float)[source]

Set the rumble output for the HID. The DS currently supports 2 rumble values, left rumble and right rumble.

Parameters:
  • type – Which rumble value to set.

  • value – The normalized value (0 to 1) to set the rumble to.