Screen#
Introduction#
The VEX AIR Drone Controller’s screen provides blocks for displaying text, managing the cursor, drawing shapes, and handling touch interactions.
Note: If the VEX AIR Drone is paired with a controller, a timer will be displayed at the top of the print screen indicating the current project’s elapsed time. Any text or drawings will appear behind the timer.
Below is a list of all available blocks, grouped by functionality:
Cursor Print - Manage text display using a row-and-column cursor system.
print — Displays text on the screen at the current cursor position.
set cursor to row column — Moves the cursor to a specific row and column.
set cursor to next row — Moves the cursor to column 1 of the next row.
clear row — Clears a specified row of text.
screen cursor column — Returns the column number where text will be printed.
screen cursor row — Returns the row number where text will be printed.
XY Print - Print text at pixel-based coordinates.
print at — Displays text at a specified x and y coordinate.
set screen origin — Changes the origin (0, 0) used for drawing and printing.
Settings - Customize text formatting and screen display.
clear screen — Erases all text and drawings from the screen.
wait for screen to render — Prevents any printing or drawing from displaying until the block is used again.
fill screen — Erases all text and drawings from the screen, then sets the screen’s background color.
set font — Changes the font type and size for text display.
set print precision — Adjusts the amount of decimal places for printed numbers.
set pen width — Adjusts the thickness of drawn lines.
set pen / font color — Changes the color for text and drawings.
set fill color — Defines the fill color for shapes.
Draw - Create graphics and visual elements.
show image file — Displays a user-uploaded image on the screen.
draw pixel — Draws a single pixel at a specified coordinate.
draw line — Draws a line between two points.
draw rectangle — Draws a rectangle with specified dimensions.
draw circle — Draws a circle with a given radius.
Touch - Detect screen interactions.
screen pressed? — Returns whether the screen is currently being pressed.
screen position — Retrieves the x and y coordinates where the screen was last touched.
when screen event — Triggers when the screen is pressed or released.
Cursor Print#
print#
The print block displays text on the controller’s screen at the current cursor position and font.
print [VEXcode] on screen ▶
Parameters |
Description |
---|---|
value |
The text, number, or variable value to display on the screen. |
expanding arrow |
Expand the block to read and set cursor to next row and make the cursor move to the next row after this block. |
Example
when started :: hat events
[Display a message at the starting cursor position.]
print [Time to fly!] on screen ▶
set cursor to row column#
When using the set cursor to row column block, the cursor is placed at a specific row and column on the screen. The amount of characters that can fit on a screen depends on the selected font. The font size can be changed using the set font block. With the default monospaced medium font, up to 18 rows and 53 columns can be displayed clearly. Text placed beyond this range may be cut off or become difficult to read.
set cursor to row [1] column [1] on screen
Parameters |
Description |
---|---|
row |
The row of the cursor. |
column |
The column of the cursor. |
Examples
when started :: hat events
[Display text starting at Row 7 Column 25.]
set cursor to row [7] column [25] on screen
print [Row 7, Column 25] on screen ▶
set cursor to next row#
The set cursor to next row block moves the cursor to column 1 on the next row on the controller’s screen.
set cursor to next row on screen
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display two lines of text.]
print [Line 1] on screen ▶
set cursor to next row on screen
print [Line 2] on screen ▶
clear row#
The clear row block clears a row of text on the controller’s screen.
clear row [1] on screen
Parameters |
Description |
---|---|
row |
The row number to clear. |
Example
when started :: hat events
[Display text on two rows.]
print [This text stays] on screen ▶
set cursor to next row on screen
print [This text disappears] on screen ▶
wait [3] seconds
clear row [2] on screen
screen cursor column#
The screen cursor column returns the cursor’s current column position.
(screen cursor column)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the cursor's current column.]
set cursor to row [7] column [25] on screen
print (screen cursor column) on screen ▶
screen cursor row#
The screen cursor row block returns the cursor’s current row position.
(screen cursor row)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the cursor's current row.]
set cursor to row [7] column [25] on screen
print (screen cursor row) on screen ▶
XY Print#
print at#
The print at block displays text on the controller’s screen at a specific (x, y) position in pixels, using the currently set font. x
sets how far from the left side the text begins, and y
sets where the bottom of the letters sit. This method disregards the current cursor position.
print [VEXcode] at x:[80] y:[120] on screen
Parameters |
Description |
---|---|
value |
The text, number, or variable value to display on the screen. |
x |
The x-coordinate in pixels (0 to 640, where 0 is left and 640 is right). |
y |
The y-coordinate in pixels (0 to 480, where 0 is top and 480 is bottom). |
Example
when started :: hat events
[Display a message starting in the middle of the screen.]
print [Hello, drone!] at x:[320] y:[240] on screen
set screen origin#
The set screen origin sets the origin (0, 0) used for drawing or printing on the controller’s screen. By default, drawing or printing blocks consider the top left corner of the screen as the origin. This block can reset the origin to an alternate (x, y) screen coordinate location.
set screen origin x:[0] y:[0]
Parameters |
Description |
---|---|
x |
The x-coordinate in pixels to set the new origin to. |
y |
The y-coordinate in pixels to set the new origin to. |
Example
when started :: hat events
[Set the origin to the center of the screen.]
set screen origin x:[320] y:[240]
[Draw a rectangle at the new origin.]
draw rectangle [0] [0] [80] [40] on screen
Settings#
clear screen#
The clear screen block clears the controller’s screen of all drawings, text, and images.
clear screen
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Draw a circle, and clear it after 2 seconds.]
draw circle [320] [240] [80] on screen
wait [2] seconds
clear screen
wait for screen to render#
The wait for screen to render block prevents any following screen blocks from displaying and then shows all of their output at once when it is used again.
Note: Using this block changes the project so that all subsequent screen blocks will remain hidden until the wait for screen to render block is used again.
wait for screen to render
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display text and images when button 7 is pressed.]
wait for screen to render
print [Screen rendered!] on screen ▶
draw circle [320] [240] [80] on screen
wait until <controller button [7 v] pressed?>
wait for screen to render
fill screen#
The fill screen block clears the controller’s screen of all drawings and text, then changes the background to a specified color.
fill screen with [red v]
Parameters |
Description |
---|---|
color |
The color to change the background to:
|
Example
when started :: hat events
[Say "Hello" then turn screen green.]
print [Hello] on screen ▶
wait [2] seconds
fill screen with [green v]
set font#
The set font block sets the font and size used for displaying text on the controller’s screen. This font will apply to all subsequently printed text.
set font to [monospaced v] [medium v] on screen
Parameters |
Description |
---|---|
type |
The font type:
|
size |
The font size (shown below):
|
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
|
Example
when started :: hat events
[Display text using a larger font.]
set font to [monospaced v] [extra large v] on screen
print [VEX] on screen ▶
set print precision#
The set print precision block sets the precision formatting used for displaying numbers on the controller’s screen. This print precision will apply to all subsequently printed numbers.
set print precision to [0.1 v] on screen
Parameters |
Description |
---|---|
precision |
Sets the print precision to:
|
Example
when started :: hat events
[Print 1/3 as 0.33.]
set print precision to [0.01 v] on screen
print ([1] [math_division v] [3]) on screen ▶
set pen width#
The set pen width block sets the pen width used for drawing lines and shapes.
set pen width to [10] on screen
Parameters |
Description |
---|---|
width |
The pen width in pixels. |
Example
when started :: hat events
[Draw a rectangle with a pen width of 10.]
set pen width to [10] on screen
draw rectangle [200] [200] [200] [80] on screen
set pen / font color#
The set pen / font color block sets the pen color used for drawing lines, shapes, and text on the controller’s screen. The default color is white.
set pen / font color to [red v] on screen
Example
Parameters |
Description |
---|---|
color |
Sets the pen color to:
|
when started :: hat events
[Draw a rectangle with an orange outline.]
set pen / font color to [orange v] on screen
draw rectangle [200] [150] [240] [150] on screen
set pen / font color to [white v] on screen
print [VEXcode AIR] at x: [250] y: [220] on screen
set fill color#
The set fill color block sets the color used to fill shapes when they are drawn. The default fill color is black.
set fill color to [red v] on screen
Parameters |
Description |
---|---|
color |
Sets the fill color to:
|
Examples
when started :: hat events
[Draw an orange-filled rectangle with text on top.]
set fill color to [orange v] on screen
draw rectangle [200] [150] [240] [150] on screen
print [VEXcode AIR] at x: [250] y: [220] on screen
Draw#
show image file#
The show image file block draws a custom user-uploaded image on the controller’s screen at the set origin.
show image file [IMAGE1 v]
Parameters |
Description |
---|---|
image number |
The user-uploaded image to use. Options will change if image names are edited in the Control Panel. |
Example
when started :: hat events
[Display custom image on screen.]
show image file [IMAGE1 v]
draw pixel#
The draw pixel block draws a pixel at the specified (x, y) screen coordinate in the current pen color.
draw pixel [0] [0] on screen
Parameters |
Description |
---|---|
x |
The x coordinate to draw the pixel, ranging from 0 to 640. |
y |
The y coordinate to draw the pixel, ranging from 0 to 480. |
Example
when started :: hat events
[Draw five pixels in a diagonal.]
draw pixel [360] [200] on screen
draw pixel [340] [220] on screen
draw pixel [320] [240] on screen
draw pixel [300] [260] on screen
draw pixel [280] [280] on screen
draw line#
The draw line block draws a line from the first specified screen coordinate (x1, y1) to the second specified screen coordinate (x2, y2) using the current pen width and pen color.
draw line [0] [0] [10] [10] on screen
Parameters |
Description |
---|---|
x1 |
The x coordinate in pixels of the start of the line, ranging from 0 to 640. |
y1 |
The y coordinate in pixels of the start of the line, ranging from 0 to 480. |
x2 |
The x coordinate in pixels of the end of the line, ranging from 0 to 640. |
y2 |
The y coordinate in pixels of the end of the line, ranging from 0 to 480. |
Example
when started :: hat events
[Make an X across the screen.]
draw line [0] [0] [640] [480] on screen
set pen / font color to [cyan v] on screen
draw line [0] [480] [640] [0] on screen
draw rectangle#
The draw rectangle block draws a rectangle using the current pen width, pen color, and fill color.
draw rectangle [0] [0] [10] [10] on screen
Example
Parameters |
Description |
---|---|
x |
The x coordinate in pixels of the top-left corner of the rectangle, ranging from 0 to 640. |
y |
The y coordinate in pixels of the top-left corner of the rectangle, ranging from 0 to 480. |
width |
The width of the rectangle in pixels. |
height |
The height of the rectangle in pixels. |
when started :: hat events
[Draw two rectangles on the screen.]
draw rectangle [0] [0] [620] [460] on screen
set fill color to [green v] on screen
draw rectangle [200] [180] [200] [100] on screen
draw circle#
The draw circle block draws a circle using the current pen width, pen color, and fill color.
draw circle [0] [0] [10] on screen
Parameters |
Description |
---|---|
x |
The x coordinate in pixels of the center of the circle, ranging from 0 to 640. |
y |
The y coordinate in pixels of the center of the circle, ranging from 0 to 480. |
radius |
The radius of the circle in pixels. |
Example
when started :: hat events
[Draw one green circle on the screen.]
set fill color to [green v] on screen
draw circle [320] [240] [200] on screen
Touch#
screen pressed?#
The screen pressed? block reports if the controller’s screen is currently being pressed or not pressed. This block returns a Boolean value:
True - Screen is currently being pressed
False - Screen is not being pressed
<screen pressed?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Play a sound when the screen is pressed.]
forever
if <screen pressed?> then
play note [low v] [C v] [note_eight v] ▶
screen position#
The screen position block returns an integer showing the x- and y-coordinate (in pixels) where the screen was pressed. The return value for x is between 0 (left) and 640 (right). The return value for y is between 0 (top) and 480 (bottom).
(screen [x v] position)
Parameters |
Description |
---|---|
coordinate |
The coordinate of the last screen press in pixels:
|
Example
when started :: hat events
[Play high or low note based on where screen is pressed.]
forever
if <screen pressed?> then
if <(screen [x v] position) [math_greater_than v] [320]> then
play note [high v] [C v] [note_eight v] ▶
else
play note [low v] [C v] [note_eight v] ▶
when screen event#
The when screen event block is called when the controller’s screen is pressed or released.
when screen [pressed v] :: hat events
Parameters |
Description |
---|---|
action |
Determines when the attached stack of blocks will run:
|
Example
when screen [pressed v] :: hat events
[Play a sound when the screen is pressed.]
play sound [success v] ▶