Screen#
Introduction#
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.
The V5 Controller screen has 3 rows and 19 columns for displaying text and numbers.
Access#
The controller class provides a Screen object. It is an instance of the screen class.
Object |
Example Usage |
Description |
|---|---|---|
|
|
The V5 Controller screen. |
Notes#
Before using a
screenmember function, create acontrollerobject.The Controller screen has 3 rows and 19 columns.
The cursor position determines where the next printed value appears.
// Create a Controller object
controller Controller = controller();
Member Functions#
The screen class includes the following member functions:
Actions — Display text or clear the Controller screen.
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.
Getters — Read the current cursor position.
Actions#
print#
print displays formatted text, numbers, or values on the V5 Controller screen at the current cursor position.
Available Functions
void print(
const char* format,
...
);
void print(
char* format,
...
);
Parameter |
Type |
Description |
|---|---|---|
|
|
A format string provided as a string literal or read-only C-style string, such as |
|
|
A format string provided as a modifiable character array. |
|
Optional. One or more additional values inserted into the format string, separated by commas. |
Return Value
This function does not return a value.
Notes
Output begins at the current cursor position on the Controller screen.
When using a format string, the number and types of values passed must match the format specifiers in the string.
Example
// 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.
Available Function
void setCursor(
int32_t row,
int32_t col
);
Parameter |
Type |
Description |
|---|---|---|
|
|
The row number where the cursor will be placed, from |
|
|
The column number where the cursor will be placed, from |
Return Value
This function does not return a value.
Example
// 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.
Available Function
void newLine();
Parameters
This function does not have parameters.
Return Value
This function does not return a value.
Example
// 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.
Available Function
void clearScreen();
Parameters
This function does not have parameters.
Return Value
This function does not return a value.
Example
// 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.
Available Functions
void clearLine(
int line
);
void clearLine();
Parameter |
Type |
Description |
|---|---|---|
|
|
Optional. The row to clear, from |
Return Value
This function does not return a value.
Notes
Clearing a row does not change the current cursor position.
Example
// 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);
Getters#
row#
row returns the current cursor row on the V5 Controller screen.
Available Function
int32_t row();
Parameters
This function does not have parameters.
Return Value
Returns an int32_t representing the current cursor row. Row numbering starts at 1.
Example
// 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.
Available Function
int32_t column();
Parameters
This function does not have parameters.
Return Value
Returns an int32_t representing the current cursor column. Column numbering starts at 1.
Example
// Display the cursor's current column
Controller.Screen.setCursor(3, 2);
Controller.Screen.print(Controller.Screen.column());