Pantalla#
Introducción#
The screen class is derived from the controller base class, which controls the V5 controller’s touchscreen, allowing your robot to show text and numbers.
La pantalla del controlador tiene 3 filas y 19 columnas para imprimir.
Acceso#
The screen class can be accessed by:
Controller.Screen
Notas#
The
screenobject is provided by the controller. It is not constructed directly.
Ejemplo#
/* This constructor is required when using VS Code.
A controller is generated automatically at the start of
VEXcode projects. */
// Create the V5 Controller
controller Controller1 = controller(primary);
// Print text to the Controller screen
Controller.Screen.print("Hello!");
Funciones de los miembros#
The screen class includes the following member functions:
print— Prints formatted text, numbers, or Boolean values to the controller’s screen.setCursor— Sets the text cursor to a specified row and column.newLine— Clears the remainder of the current line and moves the cursor to the next line.clearScreen— Clears the the entire screen.clearLine— Clears the remainder of the current line or clears a specified line.row— Returns the current cursor row.column— Returns the current cursor column.
Before calling any screen member functions, a controller instance must be created, as shown below:
// Create a V5 controller instance
controller Controller = controller();
imprimir#
Muestra texto, números o valores booleanos en la pantalla del controlador V5.
Available Functions1 — Imprime texto formateado usando literales de cadena o cadenas de estilo C de solo lectura.
void print( const char* format, ... );
Parameters2 — Imprime texto formateado utilizando matrices de caracteres modificables.
void print( char* format, ... );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A format string provided as a string literal or read-only C-style string (for example, |
|
|
Una cadena de formato proporcionada como una matriz de caracteres modificable. |
|
Uno o más valores adicionales que se insertan en la cadena de formato, separados por comas. |
Esta función no devuelve ningún valor.
NotesLa salida comienza en la posición actual del cursor en la pantalla.
Al utilizar una cadena de formato, el número y los tipos de valores pasados deben coincidir con los especificadores de formato en la cadena.
// Display a message at the starting cursor
Controller.Screen.print("Hello, Robot!");
establecer cursor#
Establece la posición del cursor en la pantalla del controlador V5 en la fila y columna especificadas.
Available Functionsvoid setCursor(
int32_t row,
int32_t col );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El número de fila donde se colocará el cursor. |
|
|
El número de columna donde se colocará el cursor. |
Esta función no devuelve ningún valor.
NotesAfecta al punto donde comienza la salida de texto posterior al usar print.
Calling
setCursoraffects the position of subsequent text output only.
// Display text starting at Row 2 Column 3
Controller.Screen.setCursor(2, 3);
Controller.Screen.print("Row 2, Column 3");
nueva línea#
Mueve el cursor al principio de la siguiente fila en la pantalla del controlador.
Available Functionsvoid newLine();
Esta función no acepta ningún parámetro.
Return ValuesEsta función no devuelve ningún valor.
NotesIf the cursor is in the middle of a sentence,
newLinewill clear the rest of the row after the cursor before moving to the next row.After calling
newLine, the cursor is positioned at the first column of the next line.La posición del cursor y la numeración de las filas se establecen mediante setCursor.
// Display two lines of text
Controller.Screen.print("Line 1");
Controller.Screen.newLine();
Controller.Screen.print("Line 2");
pantalla clara#
Borra todo el texto de la pantalla del mando.
Available Functionsvoid clearScreen();
Esta función no acepta ningún parámetro.
Return ValuesEsta función no devuelve ningún valor.
Examples// Clear screen after 2 seconds
Controller.Screen.print("VEXcode");
wait(2, seconds);
Controller.Screen.clearScreen();
Línea clara#
Borra el texto de una fila en la pantalla del controlador V5.
Available Functions1 — Borra la fila especificada en la pantalla.
void clearLine( int line );
Parameters2 — Borra la fila actual en la pantalla.
void clearLine();
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
La línea que se va a borrar va de la 1 a la 3. Si no se especifica, se borrará la línea actual. |
Esta función no devuelve ningún valor.
NotesBorrar una línea no cambia la posición actual del cursor.
La posición del cursor y la numeración de las filas se establecen mediante setCursor.
// 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);
fila#
Devuelve la posición actual del cursor en la fila de la pantalla del controlador V5.
Available Functionsint32_t row();
Esta función no acepta ningún parámetro.
Return ValuesReturns an int32_t representing the current cursor row position.
La numeración de las filas comienza en el 1.
NotesEl valor devuelto indica dónde aparecerá la siguiente impresión.
El valor de la fila cambia cuando se imprime texto o cuando se llama a setCursor.
// Display the cursor's current row
Controller.Screen.setCursor(3, 2);
Controller.Screen.print(Controller.Screen.row());
columna#
Devuelve la posición actual del cursor en la columna de la pantalla del controlador V5.
Available Functionsint32_t column();
Esta función no acepta ningún parámetro.
Return ValuesReturns an int32_t representing the current cursor column position.
La numeración de las columnas comienza en 1.
NotesEl valor devuelto indica dónde aparecerá la siguiente impresión.
El valor de la columna cambia cuando se imprime texto o cuando se llama a setCursor.
// Display the cursor's current column
Controller.Screen.setCursor(3, 2);
Controller.Screen.print(Controller.Screen.column());