Screen#

Introduction#

The EXP Brain’s screen has a set amount of rows and columns to use when printing text on its screen.

By default, the font for printing to the Brain is monospaced small which has 7 rows and 20 columns.

For drawing, the Brain’s resolution is 159 x 107 pixels.

A labeled grid diagram of the VEX Brain screen showing rows, columns, pixel dimensions, and coordinates, with red lines outlining the grid.

Below is a list of available methods:

Cursor Print – Display text and manage the print cursor.

  • print – Prints text on the screen using the current cursor position.

  • print_at – Prints text at specific x and y coordinates on the screen.

  • set_cursor – Sets the cursor position.

  • set_origin – Sets the origin used for drawing graphics on the Brain’s screen.

  • set_font – Sets the font type used for printing text on the Brain’s screen.

  • column – Returns the current column where text will be printed.

  • row – Returns the current row where text will be printed.

  • get_string_width – Gets the width of a string in pixels as if it was on the Brain’s screen.

  • get_string_height – Gets the height of a string in pixels as if it was on the Brain’s screen.

Settings – Change the appearance of text and graphics.

  • clear_screen – Clears the whole Brain’s screen to a single color.

  • clear_row – Clears a row to a single color.

  • next_row – Moves the cursor to the next row.

  • set_pen_width – Sets the pen width used for drawing lines, rectangles and circles.

  • set_pen_color – Sets the pen color used for drawing lines, rectangles and circles.

  • set_fill_color – Sets the fill color used for drawing rectangles and circles.

Draw – Create shapes, lines, and graphics on the Brain screen.

Cursor Print#

print#

print prints text on the screen using the current cursor position.

Usage:

brain.screen.print(text, sep, precision)

Parameters

Description

text

The text to print.

sep

Optional. A string to inset between values. This must be written as a keyword argument (sep=). The default is “”.

precision

Optional. The number of decimal places to display when printing simple numbers. This must be written as a keyword argument(precision=). The default is 2.

brain.screen.print("Hello, Robot!")

A screenshot of the EXP Brain showing "Hello Robot" printed on the screen.

# Print the number 1 on the Brain's screen at current
# cursor position.
brain.screen.print(1)

# Print the numbers 1, 2, 3 and 4 on the Brain's screen at
# current cursor position separated by a '-'.
brain.screen.print(1, 2, 3, 4, sep='-')

set_cursor#

set_cursor sets the cursor position. The row and column spacing will take into account the selected font. The default cursor position is Row 1, Column 1.

Usage:

brain.screen.set_cursor(row, column)

Parameters

Description

row

The row to set the cursor to.

column

The column to set the cursor to.

# Display text starting at Row 3 Column 10.
brain.screen.set_cursor(3, 10)
brain.screen.print("R3, C10")

A screenshot of the EXP Brain showing "R3, C10" printed on the screen.

set_origin#

set_origin sets the origin used for drawing graphics on the Brain’s screen. Drawing functions consider the top left corner of the Brain’s screen as the origin. This function can move the origin to an alternate position such as the center of the Brain’s screen.

Usage:

brain.screen.set_origin(x, y)

Parameters

Description

x

The origin’s x position relative to top left corner.

y

The origin’s y position relative to top left corner.

set_font#

set_font sets the font type used for printing text on the Brain’s screen.

Usage:

brain.screen.set_font(fontname)

Parameters

Description

fontname

The font size (examples below):

  • MONO12
  • MONO15
  • MONO20
  • MONO30
  • MONO40
  • MONO60
  • PROP20
  • PROP30
  • PROP40
  • PROP60
Note: Extra small and small sizes are not available for proportional fonts.

The Brain's screen printed numbers and letters with size MONO 12 font. It shows A through Z and all numbers. On the bottom of the screen, it says 9 rows, 26 columns.
MONO12

The Brain's screen printed numbers and letters with size MONO 15 font. It shows A through T and all numbers. On the bottom of the screen, it says 7 rows, 22 columns.
MONO15

The Brain's screen printed numbers and letters with size MONO 20 font. It shows A through P and all numbers. On the bottom of the screen, it says 5 rows, 16 columns.
MONO20

The Brain's screen printed numbers and letters with size MONO 30 font. It shows A through J. On the bottom of the screen, it says R:3 C:10.
MONO30

The Brain's screen printed numbers and letters with size MONO 40 font. On the bottom of the screen, it says R:2 C:8.
MONO40

The Brain's screen printed numbers and letters with size MONO 60 font. Only MON60 is displayed.
MONO60

The Brain's screen printed numbers and letters with size PROP 20 font. It shows A through W and all numbers. On the bottom of the screen, it says 5 rows, 16 columns.
PROP20

The Brain's screen printed numbers and letters with size PROP 30 font. It shows A through P. On the bottom of the screen, it says R:3 C:10.
PROP30

The Brain's screen printed numbers and letters with size PROP 40 font. On the bottom of the screen, it says R:2 C:8.
PROP40

TThe Brain's screen printed numbers and letters with size PROP 60 font. Only PROP60 is displayed.
PROP60

# Set the font type to MONO40.
brain.screen.set_font(FontType.MONO40)
brain.screen.print("VEX")

A screenshot of the EXP Brain showing the text "VEX" in larger font than the default.

column#

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

Usage:

brain.screen.column()

Parameters

Description

This method has no parameters.

# Display the cursor's current column.
brain.screen.set_cursor(3, 10)
brain.screen.print(brain.screen.column())

A screenshot of the EXP Brain showing the text "10" on column 10.

row#

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

Usage:

brain.screen.row()

Parameters

Description

This method has no parameters.

# Display the cursor's current row.
brain.screen.set_cursor(3, 10)
brain.screen.print(brain.screen.row())

A screenshot of the EXP Brain showing the text "3" on row 3.

get_string_width#

get_string_width gets the width of a string in pixels as if it was on the Brain’s screen. The width of a string changes based on the length of the string and the size of the font.

Usage:

brain.screen.get_string_width(string)

Parameters

Description

string

The string to measure.

get_string_height#

get_string_height gets the height of a string in pixels as if it was on the Brain’s screen. The height of a string changes based on the length of the string and the size of the font.

Usage:

brain.screen.get_string_height(string)

Parameters

Description

string

The string to measure.

Mutators#

clear_screen#

clear_screen clears the whole Brain’s screen to a single color.

Usage:

brain.screen.clear_screen(color)

Parameters

Description

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.BLUE_GREEN
  • Color.BLUE_VIOLET
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • COLOR.RED_ORANGE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
You can also specify a custom color.

# Print VEXcode on the Brain's screen.
brain.screen.print("VEXcode")

# Clear screen to black.
brain.screen.clear_screen()

# Print VEXcode on the Brain's screen.
brain.screen.print("VEXcode")

# Clear screen to blue using predefined color.
brain.screen.clear_screen(Color.BLUE)

clear_row#

clear_row clears a row to a single color.

Usage:

brain.screen.clear_row(row)

Parameters

Description

row

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

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.BLUE_GREEN
  • Color.BLUE_VIOLET
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • COLOR.RED_ORANGE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
You can also specify a custom color.

# Clear Brain's screen to black.
brain.screen.clear_row()

# Clear Brain's screen to blue using predefined color.
brain.screen.clear_row(2, Color.BLUE)

next_row#

next_row moves the cursor to the next row.

Usage:

brain.screen.next_row()

Parameters

Description

This method has no parameters.

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

A screenshot of the EXP Brain showing the text "3" on row 3.

set_pen_width#

set_pen_width sets the pen width used for drawing lines, rectangles and circles.

Usage:

brain.screen.set_pen_width(width)

Parameters

Description

width

The pen width.

# Draw a rectangle with a pen width of 10.
brain.screen.set_pen_width(10)
brain.screen.draw_rectangle(20, 20, 75, 50)

A screenshot of the EXP Brain showing a rectangle with thick borders.

set_pen_color#

set_pen_color sets the pen color used for drawing lines, rectangles and circles.

Usage:

brain.screen.set_pen_color(color)

Parameters

Description

color

A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.BLUE_GREEN
  • Color.BLUE_VIOLET
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • COLOR.RED_ORANGE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
You can also specify a custom color.

# Draw a rectangle with orange borders. 
brain.screen.set_pen_color(Color.ORANGE)
brain.screen.draw_rectangle(20, 20, 75, 50)

A screenshot of the EXP Brain showing a rectangle with orange borders.

# Set pen color red using a hex value.
brain.screen.set_pen_color(0xFF0000)

# Set pen color blue using predefined color.
brain.screen.set_pen_color(Color.BLUE)

# Set pen color green using web string.
brain.screen.set_pen_color("#00FF00")

set_fill_color#

set_fill_color sets the fill color used for drawing rectangles and circles.

Usage:

brain.screen.set_fill_color(color)

Parameters

Description

color

A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.BLUE_GREEN
  • Color.BLUE_VIOLET
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • COLOR.RED_ORANGE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
You can also specify a custom color.

# Draw a purple rectangle.
brain.screen.set_fill_color(Color.PURPLE)
brain.screen.draw_rectangle(20, 20, 75, 50)

A screenshot of the EXP Brain showing a rectangle filled with purple.

# Set pen color red using a hex value.
brain.screen.set_fill_color(0xFF0000)

# Set pen color blue using predefined color.
brain.screen.set_fill_color(Color.BLUE)

# Set pen color green using web string.
brain.screen.set_fill_color("#00FF00")

Draw#

draw_pixel#

draw_pixel draws a pixel using the current pen color.

Usage:

brain.screen.draw_pixel(x, y)

Parameters

Description

x

The x position to draw the pixel referenced to the screen origin.

y

The y position to draw the pixel referenced to the screen origin.

# Draw the pixels marking the corners of a square.
brain.screen.draw_pixel(50, 50)
brain.screen.draw_pixel(50, 75)
brain.screen.draw_pixel(75, 50)
brain.screen.draw_pixel(75, 75)

A screenshot of the EXP Brain showing an assortment of pixels showing the corners of a square.

draw_line#

draw_line draws a line using the current pen color.

Usage:

brain.screen.draw_line(x1, y1, x2, y2)

Parameters

Description

x1

The x position of the start of the line referenced to the screen origin.

y1

The y position of the start of the line referenced to the screen origin.

x2

The x position of the end of the line referenced to the screen origin.

y2

The y position of the end of the line referenced to the screen origin.

# Draw a line from the top left to bottom right of the screen.
brain.screen.draw_line(0, 0, 159, 107)

The Brain's screen shows a thin diagonal line across the center, from the upper left corner to the lower right corner.

draw_rectangle#

draw_rectangle draws a rectangle on the screen using the current pen and fill colors.

Usage:

brain.screen.draw_rectangle(x, y, width, height, color)

Parameters

Description

x

The x position of the top-left corner of the rectangle referenced to the screen origin.

y

The y position of the top-left corner of the rectangle referenced to the screen origin.

width

The width of the rectangle.

height

The height of the rectangle.

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.BLUE_GREEN
  • Color.BLUE_VIOLET
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • COLOR.RED_ORANGE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
You can also specify a custom color.

# Draw a rectangle on the screen.
brain.screen.draw_rectangle(20, 20, 80, 30)

The Brain's screen shows a rectangle with a thin white border on the screen.

# Draw a green rectangle on the screen that is filled using blue.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_rectangle(10, 10, 20, 20)

# Draw a green rectangle on the screen that is filled using red.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.draw_rectangle(50, 50, 20, 20, Color.RED)

draw_circle#

draw_circle draws a circle using the current pen and fill colors.

Usage:

brain.screen.draw_circle(x, y, radius, color)

Parameters

Description

x

The x position of the circle center referenced to the screen origin.

y

The y position of the circle center referenced to the screen origin.

radius

The radius of the circle.

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.BLUE_GREEN
  • Color.BLUE_VIOLET
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • COLOR.RED_ORANGE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
You can also specify a custom color.

# Draw a circle on the screen.
brain.screen.draw_circle(80, 50, 20)

The Brain's screen shows a circle with a thin white border drawn in the center.

# Draw a green circle on the Brain's screen that is filled using blue.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_circle(50, 50, 10)

# Draw a green circle on the Brain's screen that is filled using red.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.draw_circle(100, 50, 10, Color.RED)

draw_image_from_file#

draw_image_from_file draws an image from the SD card. The filename you put when calling the method must be located on the SD card.

Usage:

brain.screen.draw_image_from_file(filename, x, y)

Parameters

Description

filename

The filename of the image.

x

The x coordinate for the top-left corner of the image on the screen.

y

The y coordinate for the top-left corner of the image on the screen.

# Draw the vex.bmp image on the Brain's screen at coordinate 0, 0.
brain.screen.draw_image_from_file('vex.bmp', 0, 0)

render#

render switches drawing to double buffered and renders the Brain’s screen. Once called, further drawing will not appear on the Brain’s screen until the next time render is called.

  • True if buffer was successfully rendered to the screen.

  • False if buffer was not successfully rendered to the screen.

Usage:

brain.screen.render()

Parameters

Description

This method has no parameters.

set_clip_region#

set_clip_region sets the clip region for drawing the supplied rectangle.

Usage:

brain.screen.set_clip_region(x, y, width, height)

Parameters

Description

x

The x position of the top-left corner of the rectangle, referenced to the screen origin.

y

The y position of the top-left corner of the rectangle, referenced to the screen origin.

width

The width of the rectangle.

height

The height of the rectangle.