Ελεγκτής#
Εισαγωγή#
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 (2ης γενιάς) Brain μπορεί να συνδεθεί είτε με ένα χειριστήριο IQ (2ης γενιάς) είτε με ένα χειριστήριο IQ (1ης γενιάς). Ένα χειριστήριο IQ (1ης γενιάς) πρέπει να διαθέτει εγκατεστημένο ένα μπλε Smart Radio.
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:
Κατασκευαστές#
1 - Δημιουργεί έναν ελεγκτή χρησιμοποιώντας τον κύριο τύπο ελεγκτή. Συνήθως χρησιμοποιείται όταν είναι συνδεδεμένος ένας μόνο ελεγκτής.
controller();
2 - Δημιουργεί έναν ελεγκτή για τον καθορισμένο τύπο ελεγκτή. Χρησιμοποιείται όταν είναι συνδεδεμένοι δύο ελεγκτές.
controller( controllerType id );
Διαθέσιμες λειτουργίες
controller();
controller(controllerType id);
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Optional. The controller type to create: |
Σημειώσεις
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();
Παράμετροι#
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The type of controller being created:
|
Σημειώσεις#
Only one
primaryand onepartnercontroller 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- Controller-configured actions are enabled.false- Controller-configured actions are disabled.
Οι ενέργειες που διαμορφώνονται από τον ελεγκτή είναι ενεργοποιημένες από προεπιλογή.
// Drive forward or backward using the left joystick
RemoteControlCodeEnabled = false;
while (true) {
if (Controller1.AxisA.position() > 0) {
Drivetrain.drive(forward);
}
else if (Controller1.AxisA.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;