axis#
position()#
The controller.axis.position()
method returns the current position of the specified Controller’s axis as a percentage.
Object |
Description |
---|---|
|
Which axis to report the position of:
|
Returns: A value in the range +/- 100.
# Print the position of the current Controller's axis to the
# Brain's screen.
brain.screen.print(controller.axisA.position())
changed()#
The controller.axis.changed(callback, arg)
method registers a function to be called when the specified axis’ value changes.
Object |
Description |
---|---|
p and down of the left joystick. axisB - Left and right of the left joystick.axisC - Left and right of the right joystick.axisD - Up and down of the right joystick. |
Parameter |
Description |
---|---|
callback |
A function that will be called when the axis value changes |
arg |
Optional. A tuple that is used to pass Parameter to the callback function |
Returns: An instance of the Event class.
# 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 axisA changes.
controller.axisA.changed(axis_changed)