Ελεγκτής#

Εισαγωγή#

The controller class represents a VEX IQ Controller connected to the IQ Brain. A controller object can be used to access joystick axis values, read button states, register button or joystick callbacks, and check whether the controller is connected.

Το IQ (1ης γενιάς) Brain μπορεί να συνδεθεί με ένα χειριστήριο IQ (1ης γενιάς). Υποστηρίζει επίσης ένα χειριστήριο IQ (2ης γενιάς).

When one or more controllers are configured in the Devices window, VEXcode IQ also provides RemoteControlCodeEnabled. This global variable enables or disables controller actions configured in the Devices menu.

Παράγωγες Κλάσεις#

The controller class provides the following derived classes:

  • Axis - Provides access to joystick axis input values and change events.

  • Button - Provides access to button state and button event callbacks.

Κατασκευαστές#

1 - Δημιουργεί έναν ελεγκτή χρησιμοποιώντας τον κύριο τύπο ελεγκτή. Συνήθως χρησιμοποιείται όταν είναι συνδεδεμένος ένας μόνο ελεγκτής.

controller();

2 - Δημιουργεί έναν ελεγκτή για τον καθορισμένο τύπο ελεγκτή. Χρησιμοποιείται όταν είναι συνδεδεμένοι δύο ελεγκτές.

controller(
    controllerType id );

Διαθέσιμες λειτουργίες

controller();

controller(controllerType id);

Παράμετρος

Τύπος

Περιγραφή

id

controllerType

Optional. The controller type to create: primary for the primary controller connected to the Brain or partner for the second controller connected to the Brain.

Σημειώσεις

Only one primary controller and one partner controller can be created in a single project.

Παράδειγμα

// Create the primary controller
controller Controller1 = controller();

// Create a partner controller
controller Controller2 = controller(partner);

Καταστροφέας#

~ελεγκτής#

~controller destroys the controller object and releases associated resources.

Διαθέσιμη λειτουργία

~controller();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

id

controllerType

The type of controller being created:

  • primary - The primary controller connected to the Brain.
  • partner - The partner (second) controller connected to the Brain.

Σημειώσεις#

  • Only one primary and one partner controller may exist in a single project.

Παράδειγμα#

// Create a controller instance
controller Controller = controller();

Συναρτήσεις Μελών#

The controller class includes the following member function:

  • installed - Checks whether the controller is connected to the brain.

εγκατεστημένο#

installed returns whether the controller is connected to the Brain.

Διαθέσιμη λειτουργία

bool installed();

Παράμετροι

Αυτή η συνάρτηση δεν έχει παραμέτρους.

Επιστρεφόμενη τιμή

Επιστρέφει μια λογική τιμή.

  • true - The controller is installed/connected.
  • false - The controller is not installed/connected.

Καθολικές Μεταβλητές#

Κωδικός Απομακρυσμένου ΕλέγχουΕνεργοποιημένος#

RemoteControlCodeEnabled enables or disables controller actions configured in the Devices menu. Controller configured actions are enabled by default.

Usage:
RemoteControlCodeEnabled = state;

Αξία

Περιγραφή

true

Ενεργοποιεί ενέργειες που έχουν ρυθμιστεί από τον ελεγκτή.

false

Απενεργοποιεί τις ενέργειες που έχουν ρυθμιστεί από τον ελεγκτή.

Values
  • true - Controller-configured actions are enabled.
  • false - Controller-configured actions are disabled.
Notes
  • Οι ενέργειες που διαμορφώνονται από τον ελεγκτή είναι ενεργοποιημένες από προεπιλογή.

Examples
// Drive forward or backward using the left joystick
RemoteControlCodeEnabled = false;

while (true) {
  if (Controller1.Axis3.position() > 0) {
    Drivetrain.drive(forward);
  }
  else if (Controller1.Axis3.position() < 0) {
    Drivetrain.drive(reverse);
  }
  // Press E Up to use controller configured actions again
  else if (Controller1.ButtonEUp.pressing()) {
    break;
  }
  else {
    Drivetrain.stop();
  }

  wait(20, msec);
}

RemoteControlCodeEnabled = true;