Axis#
position()#
The position(units)
command gets the position of the joystick axis on a scale from -100 to 100.
Object |
Description |
---|---|
|
Which axis to report the position of:
|
Returns: An integer that represents the position of the joystick axis.
// Get the position of the current axis.
int axis = Controller.AxisA.position();
// Print the position of the current controller axis to the
// Brain's screen.
Brain.Screen.print(axis);
changed()#
The changed(callback)
command registers a function to be called when the axis value changes.
Parameter |
Description |
---|---|
callback |
A function that will be called when the axis value changes |
Returns: None.
// Define the axisChanged function with a void return type,
// showing it doesn't return a value.
void axisChanged() {
// The Brain will print that the controller axis changed
// on the Brain's screen.
Brain.Screen.print("controller axis changed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run axisChanged when the value of the controller axis changes.
Controller.AxisC.changed(axisChanged);
}