Screen#

Introduction#

The Screen blocks control the V5 Brain’s touchscreen, allowing your robot to show text, numbers, and graphics, and respond to touch input.

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

For drawing, the Brain’s resolution is 480 x 240 pixels.

The V5 Brain screen with red grid lines showing the layout of 12 rows and 48 columns in total. The pixel dimensions are 479 wide by 239 tall. The upper left corner begins at (0,0) pixels and row 1, column 1, while the lower right corner ends at (479, 239) pixels and row 12, column 48.

Below is a list of available blocks:

Cursor Print – Display text and manage the print cursor.

Settings – Change the appearance of text and graphics.

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

Touch – Detect touch input on the Brain’s screen.

  • screen pressed – Reports whether the screen is currently being touched.

  • screen position – Reports the selected x or y coordinate of the last screen press.

  • when screen – Runs attached blocks when the screen is pressed or released.

Cursor Print#

set cursor to row column on screen#

The set cursor to row column on screen stack block moves the cursor to a specific row and column on the Brain screen. The next print on screen block will start printing at that location. How many rows and columns can comfortably fit depends on the selected font. With the default monospaced medium font, up to 8 rows and 13 columns can be displayed clearly. Text placed beyond this range may be cut off or become difficult to read.

Monospaced fonts have characters that are all the same width, making text placement consistent. In contrast, proportional fonts vary in character width, so some letters take up more space than others. However, regardless of which type is used, the set cursor to row column on screen stack block positions the cursor based on row and column size, not font style. The font size can be adjusted using the set font on screen stack block.

Set cursor stack block#
    set cursor to row [1] column [1] on screen

Parameters

Description

row

The row to move the cursor to.

column

The column to move the cursor to.

Example

When started, moves the cursor to row 3, column 2 on the screen and prints ‘Row 3, Column 2’.#
    when started
    [Display text starting at Row 3 Column 12.]
    set cursor to row [3] column [12] on screen
    print [Row 3, Column 12] on screen ▶

A screenshot of the V5 Brain showing Row 3 Column 12 printed in the upper portion near the center of screen, at that position.

set cursor to next row on screen#

The set cursor to next row on screen stack block moves the cursor to column 1 on the next row on the Brain screen.

set cursor to next row stack block#
    set cursor to next row on screen

Parameters

Description

This block has no parameters.

Example

When started, prints ‘Line 1’ on the screen, moves the cursor to the next row, and then prints ‘Line 2’.#
    when started
    [Display two lines of text.]
    print [Line 1] on screen ▶
    set cursor to next row on screen
    print [Line 2] on screen ▶

A screenshot of the V5 Brain screen showing two lines of white text in the upper left corner. The top line reads Line 1, and the second line directly below it reads Line 2.

clear row on screen#

The clear row on screen stack block clears a single row of text on the Brain screen.

Clear row stack block#
    clear row [1] on screen

Parameters

Description

row

The row number to clear.

Example

When started, prints text on two rows. The first row remains, while the second row disappears after 3 seconds.#
    when started
    [Only keep the text on row 1.]
    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 reporter block reports the column number where text will be printed as an integer.

screen cursor column reporter block#
    (screen cursor column)

Parameters

Description

This block has no parameters.

Example

When started, moves the cursor to row 3, column 2 on the screen and prints the current cursor column number.#
    when started
    [Display the cursor's current column.]
    set cursor to row [3] column [15] on screen
    print (screen cursor column) on screen ▶

A screenshot of the V5 Brain screen showing the text 15 in white in the upper left quadrant of the screen, at the row 3 column 15 position.

screen cursor row#

The screen cursor row reporter block reports the row number where text will be printed as an integer.

screen cursor row reporter block#
    (screen cursor row)

Parameters

Description

This block has no parameters.

Example

When started, moves the cursor to row 6, column 2 on the screen and prints the current cursor row number.#
    when started
    [Display the cursor's current row.]
    set cursor to row [3] column [2] on screen
    print (screen cursor row) on screen ▶

A screenshot of the V5 Brain screen showing the text 3 in white in the upper left quadrant of the screen, at the row 3 column 2 position.

Settings#

clear screen#

The clear screen stack block clears all drawings and text from the Brain screen.

clear screen stack block#
    clear screen

Parameters

Description

This block has no parameters.

Example

When started, draws a circle with center (120,120) and radius 40 pixels. After 2 seconds, the screen is cleared.#
    when started
    [Draw a circle, and clear it after 2 seconds.]
    draw circle [120] [120] [40] on screen
    wait [2] seconds
    clear screen

set font on screen#

The set font on screen stack block sets the font and size used for displaying text on the Brain screen. This font will apply to all subsequently printed text.

set font stack block#
    set font to [monospaced v] [medium v] on screen

Parameters

Description

style

The font style: monospaced or proportional

size

The font size (examples below):

  • extra small
  • small
  • medium
  • large
  • extra large
  • super large
Note: Extra small and small sizes are not available for proportional fonts.

A screenshot of the V5 Brain screen with numbers and letters printed in white in the upper left corner in MONO 12 font. It shows A-Z on one line, across about a quarter of the width of screen. In the bottom left corner it reads 80 columns and 20 rows.
monospaced extra small

The same image as the one previous, with Mono 15 font. It shows A-Z on one line, across nearly half width of the screen. In the bottom left corner it reads 68 columns and 16 rows.
monospaced small

The same image as the one previous, with Mono 20 font. It shows A-Z on one line, across nearly two thirds of the width of the screen. In the bottom left corner it reads 48 columns and 12 rows.
monospaced medium

The same image as the one previous, with Mono 30 font. It shows A-Z on one line, across nearly the whole width of the screen. In the bottom left corner it reads 32 columns and 8 rows.
monospaced large

The same image as the one previous, with Mono 40 font. It shows A-X on one line, spanning the width the screen. In the bottom left corner it reads 24 columns and 6 rows.
monospaced extra large

The same image as the one previous, with Mono 60 font. It shows A-P on one line, spanning the width the screen. On the bottom it reads 16 columns and 4 rows.
monospaced super large

The same image as the one previous, with Prop 20 font. It shows A-Z on one line, across nearly two thirds of the width of the screen. In the bottom left corner it reads 48 columns and 12 rows.
proportional medium

The same image as the one previous, with Prop 30 font. It shows A-Z on one line, spanning nearly the width of the screen. In the bottom left corner it reads 32 columns and 8 rows.
proportional large

The same image as the one previous, with Prop 40 font. It shows A-U on one line, spanning the width of the screen. In the bottom left corner it reads 24 columns and 6 rows.
proportional extra large

The same image as the one previous, with Prop 60 font. It shows A-N on one line, spanning the width of the screen. On the bottom it reads 15 columns and 4 rows.
proportional super large

Example

When started, sets the font to ‘monospaced extra large’ and prints ‘VEX’ on the screen.#
    when started
    [Display text using a larger font]
    set font to [monospaced v] [extra large v] on screen
    print [VEX] on screen ▶

A screenshot of the V5 Brain screen showing the text "VEX" in larger font than the default in the upper left corner.

set print precision on screen#

The set print precision on screen stack block sets how many decimal places to show when printing numbers on the Brain screen. This print precision will apply to all subsequently printed numbers.

set print precision stack block#
    set print precision to [0.1 v] on screen

Parameters

Description

precision

The print precision to use:

  • 1
  • 0.1
  • 0.01
  • 0.001
  • All Digits

Example

When started, sets print precision to two decimal places and prints 1/3 as 0.33 on the screen.#
    when started
    [Print 1/3 as 0.33.]
    set print precision to [0.01 v] on screen
    print ([1] [math_division v] [3]) on screen ▶

A screenshot of the V5 Brain screen showing the text "0.33" in the upper left corner.

set pen width on screen#

The set pen width on screen stack block sets the thickness of drawn lines and shape outlines.

set pen width stack block#
    set pen width to [10] on screen

Parameters

Description

width

The pen width, in pixels, from 0 to 32.

Example

When started, sets the pen width to 10 pixels and draws a rectangle with the top-left corner at (50,50), width 130 pixels, and height 60 pixels.#
    when started
    [Draw a rectangle with a pen width of 10.]
    set pen width to [10] on screen
    draw rectangle [50] [50] [130] [60] on screen

A screenshot of the V5 Brain screen showing a rectangle with thick borders printed in the upper left quadrant of the screen.

set pen / font color on screen#

The set pen / font color on screen stack block sets the color of text, pixels, lines, and shape outlines.

set pen / font color stack block#
    set pen / font color to [red v] on screen

Parameters

Description

color

The pen and font color to use:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan
  • transparent

Example

When started, sets the pen color to orange and draws a rectangle with the top-left corner at (50, 50), width 130 pixels, and height 60 pixels.#
    when started
    [Draw a rectangle with orange borders.]
    set pen / font color to [orange v] on screen
    draw rectangle [50] [50] [130] [60] on screen

A screenshot of the V5 Brain screen showing a rectangle drawn in orange in the upper left quadrant of the screen.

set fill color on screen#

The set fill color on screen stack block sets the fill color used when shapes are drawn.

set fill color stack block#
    set fill color to [red v] on screen

Parameters

Description

color

The fill color to use:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan
  • transparent

Examples

When started, sets the fill color to purple and draws a rectangle. It is at (50, 130) with a width of 100 pixels and a height of 60 pixels.#
    when started
    [Draw a purple rectangle.]
    set fill color to [purple v] on screen
    draw rectangle [50] [130] [100] [60] on screen

A screenshot of the V5 Brain screen showing a rectangle filled with purple in the lower left quadrant of the screen.

Draw#

draw pixel on screen#

The draw pixel on screen stack block draws one pixel at the selected x and y coordinate using the current pen color.

draw pixel stack block#
    draw pixel [0] [0] on screen

Parameters

Description

x

The x-coordinate to draw the pixel from 0 to 479.

y

The y-coordinate to draw the pixel from 0 to 239.

Example

When started, draws four pixels that mark the corners of a small square.#
    when started
    [Draw the pixels marking the corners of a square.]
    draw pixel [250] [100] on screen
    draw pixel [275] [100] on screen
    draw pixel [250] [125] on screen
    draw pixel [275] [125] on screen

A screenshot of the V5 Brain screen showing an assortment of pixels showing the corners of a square near the center of the screen.

draw line on screen#

The draw line on screen stack block draws a line from the first screen coordinate (x1, y1) to the second screen coordinate (x2, y2) using the current pen width and pen color.

draw line stack block#
    draw line [0] [0] [10] [10] on screen

Parameters

Description

x1

The x-coordinate in pixels of the start of the line from 0 to 479.

y1

The y-coordinate in pixels of the start of the line from 0 to 239.

x2

The x-coordinate in pixels of the end of the line from 0 to 479.

y2

The y-coordinate in pixels of the end of the line from 0 to 239.

Example

When started, draws a diagonal line from the top-left corner (0, 0) to the bottom-right corner (479, 239) of the screen.#
    when started
    [Draw a line from the top left to bottom right of the screen.]
    draw line [0] [0] [479] [239] on screen

A screenshot of the V5 Brain screen shows a thin diagonal line across the center, from the upper left corner to the lower right corner.

draw rectangle on screen#

The draw rectangle on screen stack block draws a rectangle using the current pen width, pen color, and fill color.

draw rectangle stack block#
    draw rectangle [0] [0] [10] [10] on screen

Parameters

Description

x

The x-coordinate in pixels of the top-left corner of the rectangle from 0 to 479.

y

The y-coordinate in pixels of the top-left corner of the rectangle from 0 to 239.

width

The width of the rectangle in pixels.

height

The height of the rectangle in pixels.

Example

When started, draws a rectangle on the screen with the top-left corner at (50,50), width of 130 pixels, and height of 60 pixels.#
    when started
    [Draw a rectangle on the screen.]
    draw rectangle [50] [50] [130] [60] on screen

A screenshot of the V5 Brain's screen shows a rectangle with a thin white border printed in the upper left quadrant.

draw circle on screen#

The draw circle on screen stack block draws a circle using the current pen width, pen color, and fill color.

draw circle stack block#
    draw circle [0] [0] [10] on screen

Parameters

Description

x

The x-coordinate in pixels of the center of the circle from 0 to 479.

y

The y-coordinate in pixels of the center of the circle from 0 to 239.

radius

The radius of the circle in pixels.

Example

When started, draws a circle on the screen with the center at (120, 120) and a radius of 40 pixels.#
    when started
    [Draw a circle on the screen.]
    draw circle [120] [120] [40] on screen

A screenshot of the V5 Brain screen shows a circle with a thin white border drawn in the center.

Touch#

screen pressed#

The screen pressed Boolean block reports whether the Brain’s touchscreen is currently being pressed.

  • True – The screen is being pressed.

  • False – The screen is not being pressed.

screen pressed Boolean block#
    <screen pressed?>

Parameters

Description

This block has no parameters.

When started, changes the screen color after the screen is pressed.#
    when started
    [Change the screen's color after it's pressed.]
    wait until <screen pressed?>
    set fill color to [green v] on screen
    draw rectangle [0] [0] [479] [239] on screen
When the screen is pressed, the first message is shown. The code then waits until the screen is released, and only continues after the screen is pressed again to show the second message.#
    when started
    [Display different messages after the screen is pressed.]
    wait until <screen pressed?>
    print [First message!] on screen ▶
    set cursor to next row on screen
    [Lift finger to press the screen again.]
    wait until <not <screen pressed?>>
    wait until <screen pressed?>
    print [Second message!] on screen ▶

screen position#

The screen position reporter block reports the selected coordinate of the last screen press. The x-coordinate is from 0 (left) to 479 (right). The y-coordinate is from 0 (top) to 239 (bottom).

screen position reporter block#
    (screen [x v] position)

Parameters

Description

axis

The coordinate of the last screen press to report: x – The horizontal position or y – The vertical position

When the Brain screen is pressed, draws a circle at the press location.#
    when started
    [Display a circle where the screen is pressed.]
    wait until <screen pressed?>
    set fill color to [white v] on screen
    draw circle (screen [x v] position) (screen [y v] position) [20] on screen

when screen#

The when screen hat block runs the attached stack of blocks when the Brain screen is pressed or released.

when screen hat block#
    when Brain screen [pressed v] :: hat events

Parameters

Description

state

When to run the attached stack of blocks: pressed runs when the screen is pressed, and released runs when the screen is released.

When the Brain screen is pressed, draws a circle at the press location.#
    when Brain screen [pressed v] :: hat events
    [Color the screen with polka dots by pressing it repeatedly.]
    set fill color to [red v] on screen
    draw circle (screen [x v] position) (screen [y v] position) [20] on screen