2.6. LED Display - Images#
2.6.1. Showing Static Images#
You can show images on the display such as:
strings
numbers
arbitrary patterns
The function show will put various objects on the display
microbit.display.show(image, delay=400, wait=True, loop=False, clear=False)
where:
imageis:a
str,floatorintin which case each character (or digit), is called an image, will be shown in sequence on the displayan
Imageor list ofImagewhich specifies the intensity of each pixel individually
delayis the milliseconds between each imagewaitdetermines whether the function will block execution of code until the animation is finishedloopcan be enabled to infinitely loop the animationclearcan be set to clear the display after it has finished
2.6.2. Images#
The Image class is designed to hold a single image shown on the display and
allows you to defined your own custom images.
To construct an image you must pass a string containing each pixels brightness,
with : (colon) to separate each line.
Example#
from microbit import *
image = Image("90009:09090:00900:09090:90009:")
microbit.display.show(image)
which would be displayed an “X” on the 5x5 grid as:
90009
09090
00900
09090
90009
Built-in Images#
There are a number of built-in images provided for you such as:
Image.HEARTImage.SMILEImage.YES
All built-in images are listed here https://microbit-micropython.readthedocs.io/en/v2-docs/microbit_micropython_api.html#images
2.6.3. Scrolling Text#
Instead of showing a single image at a time, you can scroll them across the display using scroll
microbit.display.scroll(text, delay=150, wait=True, loop=False, monospace=False)
where
delaycontrols how fast the text is scrolling