Screen#

Introduction#

The VEX AIR Drone Controller’s screen provides methods for displaying text, managing the cursor, drawing shapes, and handling touch interactions.

Below is a list of all available methods:

Cursor Print – Display text using a row/column system.

  • print – Prints text at the current cursor position.

  • set_cursor – Sets the cursor to a specific row and column.

  • next_row – Moves the cursor to column 1 of the next row.

  • clear_row – Clears a row of text.

  • get_row – Returns the current cursor row.

  • get_column – Returns the current cursor column.

XY Print – Display text at a specific screen coordinate.

  • print_at – Prints text at a specific x and y location.

  • set_origin – Sets a new origin for printing and drawing.

Mutators – Clear the screen or update visual settings.

Draw – Add graphics and images to the screen.

Touch – Detect and respond to screen presses.

  • pressing – Returns whether the screen is currently being pressed.

  • x_position – Returns the x-coordinate where the screen is pressed.

  • y_position – Returns the y-coordinate where the screen is pressed.

Callback – Run functions when the screen is pressed or released.

  • pressed – Registers a function to call when the screen is pressed.

  • released – Registers a function to call when the screen is released.

Cursor Print#

print#

print displays text on the controller’s screen at the current cursor position and font.

Usage:
controller.screen.print(text)

Parameters

Description

text

The text, number, or variable value to display on the screen.

sep

Optional. The separator between printed text. By default, sep = ’ ‘

end

Optional. The string appended after the last printed text. By default, end = ‘\n’

precision

Optional. The number of decimals a float will print with as an integer. By default, precision = 5

# Display a message at the starting cursor position.
controller.screen.print("Time to fly!")

A screenshot of the VEX AIR Drone Controller screen, with white text in the upper left corner that reads Time to fly!

# Display the first 2 decimals of pi
controller.screen.print(3.1415, precision = 2)

The same screenshot as the one previous, with the text reading 3.14 in the upper left corner.

set_cursor#

set_cursor places the text cursor at a specific row and column on the screen. The number of rows and columns that fit depends on the selected font. With the default monospaced medium font, the screen can clearly display up to 11 rows and 53 columns. Text placed beyond this range may be cut off or harder to read.

Usage:
controller.screen.set_cursor(row, col)

Parameters

Description

row

The row of the cursor.

column

The column of the cursor.

# Display text starting at Row 7 Column 25.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print("Row 7, Column 25")

A screenshot of the VEX AIR Drone Controller screen, with white text near the center that reads Row 7, Column 25 in that screen position.

next_row#

next_row moves the cursor to column 1 on the next row on the controller’s screen.

Usage:
controller.screen.next_row()

Parameters

Description

This method has no parameters.

# Display two lines of text.
controller.screen.print("Line 1")
controller.screen.next_row()
controller.screen.print("Line 2")

A screenshot of the VEX AIR Drone Controller screen, with white text in the upper left corner that reads Line 1 on the top line, and Line 2 directly below it.

clear_row#

clear_row clears a row of text on the controller’s screen.

Usage:
controller.screen.clear_row(row, color)

Parameter

Description

row

Optional. The row to clear. The default is the current cursor row.

color

Optional. The color to apply to the cleared row. If a color is not specified, the set_fill_color is used. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Clear only the second row of text
controller.screen.print("This text stays")
controller.screen.next_row()
controller.screen.print("This text disappears")
wait(3, SECONDS)
controller.screen.clear_row(2)

# Turn the 5th row green.
controller.screen.clear_row(5, GREEN)

get_row#

get_row returns the current row where text will be printed, as an integer.

Usage:
controller.screen.get_row()

Parameters

Description

This method has no parameters.

# Display the cursor's current row.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print(controller.screen.get_row())

A screenshot of the VEX AIR Drone Controller screen, with white text near the center that reads 7, at the row 7, column 25 position.

get_column#

get_column returns the current column where text will be printed, as an integer.

Usage:
controller.screen.get_column()

Parameters

Description

This method has no parameters.

# Display the cursor's current column.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print(controller.screen.get_column())

A screenshot of the VEX AIR Drone Controller screen, with white text near the center that reads 25, at the row 7, column 25 position.

XY Print#

set_origin#

set_origin sets the origin (0, 0) used for drawing or printing on the controller’s screen. By default, drawing or printing methods consider the top left corner of the screen as the origin. This method can reset the origin to an alternate (x, y) screen coordinate location.

Usage:
controller.screen.set_origin(x, y)

Parameter

Description

x

The new x-coordinate to set as the origin, given as an integer from 0 to 640.

y

The new y-coordinate to set as the origin, given as an integer from 0 to 480.

# Set the origin to the center of the screen.
controller.screen.set_origin(x=320, y=240)

# Draw a rectangle at the new origin.
controller.screen.draw_rectangle(x=0, y=0, width=80, height=40)

A screenshot of the VEX AIR Drone Controller screen, with a white rectangle drawn so that the upper left corner is the center of the screen.

Mutators#

clear_screen#

clear_screen clears the controller’s screen of all drawings, text, and images.

Usage:
controller.screen.clear_screen(row, col, color)

Parameter

Description

row

Optional. The x position to set the cursor at after clearing the screen. The default is 1.

col

Optional. The y position to set the cursor at after clearing the screen. The default is 1.

color

Optional. Sets the screen color. To use, you must include all three optional parameters. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Draw a circle, and clear it after 2 seconds.
controller.screen.draw_circle(x=320, y=240, radius=80)
wait(2, SECONDS)
controller.screen.clear_screen()

# Print two messages in the same spot
controller.screen.print("Hello!")
wait(3,SECONDS)
controller.screen.clear_screen(row=1, col=1)
controller.screen.print("Goodbye!")

# Set the background color of the screen to red.
controller.screen.clear_screen(RED)

wait_for_render#

wait_for_render prevents any following commands from running until all previous drawing and print commands on the screen have finished rendering.

Usage:
controller.screen.wait_for_render()

Parameter

Description

This method has no parameters.

# Display text and images when button 7 is pressed.
controller.screen.wait_for_render()
controller.screen.print("Screen rendered!")
controller.screen.draw_circle(x=320, y=240, radius=80)
while not controller.button7.pressing():
    wait(5, MSEC)
controller.screen.wait_for_render()

A screenshot of the VEX AIR Drone Controller screen, with white text that reads Screen rendered! in the upper left corner, and a white circle drawn in the center of the screen.

set_font#

set_font sets the font used for displaying text on the controller’s screen. This font will apply to all text printed with print or print_at. The default font at the start of a project is MONO20.

Usage:
controller.screen.set_font(fontname)

Parameter

Description

fontname

Sets the font to one of the following:

  • MONO12
  • MONO15
  • MONO20
  • MONO24
  • MONO30
  • MONO36
  • MONO40
  • MONO60
  • PROP20
  • PROP24
  • PROP30
  • PROP36
  • PROP40
  • PROP60

A screenshot of the VEX AIR Drone Controller screen with an assortment of letters and numbers printed in white in the upper left hand corner in Mono 12 font. The letters A-Z are on one line, and take up about a third of the width of the screen. In the lower left corner, it reads 91 characters across and 30 rows.
MONO12

The same image as the one previous, now with Mono 15 font. The letters A-Z are on one line, and take up nearly half the width of the screen. In the lower left corner, it reads 71 characters across and 23 rows.
MONO15

The same image as the one previous, now with Mono 20 font. The letters A-Z are on one line, and take up half the width of the screen. In the lower left corner, it reads 53 characters across and 18 rows.
MONO20

The same image as the one previous, now with Mono 24 font. The letters A-Z are on one line, and take up a little over half the width of the screen. In the lower left corner, it reads 45 characters across and 15 rows.
MONO24

The same image as the one previous, now with Mono 30 font. The letters A-Z are on one line, and take up about three quarters of the width of the screen. In the lower left corner, it reads 35 characters across and 12 rows.
MONO30

The same image as the one previous, now with Mono 36 font. The letters A-Z are on one line, spanning nearly the width of the screen. In the lower left corner, it reads 29 characters across and 10 rows.
MONO36

he same image as the one previous, now with Mono 40 font. The letters A-Z are on one line, spanning the width of the screen. In the lower left corner, it reads 26 characters across and 9 rows.
MONO40

The same image as the one previous, now with Mono 60 font. The letters A-Q are on one line, spanning the width of the screen. In the lower left corner, it reads 17 characters across and 6 rows.
MONO60

The same image as the one previous, now with Prop 20 font. The letters A-Z are on one line, and take up a little over half the width of the screen. In the lower left corner, it reads 49 characters across and 18 rows.
PROP20

The same image as the one previous, now with Prop 24 font. The letters A-Z are on one line, and take up about two thirds of the width of the screen. In the lower left corner, it reads 42 characters across and 15 rows.
PROP24

The same image as the one previous, now with Prop 30 font. The letters A-Z are on one line, and take up three quarters of the width of the screen. In the lower left corner, it reads 33 characters across and 12 rows.
PROP30

The same image as the one previous, now with Prop 36 font. The letters A-Z are on one line, spanning nearly the width of the screen. In the lower left corner, it reads 27 characters across and 10 rows.
PROP36

The same image as the one previous, now with Prop 40 font. The letters A-Y are on one line, spanning the width of the screen. In the lower left corner, it reads 24 characters across and 9 rows.
PROP40

The same image as the one previous, now with Prop 60 font. The letters A-Q are on one line, spanning the width of the screen. In the lower left corner, it reads 17 characters across and 6 rows.
PROP60

# Display text using a larger font.
controller.screen.set_font(MONO40)
controller.screen.print("VEX")

The same image as those previous, now with the word VEX printed in Mono 40 font in the upper left corner.

set_pen_width#

set_pen_width sets the pen width used for drawing lines and shapes.

Usage:
controller.screen.set_pen_width(width)

Parameter

Description

width

The pen width, given as an integer in pixels.

# Draw a rectangle with a pen width of 10.
controller.screen.set_pen_width(10)
controller.screen.draw_rectangle(x=200, y=200, width=200, height=80)

A screenshot of the VEX AIR Drone Controller's screen with a white rectangle with a thick border printed in the center.

set_pen_color#

set_pen_color sets the pen color used for drawing lines, shapes, and printing text.

Usage:
controller.screen.set_pen_color(color)

Parameter

Description

color

Optional. Sets the pen color. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Draw a rectangle with an orange outline.
controller.screen.set_pen_color(ORANGE)
controller.screen.draw_rectangle(x=200, y=150, width=240, height=150)
controller.screen.set_pen_color(WHITE)
controller.screen.print_at("VEXcode AIR", x=250, y=220)

A screenshot of the VEX AIR Drone Controller's screen with a thin orange rectangle with the words VEXcode AIR printed in white in the center.

set_text_fill_color#

set_text_fill_color sets the highlight color used when text is printed. The default highlight color is transparent.

Usage:
controller.screen.set_text_fill_color(color)

Parameter

Description

color

Optional. Sets the text highlight color. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Display two colors behind text
controller.screen.set_text_fill_color(RED)
controller.screen.print("Red")
controller.screen.next_row()
controller.screen.set_text_fill_color(BLUE)
controller.screen.print("Blue")

A screenshot of the VEX AIR Drone Controller's screen with two lines of text printed in the upper left corner. The first reads Red in white text with a red highlight, the second, directly below, reads Blue in white text with a blue highlight.

set_fill_color#

set_fill_color sets the fill color used when shapes are drawn. The default fill color is black.

Usage:
controller.screen.set_fill_color(color)

Parameter

Description

color

Optional. Sets the fill color. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Draw an orange-filled rectangle with text on top
controller.screen.set_fill_color(ORANGE)
controller.screen.draw_rectangle(x=200, y=150, width=250, height=150)
controller.screen.print_at("VEXcode AIR", x=250, y=220)

A screenshot of the VEX AIR Drone Controller's screen with a solid orange rectangle with a thin white border with white text reading VEXcode AIR printed in the center.

Draw#

draw_pixel#

draw_pixel draws a pixel at the specified (x, y) screen coordinate in the current pen color. It uses the current pen color set by set_pen_color.

Usage:
controller.screen.draw_pixel(x, y)

Parameter

Description

x

The x-coordinate where the pixel will be drawn, given as an integer from 0 to 640.

y

The y-coordinate where the pixel will be drawn, given as an integer from 0 to 480.

# Draw five pixels in a diagonal.
controller.screen.draw_pixel(x=360, y=200)
controller.screen.draw_pixel(x=340, y=220)
controller.screen.draw_pixel(x=320, y=240)
controller.screen.draw_pixel(x=300, y=260)
controller.screen.draw_pixel(x=280, y=280)

A screenshot of the VEX AIR Drone Controller's screen with 5 evenly spaced pixels printed in a diagonal line across the center of the screen.

draw_line#

draw_line draws a line from the first specified screen coordinate (x1, y1) to the second specified screen coordinate (x2, y2). It uses the current the pen width set by set_pen_width and pen color set by set_pen_color.

The x and y-coordinates use the default origin of (0, 0) unless a different origin has been set using set_origin.

Usage:
controller.screen.draw_line(x1, y1, x2, y2)

Parameter

Description

x1

The starting x-coordinate of the line, given as an integer from 0 to 640.

y1

The starting y-coordinate of the line, given as an integer from 0 to 480.

x2

The ending x-coordinate of the line, given as an integer from 0 to 640.

y2

The ending y-coordinate of the line, given as an integer from 0 to 480.

# Make an X across the screen.
controller.screen.draw_line(x1=0, y1=0, x2=640, y2=480)
controller.screen.set_pen_color(CYAN)
controller.screen.draw_line(x1=0, y1=480, x2=640, y2=0)

A screenshot of the VEX AIR Drone Controller's screen with a white line drawn from the upper left  to the lower right corner, and a teal colored line drawn from the lower left to upper right corner, intersecting in the center.

draw_rectangle#

draw_rectangle draws a rectangle with its top-left corner at the specified (x, y) coordinate and a size determined by the given width and height, all measured in pixels. The rectangle’s outline is drawn using the current pen width set by set_pen_width and the pen color set by set_pen_color. The interior is filled with the color set by set_fill_color.

The x and y-coordinates use the default origin of (0, 0) unless a different origin has been set using set_origin.

Usage:
controller.screen.draw_rectangle(x, y, width, height, color)

Parameter

Description

x

The x-coordinate of the top-left corner of the rectangle, given as an integer from 0 to 640.

y

The y-coordinate of the top-left corner of the rectangle, given as an integer from 0 to 480.

width

The width of the rectangle, given as an integer from 0 to 640.

height

The height of the rectangle, given as an integer from 0 to 480.

color

Optional. Sets the fill color of the rectangle. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Draw two rectangles on the screen.
controller.screen.draw_rectangle(x=0, y=0, width=620, height=460)
controller.screen.draw_rectangle(x=200, y=180, width=200, height=100, color=GREEN)

A screenshot of the VEX AIR Drone Controller's screen with a solid green rectangle with a thin white border printed in the center, and a thin white rectangle printed around the outer edges of the screen.

draw_circle#

draw_circle draws a circle with its center at the specified (x, y) coordinate and a size determined by the given radius, all measured in pixels. The circle’s outline is drawn using the current pen width set by set_pen_width and the pen color set by set_pen_color. The interior is filled with the color set by set_fill_color.

The x and y-coordinates use the default origin of (0, 0) unless a different origin has been set using set_origin.

Usage:
controller.screen.draw_circle(x, y, radius, color)

Parameter

Description

x

The x-coordinate of the center of the circle, given as an integer from 0 to 640.

y

The y-coordinate of the center of the circle, given as an integer from 0 to 480.

radius

The radius of the circle, given as an integer from 0 to 480 pixels.

color

Optional. Sets the fill color of the circle. Options include:

  • BLAC
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW
You can also specify a custom color.

# Draw one green circle on the screen.
controller.screen.set_fill_color(GREEN)
controller.screen.draw_circle(x=320, y=240, radius=200, color=GREEN)

A screenshot of the VEX AIR Drone Controller's screen with a large solid green circle with a thin white border drawn centered on the screen.

show_file#

show_file draws a custom uploaded image on the controller’s screen, with its position set using the x, y, and center parameters based on the image’s reference point.

Usage:
controller.screen.show_file(file, x, y, scale_width, scale_height, rotate, use_alpha)

Parameter

Description

file

The user-uploaded image to use. Options will change if image names are edited in the Control Panel.

x

The horizontal offset for the image, given as an integer in pixels. Positive values move it right; negative values move it left.

y

The vertical offset for the image, given as an integer in pixels. Positive values move it down; negative values move it up.

scale_width

Optional. The image width being scaled to, given as an integer in pixels.

scale_height

Optional. The image height being scaled to, given as an integer in pixels.

rotation

Optional. The degree which image being rotated to, given as an integer from 0 to 359.

use_alpha

Optional. Use alpha channel for image to show transparent. Options include:

  • True
  • False

# Display uploaded Image 1 in the top left corner.
controller.screen.show_file(IMAGE1, x=0, y=0)

# Display uploaded Image 1 scaled to the full screen.
controller.screen.show_file(IMAGE1, x=65, y=0, scale_width=640, scale_height=480)

# Display uploaded Image 1 with rotation of 180 degrees.
controller.screen.show_file(IMAGE1, x=-65, y=0, rotation=180)

# Upload an image with a transparent background.
# Display uploaded Image 1 with alpha channel enabled.
controller.screen.show_file(IMAGE1, x=0, y=0, use_alpha=True)

Touch#

pressing#

pressing returns whether the controller’s screen is currently being pressed as a Boolean:

  • True – The screen is being pressed.

  • False – The screen is not being pressed.

Usage:
controller.screen.pressing()

Parameters

Description

This method has no parameters.

# Play a sound when the screen is pressed.
while True:
    if controller.screen.pressing():
        controller.sound.play_note("C5", 500)
    wait(5, MSEC)

# Display different messages after the screen is pressed
while not controller.screen.pressing():
    wait(5, MSEC)
controller.screen.print("First message!")
controller.screen.next_row()
# Lift finger to press the screen again
while controller.screen.pressing():
    wait(5, MSEC)
while not controller.screen.pressing():
    wait(5, MSEC)
controller.screen.print("Second message!")
controller.screen.next_row()

x_position#

x_position returns the x-coordinate in pixels where the screen was pressed, as an integer from 0 (left) to 640 (right).

A VEX AIR Drone Controller with the printable area of the screen dimensions labeled and outlined in a red box. The coordinates begin with (0,0) in the upper left corner, and proceed clockwise with (0, 640), (480, 640), and (480,0) to the lower left corner. The center coorindates of the scrren are labeled (240, 320).

Usage:
controller.screen.x_position()

Parameters

Description

This method has no parameters.

# Play a high or low note based on where screen is pressed.
while True:
    if controller.screen.pressing():
        if controller.screen.x_position() > 320:
            controller.sound.play_note("C6", 500)
        else:
            controller.sound.play_note("C4", 500)
    wait(5, MSEC)

y_position#

y_position returns the y-coordinate in pixels where the screen was pressed, as an integer from 0 (top) to 480 (bottom).

A VEX AIR Drone Controller with the printable area of the screen dimensions labeled and outlined in a red box. The coordinates begin with (0,0) in the upper left corner, and proceed clockwise with (0, 640), (480, 640), and (480,0) to the lower left corner. The center coorindates of the scrren are labeled (240, 320).

Usage:
controller.screen.y_position()

# Play a high or low note based on where screen is pressed.
while True:
    if controller.screen.pressing():
        if controller.screen.y_position() > 240:
            controller.sound.play_note("C6", 500)
        else:
            controller.sound.play_note("C4", 500)
    wait(5, MSEC)

Callback#

pressed#

pressed registers a method to be called when the controller’s screen is pressed.

Usage:
controller.screen.pressed(callback, arg)

Parameters

Description

callback

A function that is previously defined to execute when the axis’ value changes.

arg

Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information.

# Play a sound when the screen is pressed.
def play_sound():
    controller.sound.play_note("C5", 500)

controller.screen.pressed(play_sound)

released#

released registers a method to be called when the screen is no longer being pressed.

Usage:
controller.screen.released(callback, arg)

Parameters

Description

callback

A function that is previously defined to execute when the axis’ value changes.

arg

Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information.

# Play a sound when the screen is pressed.
def play_sound():
    controller.sound.play_note("C5", 500)
    
controller.screen.released(play_sound)