Οθόνη#

Εισαγωγή#

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 στήλες για την εμφάνιση κειμένου και αριθμών.

Στιγμιότυπο οθόνης της οθόνης του ελεγκτή V5, που δείχνει τις γραμμές και τις στήλες στην εκτυπώσιμη περιοχή. Γραμμή 1 Η στήλη 1 ξεκινά από την επάνω αριστερή γωνία και η γραμμή 3 και η στήλη 19 βρίσκονται στην κάτω δεξιά γωνία.

Πρόσβαση#

The controller class provides a Screen object. It is an instance of the screen class.

Αντικείμενο

Παράδειγμα Χρήσης

Περιγραφή

Screen

Controller.Screen.print(“Hello”);

Η οθόνη του χειριστηρίου V5.

Σημειώσεις#

  • Before using a screen member function, create a controller object.

  • Η οθόνη Ελεγκτή έχει 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.

Λήψη δεδομένων — Ανάγνωση της τρέχουσας θέσης του κέρσορα.

  • row — Returns the current cursor row.

  • column — Returns the current cursor column.

Ενέργειες#

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,
  ...
);

Παράμετρος

Τύπος

Περιγραφή

format

const char*

A format string provided as a string literal or read-only C-style string, such as “Score: %d”.

format

char*

Μια συμβολοσειρά μορφοποίησης που παρέχεται ως τροποποιήσιμος πίνακας χαρακτήρων.

Προαιρετικό. Μία ή περισσότερες πρόσθετες τιμές εισάγονται στη συμβολοσειρά μορφοποίησης, διαχωρισμένες με κόμματα.

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

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Σημειώσεις

  • Η έξοδος ξεκινά από την τρέχουσα θέση του κέρσορα στην οθόνη Ελεγκτή.

  • Όταν χρησιμοποιείτε μια συμβολοσειρά μορφοποίησης, ο αριθμός και οι τύποι των τιμών που διαβιβάζονται πρέπει να ταιριάζουν με τους προσδιοριστές μορφής στη συμβολοσειρά.

Παράδειγμα

// 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
);

Παράμετρος

Τύπος

Περιγραφή

row

int32_t

The row number where the cursor will be placed, from 1 to 3.

col

int32_t

The column number where the cursor will be placed, from 1 to 19.

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

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Παράδειγμα

// 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();

Παράμετρος

Τύπος

Περιγραφή

line

int

Optional. The row to clear, from 1 to 3. If no row is provided, the current row is cleared.

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

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Σημειώσεις

  • Η διαγραφή μιας γραμμής δεν αλλάζει την τρέχουσα θέση του δρομέα.

Παράδειγμα

// 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());