This module controls the 5×5 LED display on the front of your board. It can be used to display images, animations and even text.
该模块控制板子正面的 5×5 LED 显示屏。它可用于显示图像、动画甚至文本。
Return the brightness of the LED at column x and row y as an integer between 0 (off) and 9 (bright).
将 x 列和第 y 行的 LED 亮度返回为介于 0(关闭)和 9(明亮)之间的整数。
Set the brightness of the LED at column x and row y to value, which has to be an integer between 0 and 9.
将 x 列和第 y 行的 LED 亮度设置为值 ,该值必须是介于 0 和 9 之间的整数。
Set the brightness of all LEDs to 0 (off).
将所有 LED 的亮度设置为 0(关闭)。
Display the image.
显示图像 。
If image is a string, float or integer, display letters/digits in sequence. Otherwise, if image is an iterable sequence of images, display these images in sequence. Each letter, digit or image is shown with delay milliseconds between them.
如果 image 是字符串、浮点数或整数,则按顺序显示字母/数字。否则,如果 image 是图像的可迭代序列,则按顺序显示这些图像。每个字母、数字或图像之间都以延迟毫秒为单位显示。
If wait is True, this function will block until the animation is finished, otherwise the animation will happen in the background.
如果 wait 为 True,则此函数将阻塞,直到动画完成,否则动画将在后台发生。
If loop is True, the animation will repeat forever.
如果 loop 为 True,则动画将永远重复。
If clear is True, the display will be cleared after the iterable has finished.
如果 clear 为 True,则在 iterable 完成后将清除显示。
Note that the wait, loop and clear arguments must be specified using their keyword.
请注意, 必须使用其关键字指定 wait、loop 和 clear 参数。
Note 注意
If using a generator as the iterable, then take care not to allocate any memory in the generator as allocating memory in an interrupt is prohibited and will raise a MemoryError.
如果使用生成器作为可迭代对象 ,则注意不要分配任何内存 ,因为在中断中分配内存是被禁止的,并且会引发一个 MemoryError 的 MemoryError 错误。
Scrolls text horizontally on the display. If text is an integer or float it is first converted to a string using str(). The delay parameter controls how fast the text is scrolling.
在显示屏上水平滚动文本 。如果 text 是整数或浮点数,则首先使用 str() 将其转换为字符串。delay 参数控制文本滚动的速度。
If wait is True, this function will block until the animation is finished, otherwise the animation will happen in the background.
如果 wait 为 True,则此函数将阻塞,直到动画完成,否则动画将在后台发生。
If loop is True, the animation will repeat forever.
如果 loop 为 True,则动画将永远重复。
If monospace is True, the characters will all take up 5 pixel-columns in width, otherwise there will be exactly 1 blank pixel-column between each character as they scroll.
如果等宽为 True,则字符的宽度将全部占用 5 个像素列,否则在滚动时,每个字符之间将恰好有 1 个空白像素列。
Note that the wait, loop and monospace arguments must be specified using their keyword.
请注意,必须使用其关键字指定 wait、loop 和 monospace 参数。
Use on() to turn on the display.
使用 on() 打开显示。
Use off() to turn off the display (thus allowing you to re-use the GPIO pins associated with the display for other purposes).
使用 off() 关闭显示(从而允许您将与显示关联的 GPIO 引脚重新用于其他目的)。
Returns True if the display is on, otherwise returns False.
如果显示处于打开状态,则返回 True,否则返回 False。
Use the display’s LEDs in reverse-bias mode to sense the amount of light falling on the display. Returns an integer between 0 and 255 representing the light level, with larger meaning more light.
在反向偏置模式下使用显示器的 LED 来感应落在显示器上的光量。返回一个介于 0 和 255 之间的整数,表示光照级别,越大表示光线越多。
To continuously scroll a string across the display, and do it in the background, you can use:
要在显示屏上连续滚动字符串,并在后台执行此作,您可以使用:
import microbit
microbit.display.scroll('Hello!', wait=False, loop=True)