CommandSwitch2ProController
- class commands2.button.CommandSwitch2ProController(hid: int | Switch2ProController)[source]
Bases:
objectA version of
wpilib.Switch2ProControllerwithTriggerfactories for command-based.Construct an instance of a controller.
- Parameters:
hid – The port index on the Driver Station that the controller is plugged into, or the Switch2ProController object to use for this controller.
- a(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the A button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the A button’s digital signal attached to the given loop.
- axis_greater_than(axis: Axis, 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
wpilib.Switch2ProController.Axisto readthreshold – 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: Axis, 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
wpilib.Switch2ProController.Axisto readthreshold – 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: Axis, 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
wpilib.Switch2ProController.Axisto readthreshold – 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.
- b(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the B button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the B button’s digital signal attached to the given loop.
- button(button: Button, loop: EventLoop | None = None) Trigger[source]
Constructs an event instance around this button’s digital signal.
- Parameters:
button – the
wpilib.Switch2ProController.Buttonto readloop – the event loop instance to attach the event to
- c(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the C button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the C button’s digital signal attached to the given loop.
- capture(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Capture button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Capture button’s digital signal attached to the given loop.
- dpad_down(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Dpad Down button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Dpad Down button’s digital signal attached to the given loop.
- dpad_left(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Dpad Left button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Dpad Left button’s digital signal attached to the given loop.
- dpad_right(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Dpad Right button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Dpad Right button’s digital signal attached to the given loop.
- dpad_up(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Dpad Up button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Dpad Up button’s digital signal attached to the given loop.
- get_axis(axis: Axis) float[source]
Get the value of the axis.
- Parameters:
axis – the
wpilib.Switch2ProController.Axisto read
- get_controller() Switch2ProController[source]
Get the wrapped controller object.
- Returns:
the wrapped controller object
- get_hid() CommandGenericHID[source]
Get the underlying CommandGenericHID object.
- Returns:
the wrapped CommandGenericHID object
- gl(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the GL button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the GL button’s digital signal attached to the given loop.
- gr(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the GR button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the GR button’s digital signal attached to the given loop.
- home(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Home button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Home button’s digital signal attached to the given loop.
- l(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the L button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the L button’s digital signal attached to the given loop.
- left_stick(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Left Stick button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Left Stick button’s digital signal attached to the given loop.
- minus(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Minus button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Minus button’s digital signal attached to the given loop.
- plus(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Plus button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Plus button’s digital signal attached to the given loop.
- r(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the R button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the R button’s digital signal attached to the given loop.
- right_stick(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Right Stick button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Right Stick button’s digital signal attached to the given loop.
- x(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the X button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the X button’s digital signal attached to the given loop.
- y(loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the Y button’s digital signal.
- Parameters:
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()- Returns:
a Trigger instance representing the Y button’s digital signal attached to the given loop.
- zl(threshold: float = 0.5, loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the ZL axis value. The returned Trigger will be true when the axis value is greater than
threshold.- Parameters:
threshold – the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()
- Returns:
a Trigger instance that is true when the ZL axis exceeds the provided threshold, attached to the given event loop.
- zr(threshold: float = 0.5, loop: EventLoop | None = None) Trigger[source]
Constructs a Trigger instance around the ZR axis value. The returned Trigger will be true when the axis value is greater than
threshold.- Parameters:
threshold – the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.
loop – the event loop instance to attach the Trigger to, defaults to
commands2.CommandScheduler.get_default_button_loop()
- Returns:
a Trigger instance that is true when the ZR axis exceeds the provided threshold, attached to the given event loop.