Οθόνη#
Εισαγωγή#
The screen class is a derived class of the controller class. It provides functions for displaying text, numbers, and values on the V5 Controller screen.
A screen object is accessed through a controller object. It is not constructed directly.
Η οθόνη του ελεγκτή V5 έχει 3 γραμμές και 19 στήλες για την εμφάνιση κειμένου και αριθμών.
Πρόσβαση#
The controller class provides a Screen object. It is an instance of the screen class.
Αντικείμενο |
Παράδειγμα Χρήσης |
Περιγραφή |
|---|---|---|
|
|
Η οθόνη του χειριστηρίου V5. |
Σημειώσεις#
Before using a
screenmember function, create acontrollerobject.Η οθόνη Ελεγκτή έχει 3 γραμμές και 19 στήλες.
Η θέση του κέρσορα καθορίζει πού εμφανίζεται η επόμενη εκτυπωμένη τιμή.
// Create a Controller object
controller Controller = controller();
Συναρτήσεις Μελών#
The screen class includes the following member functions:
Ενέργειες — Εμφάνιση κειμένου ή εκκαθάριση της οθόνης Ελεγκτή.
print— Displays formatted text, numbers, or values on the Controller screen.setCursor— Moves the cursor to a specified row and column.newLine— Clears the rest of the current row and moves the cursor to the next row.clearScreen— Clears the Controller screen.clearLine— Clears one row on the Controller screen.
Λήψη δεδομένων — Ανάγνωση της τρέχουσας θέσης του κέρσορα.
Ενέργειες#
print#
print displays formatted text, numbers, or values on the V5 Controller screen at the current cursor position.
Διαθέσιμες λειτουργίες
void print(
const char* format,
...
);
void print(
char* format,
...
);
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
A format string provided as a string literal or read-only C-style string, such as |
|
|
Μια συμβολοσειρά μορφοποίησης που παρέχεται ως τροποποιήσιμος πίνακας χαρακτήρων. |
|
Προαιρετικό. Μία ή περισσότερες πρόσθετες τιμές εισάγονται στη συμβολοσειρά μορφοποίησης, διαχωρισμένες με κόμματα. |
Επιστρεφόμενη τιμή
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Σημειώσεις
Η έξοδος ξεκινά από την τρέχουσα θέση του κέρσορα στην οθόνη Ελεγκτή.
Όταν χρησιμοποιείτε μια συμβολοσειρά μορφοποίησης, ο αριθμός και οι τύποι των τιμών που διαβιβάζονται πρέπει να ταιριάζουν με τους προσδιοριστές μορφής στη συμβολοσειρά.
Παράδειγμα
// Display a message at the starting cursor position
Controller.Screen.print("Hello, Robot!");
// Display a formatted number
Controller.Screen.print("Score: %d", 25);
setCursor#
setCursor moves the cursor to a specified row and column on the V5 Controller screen. The next printed value will appear at that position.
Διαθέσιμη λειτουργία
void setCursor(
int32_t row,
int32_t col
);
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The row number where the cursor will be placed, from |
|
|
The column number where the cursor will be placed, from |
Επιστρεφόμενη τιμή
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Παράδειγμα
// Display text starting at row 2, column 3
Controller.Screen.setCursor(2, 3);
Controller.Screen.print("Row 2, Column 3");
newLine#
newLine clears the rest of the current row and moves the cursor to column 1 on the next row of the V5 Controller screen.
Διαθέσιμη λειτουργία
void newLine();
Παράμετροι
Αυτή η συνάρτηση δεν έχει παραμέτρους.
Επιστρεφόμενη τιμή
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Παράδειγμα
// Display two lines of text
Controller.Screen.print("Line 1");
Controller.Screen.newLine();
Controller.Screen.print("Line 2");
clearScreen#
clearScreen clears all text from the V5 Controller screen.
Διαθέσιμη λειτουργία
void clearScreen();
Παράμετροι
Αυτή η συνάρτηση δεν έχει παραμέτρους.
Επιστρεφόμενη τιμή
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Παράδειγμα
// Clear the Controller screen after 2 seconds
Controller.Screen.print("VEXcode");
wait(2, seconds);
Controller.Screen.clearScreen();
clearLine#
clearLine clears one row on the V5 Controller screen.
Διαθέσιμες λειτουργίες
void clearLine(
int line
);
void clearLine();
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Optional. The row to clear, from |
Επιστρεφόμενη τιμή
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Σημειώσεις
Η διαγραφή μιας γραμμής δεν αλλάζει την τρέχουσα θέση του δρομέα.
Παράδειγμα
// Display text on two rows
Controller.Screen.print("This text stays");
Controller.Screen.newLine();
Controller.Screen.print("This disappears");
// Wait 3 seconds before clearing row 2
wait(3, seconds);
Controller.Screen.clearLine(2);
Αποκτητές#
row#
row returns the current cursor row on the V5 Controller screen.
Διαθέσιμη λειτουργία
int32_t row();
Παράμετροι
Αυτή η συνάρτηση δεν έχει παραμέτρους.
Επιστρεφόμενη τιμή
Returns an int32_t representing the current cursor row. Row numbering starts at 1.
Παράδειγμα
// Display the cursor's current row
Controller.Screen.setCursor(3, 2);
Controller.Screen.print(Controller.Screen.row());
column#
column returns the current cursor column on the V5 Controller screen.
Διαθέσιμη λειτουργία
int32_t column();
Παράμετροι
Αυτή η συνάρτηση δεν έχει παραμέτρους.
Επιστρεφόμενη τιμή
Returns an int32_t representing the current cursor column. Column numbering starts at 1.
Παράδειγμα
// Display the cursor's current column
Controller.Screen.setCursor(3, 2);
Controller.Screen.print(Controller.Screen.column());