eje#

posición()#

The controller.axis.position() command returns the current position of the specified Controller’s axis as a percentage.

Objeto

Descripción



eje

Which axis to report the position of:

  • axis1 - Left and right of the right joystick.
  • axis2 - Up and down of the right joystick.
  • axis3 - Up and down of the left joystick.
  • axis4 - Left and right of the left joystick.

Devuelve: Un valor en el rango +/- 100.

# Print the position of the current Controller's axis to the
# Brain's screen.
brain.screen.print(controller.axis1.position())

cambió()#

The controller.axis.changed(callback, arg) command registers a function to be called when the specified axis’ value changes.

Objeto

Descripción



eje

Which axis to report the position of:

  • axis1 - Left and right of the right joystick.
  • axis2 - Up and down of the right joystick.
  • axis3 - Up and down of the left joystick.
  • axis4 - Left and right of the left joystick.

Parámetro

Descripción

llamar de vuelta

Una función que se llamará cuando cambie el valor del eje

arg

Opcional. Una tupla que se utiliza para pasar parámetros a la función de devolución de llamada

Devuelve: Una instancia de la clase Event.

# Define a function axis_changed().
def axis_changed():
    # The Brain will print that the axis changed on the
    # Brain's screen.
    brain.screen.print("axis changed")

# Run axis_changed() when the value of axis1 changes.
controller.axis1.changed(axis_changed)