Using text on the LED Matrix is very similar to using Sprites. In fact, text is just a Sprite made up of strings of text. Anything we can do with a Sprite, we can also do with Text — it can be rotated, cropped, flipped and drawn on the Framebuffer.
To create Text, we can use the the Text()
function:
Text(text)
where text
is a string we want displayed. Text also
has some optional parameters — for example, we can call Text()
with:
Text(text, char_spacing=1, font_name='5x7')
Both optional parameters have the defaults as shown — but we can change them. The char_spacing is the number of blank points between characters in the text — the higher the number, the further apart the text is spaced. The font_name is the font that is used for the text. There are two choices for font: '5x7' and '3x5', and they are named according to the max width and height of the characters they use.
For example, the letter 'A' could be created and displayed with the
draw()
function, as follows:
Here's a set of examples of things we can do with Text on the LED Matrix. All the examples use the letter 'P', but, of course, you could use any text you'd like:
Here are some of the things we could do to the Text by modifying the
fb.draw()
function above (and potentially adding lines before
it). Along with each example is a demonstration of what the text would look
like for each operation:
Functions |
LED Matrix |
---|---|
|
00000000 FFFF0000 F000F000 F000F000 FFFF0000 F0000000 F0000000 F0000000 |
|
00F000F0 00FFFF00 00F00000 00F00000 00F00000 00000000 00000000 00000000 |
|
00000000 00000000 00000000 00000000 FFFF0000 F000F000 F000F000 FFFF0000 |
|
000FFFF0 000F000F 000F000F 000FFFF0 00000000 00000000 00000000 00000000 |
|
00000000 00000000 00000000 0FF00000 F00F0000 F00F0000 F00F0000 FFFFFFF0 |
|
00000000 0000F000 0000F000 0000F000 0FFFF000 F000F000 F000F000 0FFFF000 |
|
00000000 00000000 00000000 FFFFFFF0 000F00F0 000F00F0 000F00F0 0000FF00 |
|
00000000 0FFFF000 F000F000 F000F000 0FFFF000 0000F000 0000F000 0000F000 |
|
00000000 F0000000 F0000000 F0000000 FFFF0000 F000F000 F000F000 FFFF0000 |
|
00000000 00000000 00000000 0FF00000 F00F0000 F00F0000 F00F0000 FFFF0000 |
|
00000000 FFFF0000 F000F000 F000F000 FFFF0000 F0000000 F0000000 F0000000 |