屏幕#

介绍#

VEX AIR 无人机控制器的屏幕提供用于显示文本、管理光标、绘制形状和处理触摸交互的模块。

**注意:**如果 VEX AIR 无人机已与控制器配对,则打印屏幕顶部将显示一个计时器,指示当前项目的已用时间。任何文本或绘图都将显示在计时器后面。

以下是所有可用块的列表,按功能分组:

光标打印 - 使用行列光标系统管理文本显示。

XY 打印 - 在基于像素的坐标处打印文本。

  • print at — 在指定的 x 和 y 坐标处显示文本。

  • 设置屏幕原点 — 更改用于绘图和打印的原点 (0, 0)。

设置 - 自定义文本格式和屏幕显示。

绘制——创建图形和视觉元素。

触摸 - 检测屏幕交互。

光标打印#

打印#

print 块在控制器屏幕上的当前 光标位置字体 显示文本。

打印堆栈块#
在屏幕上打印 [VEXcode]▶

参数

描述

价值

要在屏幕上显示的文本、数字或变量值。

扩大箭头

展开块读取 并将光标设置到下一行 ,并使光标移动到该块之后的下一行。

例子

启动时,在屏幕的起始光标位置显示消息“你好,无人机!”。#
当开始
[Display a message at the starting cursor position.]
在屏幕上打印 [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!

将光标设置到行列#

使用“将光标置于行列”块时,光标将放置在屏幕上的特定行和#set-font。屏幕上可显示的字符数量取决于所选字体。可以使用“设置字体”块更改字体大小。使用默认的等宽中等字体,最多可清晰显示 18 行和 53 列。超出此范围的文本可能会被截断或难以阅读。

设置游标堆栈块#
在屏幕上设定光标至 [1] 行 [1] 列

参数

描述

游标所在行。

柱子

光标所在的列。

示例

启动后,将光标移动到屏幕上的第 7 行、第 25 列,并打印“第 7 行、第 25 列”。#
当开始
[Display text starting at Row 7 Column 25.]
在屏幕上设定光标至 [7] 行 [25] 列
在屏幕上打印 [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.

将光标设置到下一行#

将光标设置到下一行块将光标移动到控制器屏幕上下一行的第 1 列。

将光标设置到下一行堆栈块#
在屏幕上设定光标至下一行

参数

描述

该块没有参数。

例子

启动时,在屏幕上打印“第 1 行”,将光标移动到下一行,然后打印“第 2 行”。#
当开始
[Display two lines of text.]
在屏幕上打印 [Line 1]▶
在屏幕上设定光标至下一行
在屏幕上打印 [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.

清除行#

清除行块清除控制器屏幕上的一行文本。

清除行堆栈块#
清除屏幕第 [1] 行

参数

描述

要清除的行号。

例子

启动后,打印两行文本。第一行保留,第二行在 3 秒后消失。#
当开始
[Clear only the second row of text.]
在屏幕上打印 [This text stays]▶
在屏幕上设定光标至下一行
在屏幕上打印 [This text disappears]▶
等待 [3] 秒
清除屏幕第 [2] 行

屏幕光标列#

屏幕光标列返回光标的当前列位置。

屏幕光标列报告块#
(屏幕光标列数)

参数

描述

该块没有参数。

例子

启动时,将光标移动到屏幕上的第 7 行、第 25 列,并打印当前光标列号。#
当开始
[Display the cursor's current column.]
在屏幕上设定光标至 [7] 行 [25] 列
在屏幕上打印 (屏幕光标列数)▶

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.

屏幕光标行#

屏幕光标行块返回光标的当前行位置。

屏幕光标行报告块#
(屏幕光标行数)

参数

描述

该块没有参数。

例子

启动时,将光标移动到屏幕上的第 7 行、第 25 列,并打印当前光标行号。#
当开始
[Display the cursor's current row.]
在屏幕上设定光标至 [7] 行 [25] 列
在屏幕上打印 (屏幕光标行数)▶

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.

XY打印#

设置屏幕原点#

设置屏幕原点 设置在控制器屏幕上绘图或打印时使用的原点 (0, 0)。默认情况下,绘图或打印块将屏幕左上角视为原点。此块可以将原点重置为另一个 (x, y) 屏幕坐标位置。

设置屏幕原点堆栈块#
设置屏幕原点 x: [0] y: [0]

参数

描述

x

设置新原点的 x 坐标(以像素为单位)。

y

设置新原点的 y 坐标(以像素为单位)。

例子

启动时,将屏幕原点设置为 (320, 240),并在新原点处绘制一个矩形,其左上角为 (0,0),宽度为 80 像素,高度为 40 像素。#
当开始
[Set the origin to the center of the screen.]
设置屏幕原点 x: [320] y: [240]
[Draw a rectangle at the new origin.]
在屏幕 [0] [0] [80] [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.

设置#

清除屏幕#

清除屏幕块清除控制器屏幕上的所有图形、文本和图像。

清除屏幕块#
清屏

参数

描述

该块没有参数。

例子

启动时,绘制一个以 (120,120) 为圆心、半径为 40 像素的圆。2 秒后,屏幕清空。#
当开始
[Draw a circle, and clear it after 2 seconds.]
在屏幕 [320] [240] [80] 上画圆形
等待 [2] 秒
清屏

等待屏幕渲染#

等待屏幕渲染块可防止任何后续屏幕块显示,然后在再次使用时立即显示其所有输出。

注意:使用此块会改变项目,以便所有后续屏幕块将保持隐藏状态,直到再次使用等待屏幕渲染块。

等待屏幕渲染

参数

描述

该块没有参数。

例子

启动时,绘制一个以 (120,120) 为圆心、半径为 40 像素的圆。2 秒后,屏幕清空。#
当开始
[Display text and images when button 7 is pressed.]
等待屏幕渲染
在屏幕上打印 [Screen rendered!]▶
在屏幕 [320] [240] [80] 上画圆形
等到 <遥控器按键 [7 v] 按下了?>
等待屏幕渲染

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.

填满屏幕#

填充屏幕块清除控制器屏幕上的所有图形和文本,然后将背景更改为指定的颜色。

填充屏幕块#
屏幕填充色为 [红色 v]

参数

描述

颜色

将背景颜色更改为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色

例子

当开始
[Say "Hello" then turn screen green.]
在屏幕上打印 [Hello]▶
等待 [2] 秒
屏幕填充色为 [绿色 v]

A screenshot of the VEX AIR Drone Controller screen, with the entire printable area of the screen filled with bright green.

设置字体#

设置字体 块设置控制器屏幕上显示文本的字体和大小。此字体将应用于所有后续打印的文本。

设置字体堆栈块#
设定屏幕字体为 [等宽字体 v] [中 v]

参数

描述

类型

字体类型:

  • 等宽
  • 比例

尺寸

字体大小(如下所示):

  • 超小
  • 特小
  • 特大
  • 超大

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.
monospaced super small

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.
monospaced extra small

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.
monospaced small

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.
monospaced medium

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.
monospaced large

The 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.
monospaced extra large

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.
monospaced super large

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.
proportional small

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.
proportional medium

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.
proportional large

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.
proportional extra large

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.
proportional super large

例子

启动时,将字体设置为“等宽超大”并在屏幕上打印“VEX”。#
当开始
[Display text using a larger font.]
设定屏幕字体为 [等宽字体 v] [特大 v]
在屏幕上打印 [VEX]▶

The same image as those previous, now with white text in the upper left corner that reads VEX is Mono 40 font.

set print precision on screen#

The set print precision on screen block sets the precision formatting used for displaying numbers on the controller’s screen. This print precision will apply to all subsequently printed numbers.

设置打印精度堆栈块#
在屏幕上设定打印精度为 [0.1 v]

参数

描述

精确

将打印精度设置为:

  • 1
  • 0.01
  • 0.001
  • 所有数字

例子

启动时,将打印精度设置为小数点后两位,并在屏幕上将 1/3 打印为 0.33。#
当开始
[Print 1/3 as 0.33.]
在屏幕上设定打印精度为 [0.01 v]
在屏幕上打印 ([1] [math_division v] [3])▶

A screenshot of the VEX AIR Drone Controller's screen with white text in the upper left corner that reads 0.33.

设置笔宽#

设置笔宽块设置用于绘制线条和形状的笔宽。

设置笔宽块#
设定屏幕笔宽为 [10]

参数

描述

宽度

笔的宽度(以像素为单位)。

例子

启动时,将笔宽设置为10像素,并绘制一个矩形,其左上角位于(50,50),宽度为130像素,高度为60像素。#
当开始
[Draw a rectangle with a pen width of 10.]
设定屏幕笔宽为 [10]
在屏幕 [200] [200] [200] [80] 上画矩形

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

设置画笔/字体颜色#

设置画笔/字体颜色 块用于设置在控制器屏幕上绘制线条、形状和文本时使用的画笔颜色。默认颜色为白色。

设置钢笔字体颜色#
设定屏幕笔/字体颜色为 [红色 v]

例子

参数

描述

颜色

将笔颜色设置为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色
  • 透明

启动时,将画笔颜色设置为红色,并绘制一个矩形,左上角位于 (50, 50),宽度为 130 像素,高度为 60 像素。#
当开始
[Draw a rectangle with an orange outline.]
设定屏幕笔/字体颜色为 [orange v]
在屏幕 [200] [150] [240] [150] 上画矩形
设定屏幕笔/字体颜色为 [white v]
print [VEXcode AIR] at x: [250] y: [220] on screen

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.

设置文本填充颜色#

设置文本填充颜色 块设置打印文本时使用的突出显示颜色。默认突出显示颜色为透明。

设置填充颜色堆栈块#
将屏幕上的文本填充颜色设置为 [红色 v]

参数

描述

颜色

将文本高亮颜色设置为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色
  • 透明

示例

启动后,将填充颜色设置为橙色,并绘制两个矩形。第一个矩形位于 (50, 50),第二个矩形位于 (50, 130),宽度均为 100 像素,高度均为 60 像素。#
当开始 :: hat events
[Display two colors behind text.]
将屏幕上的文本填充颜色设置为 [红色 v]
在屏幕上打印 ["Red"]▶
在屏幕上设定光标至下一行
将屏幕上的文本填充颜色设置为 [蓝色 v]
在屏幕上打印 ["Blue"]▶

设置绘制填充颜色#

设置绘制填充颜色 块设置绘制形状时填充的颜色。默认填充颜色为黑色。

设置填充颜色堆栈块#
将屏幕上的绘制填充颜色设置为 [红色 v]

参数

描述

颜色

将形状填充颜色设置为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色
  • 透明

示例

启动后,将填充颜色设置为橙色,并绘制两个矩形。第一个矩形位于 (50, 50),第二个矩形位于 (50, 130),宽度均为 100 像素,高度均为 60 像素。#
当开始
[Draw an orange-filled rectangle with text on top.]
将屏幕上的绘制填充颜色设置为 [orange v]
在屏幕 [200] [150] [240] [150] 上画矩形
print [VEXcode AIR] at x: [250] y: [220] on screen

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.

#

显示图像文件#

显示图像文件 块在控制器屏幕上的 设置原点 处绘制自定义用户上传的图像。

显示用户图像堆栈块#
显示图像文件 [IMAGE1 v]

参数

描述

图像编号

要使用的用户上传的图片。如果在控制面板中编辑了图片名称,选项将会更改。

例子

待办事项#
当开始
[Display custom image on screen.]
显示图像文件 [IMAGE1 v]

绘制像素#

绘制像素 块使用当前 画笔颜色 在指定的 (x, y) 屏幕坐标处绘制一个像素。

绘制像素堆栈块#
在屏幕 [0] [0] 上画点

参数

描述

x

绘制像素的 x 坐标,范围从 0 到 640。

y

绘制像素的 y 坐标,范围从 0 到 480。

例子

启动时,在屏幕中心坐标 (120, 120) 处绘制一个像素。#
当开始
[Draw five pixels in a diagonal.]
在屏幕 [360] [200] 上画点
在屏幕 [340] [220] 上画点
在屏幕 [320] [240] 上画点
在屏幕 [300] [260] 上画点
在屏幕 [280] [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.

画线#

画线 块使用当前 笔宽笔颜色 从第一个指定的屏幕坐标 (x1, y1) 到第二个指定的屏幕坐标 (x2, y2) 绘制一条线。

画线堆叠块#
在屏幕 [0] [0] [10] [10] 上画线段

参数

描述

x1

行起点的 x 坐标(以像素为单位),范围从 0 到 640。

y1

线起点的 y 坐标(以像素为单位),范围从 0 到 480。

x2

线末端的 x 坐标(以像素为单位),范围从 0 到 640。

y2

线末端的 y 坐标(以像素为单位),范围从 0 到 480。

例子

启动时,从屏幕左上角(0,0)到右下角(240,240)绘制一条对角线。#
当开始
[Make an X across the screen.]
在屏幕 [0] [0] [640] [480] 上画线段
设定屏幕笔/字体颜色为 [cyan v]
在屏幕 [0] [480] [640] [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.

绘制矩形#

绘制矩形块使用当前画笔宽度画笔颜色填充颜色绘制一个矩形。

绘制矩形块#
在屏幕 [0] [0] [10] [10] 上画矩形

例子

参数

描述

x

矩形左上角的 x 坐标(以像素为单位),范围从 0 到 640。

y

矩形左上角的 y 坐标(以像素为单位),范围从 0 到 480。

宽度

矩形的宽度(以像素为单位)。

高度

矩形的高度(以像素为单位)。

启动时,在屏幕上绘制一个矩形,左上角位于 (50,50),宽度为 130 像素,高度为 60 像素。#
当开始
[Draw two rectangles on the screen.]
在屏幕 [0] [0] [620] [460] 上画矩形
设定屏幕填充色为 [绿色 v]
在屏幕 [200] [180] [200] [100] 上画矩形

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.

画圆#

画圆 块使用当前的 笔宽笔颜色填充颜色 绘制一个圆圈。

画圆堆叠块#
在屏幕 [0] [0] [10] 上画圆形

参数

描述

x

圆心的 x 坐标(以像素为单位),范围从 0 到 640。

y

圆心的 y 坐标(以像素为单位),范围从 0 到 480。

半径

圆的半径(以像素为单位)。

例子

启动时,在屏幕上绘制一个圆心为 (120,120) 、半径为 40 像素的圆圈。#
当开始
[Draw one green circle on the screen.]
设定屏幕填充色为 [绿色 v]
在屏幕 [320] [240] [200] 上画圆形

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.

触碰#

屏幕被按下?#

屏幕是否被按下? 块报告控制器的屏幕当前是否被按下。此块返回一个布尔值:

  • True - 屏幕当前被按下

  • False - 屏幕未被按下

屏幕按下布尔块#
<屏幕按下了?>

参数

描述

该块没有参数。

例子

当开始
[Play a sound when the screen is pressed.]
永久循环
如果 <屏幕按下了?> 那么
播放音符 [低 v] [C v] [note_eight v] ▶
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.#
当开始
[Display different messages after the screen is pressed.]
等到 <屏幕按下了?>
在屏幕上打印 [First message!]▶
在屏幕上设定光标至下一行
[Lift finger to press the screen again.]
等到 <非 <屏幕按下了?>>
等到 <屏幕按下了?>
在屏幕上打印 [Second message!]▶

屏幕位置#

屏幕位置 块返回一个整数,表示按下屏幕时的 x 和 y 坐标(以像素为单位)。x 的返回值介于 0(左)和 640(右)之间。y 的返回值介于 0(上)和 480(下)之间。

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).

屏幕位置报告块#
(屏幕 [X v] 坐标)

参数

描述

协调

最后一次屏幕按下的坐标(以像素为单位):

  • x - 水平位置
  • y - 垂直位置

例子

启动后,持续检测屏幕是否按下。如果按下,则清除屏幕并打印触摸位置的 x 和 y 坐标。#
当开始
[Play high or low note based on where screen is pressed.]
永久循环
如果 <屏幕按下了?> 那么
如果 <(屏幕 [X v] 坐标) [math_greater_than v] [320]> 那么
播放音符 [高 v] [C v] [note_eight v] ▶
否则
播放音符 [低 v] [C v] [note_eight v] ▶

当屏幕事件#

当按下或释放控制器的屏幕时,将调用当屏幕事件块。

当屏幕事件帽子块#
当屏幕 [pressed v]

参数

描述

行动

确定附加的块堆栈何时运行:

  • 按下
  • 释放

例子

当屏幕 [pressed v]
[Play a sound when the screen is pressed.]
播放声音 [成功 v] ▶