botón#
Depending on if it is an EXP Controller or a V5 Controller connected, the button attribute has access to different objects:
Controlador EXP |
Controlador V5 |
|---|---|
|
|
apretado()#
The pressed(callback, arg) method registers a function to be called when a Controller’s button is pressed.
Parámetro |
Descripción |
|---|---|
|
Una función que se llamará cuando se presione el botón |
|
Opcional. Una tupla que se utiliza para pasar un parámetro a la función de devolución de llamada. |
Devuelve: Una instancia de la clase Event.
# Define a function button_pressed().
def button_pressed():
# The Brain will print that the button was pressed on the
# Brain's screen.
brain.screen.print("button pressed")
# Run button_pressed() when L1 button is pressed.
controller.buttonL1.pressed(button_pressed)
liberado()#
The released(callback, arg) method registers a function to be called when a Controller’s button is released.
Parámetro |
Descripción |
|---|---|
|
Una función que se llamará cuando se suelte el botón |
|
Opcional. Una tupla que se utiliza para pasar un parámetro a la función de devolución de llamada. |
Devuelve: Una instancia de la clase Event.
# Define a function button_released().
def button_released():
# The Brain will print that the button was released on
# the Brain's screen.
brain.screen.print("button released")
# Run button_released() when the L1 button is released.
controller.buttonL1.released(button_released)
prensado()#
The pressing() method returns whether a Controller’s button is currently being pressed.
Returns: True if the button is currently being pressed. False if it is not currently being pressed.