robotpy_ext.control package

robotpy_ext.control.button_debouncer module

class robotpy_ext.control.button_debouncer.ButtonDebouncer(joystick, buttonnum, period=0.5)[source]

Useful utility class for debouncing buttons

Parameters:
  • joystick (wpilib.Joystick) – Joystick object

  • buttonnum (int) – Number of button to retrieve

  • period (float) – Period of time (in seconds) to wait before allowing new button presses. Defaults to 0.5 seconds.

get()[source]

Returns the value of the joystick button. If the button is held down, then True will only be returned once every debounce_period seconds

set_debounce_period(period)[source]

Set number of seconds to wait before returning True for the button again

robotpy_ext.control.toggle module

class robotpy_ext.control.toggle.Toggle(joystick, button, debounce_period=None)[source]

Utility class for joystick button toggle

Usage:

foo = Toggle(joystick, 3)

if foo:
    toggleFunction()

if foo.on:
    onToggle()

if foo.off:
    offToggle()
Parameters:
  • joystick (Joystick) – wpilib.Joystick that contains the button to toggle

  • button (int) – Number of button that will act as toggle. Same value used in getRawButton()

  • debounce_period (float) – Period in seconds to wait before registering a new button press.

get()[source]
Returns:

State of toggle

Return type:

bool

property off

Equates to true if toggle is in the ‘off’ state

property on

Equates to true if toggle is in the ‘on’ state