Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import board
import terminalio
from adafruit_display_text import label
text = "Hello world"
text_area = label.Label(terminalio.FONT, text=text)
text_area.x = 10
text_area.y = 10
board.DISPLAY.show(text_area)
while True:
pass
|
Bitmap_label Simple test¶
Simple test using bitmap_label to display text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import board
import terminalio
from adafruit_display_text import bitmap_label
text = "Hello world"
text_area = bitmap_label.Label(terminalio.FONT, text=text)
text_area.x = 10
text_area.y = 10
board.DISPLAY.show(text_area)
while True:
pass
|
Label vs Bitmap_label Comparison¶
Example to compare Label and Bitmap_Label characteristics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# Sample for comparing label and bitmap_label positioning with Builtin or loaded BDF fonts
# pylint: disable=no-member
import gc
import board
import displayio
import terminalio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import bitmap_label
from adafruit_display_text import label
# pylint: disable=no-member
##########
# Use this Boolean variables to select which font style to use
##########
use_builtinfont = False # Set True to use the terminalio.FONT BuiltinFont,
fontToUse = terminalio.FONT
# Set False to use a BDF loaded font, see "fontFiles" below
##########
if not use_builtinfont:
# load the fonts
print("loading font...")
fontList = []
# Load some proportional fonts
fontFile = "fonts/LeagueSpartan-Bold-16.bdf"
fontToUse = bitmap_font.load_font(fontFile)
# Set scaling factor for display text
my_scale = 1
# Setup the SPI display
if "DISPLAY" in dir(board):
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY
else:
# Setup the LCD display with driver
# You may need to change this to match the display driver for the chipset
# used on your display
from adafruit_ili9341 import ILI9341
displayio.release_displays()
# setup the SPI bus
spi = board.SPI()
tft_cs = board.D9 # arbitrary, pin not used
tft_dc = board.D10
tft_backlight = board.D12
tft_reset = board.D11
while not spi.try_lock():
spi.configure(baudrate=32000000)
spi.unlock()
display_bus = displayio.FourWire(
spi,
command=tft_dc,
chip_select=tft_cs,
reset=tft_reset,
baudrate=32000000,
polarity=1,
phase=1,
)
# Number of pixels in the display
DISPLAY_WIDTH = 320
DISPLAY_HEIGHT = 240
# create the display
display = ILI9341(
display_bus,
width=DISPLAY_WIDTH,
height=DISPLAY_HEIGHT,
rotation=180, # The rotation can be adjusted to match your configuration.
auto_refresh=True,
native_frames_per_second=90,
)
# reset the display to show nothing.
display.show(None)
print("Display is started")
preload_glyphs = (
True # set this to True if you want to preload the font glyphs into memory
)
# preloading the glyphs will help speed up the rendering of text but will use more RAM
if preload_glyphs and not use_builtinfont:
# identify the glyphs to load into memory -> increases rendering speed
glyphs = (
b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-_,.:?!'\n "
)
print("loading glyphs...")
fontToUse.load_glyphs(glyphs)
print("Glyphs are loaded.")
print("Fonts completed loading.")
# create group
long_string = "The purple snake\nbrings python fun\nto everyone."
label2_padding = 10
#####
# Create the "bitmap_label.py" versions of the text labels.
gc.collect()
bitmap_label_start = gc.mem_free()
bmap_label1 = bitmap_label.Label(
font=fontToUse,
text="bitmap_label",
color=0xFFFFFF,
background_color=0xFF0000,
padding_bottom=0,
padding_left=0,
padding_right=0,
padding_top=0,
background_tight=True,
line_spacing=1.25,
scale=my_scale,
anchor_point=(0.0, 0),
anchored_position=(10, 60),
)
bmap_label2 = bitmap_label.Label(
font=fontToUse,
text=long_string,
color=0x000000,
background_color=0xFFFF00,
padding_bottom=label2_padding,
padding_left=0,
padding_right=0,
padding_top=label2_padding,
background_tight=False,
line_spacing=1.25,
scale=my_scale,
anchor_point=(0.0, 0),
anchored_position=(10, 120),
)
gc.collect()
bitmap_label_end = gc.mem_free()
print("bitmap_label used: {} memory".format(bitmap_label_start - bitmap_label_end))
bmap_group = displayio.Group() # Create a group for displaying
bmap_group.append(bmap_label1)
bmap_group.append(bmap_label2)
#####
# Create the "label.py" versions of the text labels.
gc.collect()
label_start = gc.mem_free()
label1 = label.Label(
font=fontToUse,
text="label",
color=0xFFFFFF,
background_color=0xFF0000,
padding_bottom=0,
padding_left=0,
padding_right=0,
padding_top=0,
background_tight=True,
line_spacing=1.25,
scale=my_scale,
anchor_point=(1.0, 0),
anchored_position=(display.width - 10, 60),
)
label2 = label.Label(
font=fontToUse,
text=long_string,
color=0x000000,
background_color=0xFFFF00,
padding_bottom=label2_padding,
padding_left=0,
padding_right=0,
padding_top=label2_padding,
background_tight=False,
line_spacing=1.25,
scale=my_scale,
anchor_point=(1.0, 0),
anchored_position=(display.width - 10, 120),
)
gc.collect()
label_end = gc.mem_free()
print("label used: {} memory".format(label_start - label_end))
label_group = displayio.Group() # Create a group for displaying
label_group.append(label1)
label_group.append(label2)
print("***")
main_group = displayio.Group()
main_group.append(label_group)
main_group.append(bmap_group)
display.auto_refresh = True
display.show(main_group)
while True:
pass
|
Background color example¶
Show the text backgrounds features
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example shows the use color and background_color
"""
import time
import board
import terminalio
from adafruit_display_text import label
text = " Color Background Hello world"
text_area = label.Label(
terminalio.FONT, text=text, color=0x0000FF, background_color=0xFFAA00
)
text_area.x = 10
text_area.y = 10
print("background color is {:06x}".format(text_area.background_color))
board.DISPLAY.show(text_area)
time.sleep(2)
text_area.background_color = 0xFF0000
print("background color is {:06x}".format(text_area.background_color))
time.sleep(2)
text_area.background_color = None
print("background color is {}".format(text_area.background_color))
while True:
pass
|
Text padding example¶
Show the text padding features in all directions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example shows the use color and background_color
"""
import time
import board
import displayio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import label
# Setup the SPI display
if "DISPLAY" in dir(board):
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY
else:
print("Starting external display") # goes to serial only
# Setup the LCD display with driver
# You may need to change this to match the display driver for the chipset
# used on your display
from adafruit_ili9341 import ILI9341
# from adafruit_st7789 import ST7789
displayio.release_displays()
# setup the SPI bus
spi = board.SPI()
tft_cs = board.D9 # arbitrary, pin not used
tft_dc = board.D10
tft_backlight = board.D12
tft_reset = board.D11
while not spi.try_lock():
spi.configure(baudrate=32000000)
spi.unlock()
display_bus = displayio.FourWire(
spi,
command=tft_dc,
chip_select=tft_cs,
reset=tft_reset,
baudrate=32000000,
polarity=1,
phase=1,
)
# Number of pixels in the display
DISPLAY_WIDTH = 320
DISPLAY_HEIGHT = 240
# display = ST7789(display_bus, width=240, height=240, rotation=0, rowstart=80, colstart=0)
# create the display
display = ILI9341(
display_bus,
width=DISPLAY_WIDTH,
height=DISPLAY_HEIGHT,
rotation=180, # The rotation can be adjusted to match your configuration.
auto_refresh=True,
native_frames_per_second=90,
)
display.show(None)
# font=terminalio.FONT # this is the Builtin fixed dimension font
font = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")
text = []
text.append("none") # no ascenders or descenders
text.append("pop quops") # only descenders
text.append("MONSTERs are tall") # only ascenders
text.append("MONSTERs ate pop quops") # both ascenders and descenders
text.append("MONSTER quops\nnewline quops") # with newline
display.auto_refresh = True
myGroup = displayio.Group()
display.show(myGroup)
text_area = []
myPadding = 4
for i, thisText in enumerate(text):
text_area.append(
label.Label(
font,
text=thisText,
color=0xFFFFFF,
background_color=None,
background_tight=False,
padding_top=myPadding,
padding_bottom=myPadding,
padding_left=myPadding,
padding_right=myPadding,
)
)
this_x = 10
this_y = 10 + i * 40
text_area[i].x = 10
text_area[i].y = 3 + i * 50
text_area[i].anchor_point = (0, 0)
text_area[i].anchored_position = (this_x, this_y)
myGroup.append(text_area[i])
print("background color is {}".format(text_area[0].background_color))
while True:
time.sleep(2)
text_area[0].text = "text" # change some text in an existing text box
# Note: changed text must fit within existing number of characters
# when the Label was created
for area in text_area:
area.background_color = 0xFF0000
print("background color is {:06x}".format(text_area[0].background_color))
time.sleep(2)
for area in text_area:
area.background_color = 0x000088
print("background color is {:06x}".format(text_area[0].background_color))
time.sleep(2)
for area in text_area:
area.background_color = 0x00FF00
print("background color is {:06x}".format(text_area[0].background_color))
time.sleep(2)
for area in text_area:
area.background_color = 0xFF0000
print("background color is {:06x}".format(text_area[0].background_color))
time.sleep(2)
for area in text_area:
area.background_color = None
print("background color is {}".format(text_area[0].background_color))
|
Anchored Position¶
Anchored position use illustration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This examples shows the use of anchor_point and anchored_position.
"""
import board
import terminalio
import displayio
from adafruit_display_text import label
DISPLAY_WIDTH = 320
DISPLAY_HEIGHT = 240
TEXT = "Hello"
text_area_top_left = label.Label(terminalio.FONT, text=TEXT)
text_area_top_left.anchor_point = (0.0, 0.0)
text_area_top_left.anchored_position = (0, 0)
text_area_top_middle = label.Label(terminalio.FONT, text=TEXT)
text_area_top_middle.anchor_point = (0.5, 0.0)
text_area_top_middle.anchored_position = (DISPLAY_WIDTH / 2, 0)
text_area_top_right = label.Label(terminalio.FONT, text=TEXT)
text_area_top_right.anchor_point = (1.0, 0.0)
text_area_top_right.anchored_position = (DISPLAY_WIDTH, 0)
text_area_middle_left = label.Label(terminalio.FONT, text=TEXT)
text_area_middle_left.anchor_point = (0.0, 0.5)
text_area_middle_left.anchored_position = (0, DISPLAY_HEIGHT / 2)
text_area_middle_middle = label.Label(terminalio.FONT, text=TEXT)
text_area_middle_middle.anchor_point = (0.5, 0.5)
text_area_middle_middle.anchored_position = (DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2)
text_area_middle_right = label.Label(terminalio.FONT, text=TEXT)
text_area_middle_right.anchor_point = (1.0, 0.5)
text_area_middle_right.anchored_position = (DISPLAY_WIDTH, DISPLAY_HEIGHT / 2)
text_area_bottom_left = label.Label(terminalio.FONT, text=TEXT)
text_area_bottom_left.anchor_point = (0.0, 1.0)
text_area_bottom_left.anchored_position = (0, DISPLAY_HEIGHT)
text_area_bottom_middle = label.Label(terminalio.FONT, text=TEXT)
text_area_bottom_middle.anchor_point = (0.5, 1.0)
text_area_bottom_middle.anchored_position = (DISPLAY_WIDTH / 2, DISPLAY_HEIGHT)
text_area_bottom_right = label.Label(terminalio.FONT, text=TEXT)
text_area_bottom_right.anchor_point = (1.0, 1.0)
text_area_bottom_right.anchored_position = (DISPLAY_WIDTH, DISPLAY_HEIGHT)
text_group = displayio.Group()
text_group.append(text_area_top_middle)
text_group.append(text_area_top_left)
text_group.append(text_area_top_right)
text_group.append(text_area_middle_middle)
text_group.append(text_area_middle_left)
text_group.append(text_area_middle_right)
text_group.append(text_area_bottom_middle)
text_group.append(text_area_bottom_left)
text_group.append(text_area_bottom_right)
board.DISPLAY.show(text_group)
while True:
pass
|
Textarea Boundingbox¶
Boundingbox demonstration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import os
import board
import displayio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text.label import Label
# the current working directory (where this file is)
cwd = ("/" + __file__).rsplit("/", 1)[0]
fonts = [
file
for file in os.listdir(cwd + "/fonts/")
if (file.endswith(".bdf") and not file.startswith("._"))
]
for i, filename in enumerate(fonts):
fonts[i] = cwd + "/fonts/" + filename
print(fonts)
##########################################################################
THE_FONT = fonts[0]
DISPLAY_STRING = "A multi-line-\nexample of\n font bounding!"
WRAP_CHARS = 40
##########################################################################
# Make the display context
splash = displayio.Group()
board.DISPLAY.show(splash)
# Make a background color fill
color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)
# Load the font
font = bitmap_font.load_font(THE_FONT)
font.load_glyphs(DISPLAY_STRING.encode("utf-8"))
print(DISPLAY_STRING)
text = Label(font, text=DISPLAY_STRING)
text.x = 20
text.y = 100
text.color = 0x0
# Make a background color fill
dims = text.bounding_box
print(dims)
textbg_bitmap = displayio.Bitmap(dims[2], dims[3], 1)
textbg_palette = displayio.Palette(1)
textbg_palette[0] = 0xFF0000
textbg_sprite = displayio.TileGrid(
textbg_bitmap, pixel_shader=textbg_palette, x=text.x + dims[0], y=text.y + dims[1]
)
splash.append(textbg_sprite)
splash.append(text)
try:
board.DISPLAY.refresh(target_frames_per_second=60)
except AttributeError:
board.DISPLAY.refresh_soon()
board.DISPLAY.wait_for_frame()
while True:
pass
|
Align Baseline example¶
Demonstrate how to align different labels to a common horizontal line
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # SPDX-FileCopyrightText: 2021 Jose David Montoya for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example shows the use of base_alignment parameter.
"""
import board
import displayio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import label
display = board.DISPLAY
# Font definition. You can choose any two fonts available in your system
MEDIUM_FONT = bitmap_font.load_font("LeagueSpartan-Bold-16.bdf")
BIG_FONT = bitmap_font.load_font("LibreBodoniv2002-Bold-27.bdf")
TEXT_RIGHT = "MG"
TEXT_LEFT = "32.47"
main_group = displayio.Group()
# Create labels
# Base Alignment parameter False
left_text = label.Label(
BIG_FONT,
text=TEXT_LEFT,
color=0x000000,
background_color=0x999999,
x=10,
y=50,
base_alignment=False,
)
main_group.append(left_text)
right_text = label.Label(
MEDIUM_FONT,
text=TEXT_RIGHT,
color=0x000000,
background_color=0x999999,
x=90,
y=50,
base_alignment=False,
)
main_group.append(right_text)
# Base Alignment parameter True
left_text_aligned = label.Label(
BIG_FONT,
text=TEXT_LEFT,
color=0x000000,
background_color=0x999999,
x=10,
y=100,
base_alignment=True,
)
main_group.append(left_text_aligned)
right_text_aligned = label.Label(
MEDIUM_FONT,
text=TEXT_RIGHT,
color=0x000000,
background_color=0x999999,
x=90,
y=100,
base_alignment=True,
)
main_group.append(right_text_aligned)
display.show(main_group)
while True:
pass
|
Magtag example¶
Uses the MAGTAG to display some text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
Basic display_text.label example script
adapted for use on MagTag.
"""
import time
import board
import displayio
import terminalio
from adafruit_display_text import label
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY
# wait until we can draw
time.sleep(display.time_to_refresh)
# main group to hold everything
main_group = displayio.Group()
# white background. Scaled to save RAM
bg_bitmap = displayio.Bitmap(display.width // 8, display.height // 8, 1)
bg_palette = displayio.Palette(1)
bg_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(bg_bitmap, x=0, y=0, pixel_shader=bg_palette)
bg_group = displayio.Group(scale=8)
bg_group.append(bg_sprite)
main_group.append(bg_group)
# first example label
TEXT = "Hello world"
text_area = label.Label(
terminalio.FONT,
text=TEXT,
color=0xFFFFFF,
background_color=0x666666,
padding_top=1,
padding_bottom=3,
padding_right=4,
padding_left=4,
)
text_area.x = 10
text_area.y = 14
main_group.append(text_area)
# second example label
another_text = label.Label(
terminalio.FONT,
scale=2,
text="MagTag display_text\nexample",
color=0x000000,
background_color=0x999999,
padding_top=1,
padding_bottom=3,
padding_right=4,
padding_left=4,
)
# centered
another_text.anchor_point = (0.5, 0.5)
another_text.anchored_position = (display.width // 2, display.height // 2)
main_group.append(another_text)
# show the main group and refresh.
display.show(main_group)
display.refresh()
while True:
pass
|
MatrixPortal example¶
Uses the MatrixPortal to display some text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example shows how to create a display_text label and show it
with a Matrix Portal
Requires:
adafruit_matrixportal - https://github.com/adafruit/Adafruit_CircuitPython_MatrixPortal
Copy it from the current libraries bundle into the lib folder on your device.
"""
import terminalio
from adafruit_matrixportal.matrix import Matrix
from adafruit_display_text import label
matrix = Matrix()
display = matrix.display
text = "Hello\nworld"
text_area = label.Label(terminalio.FONT, text=text)
text_area.x = 1
text_area.y = 4
display.show(text_area)
while True:
pass
|
PyPortal example¶
Uses the Pyportal to display some text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example show the use of the backlight as well as using labels to simulate
a terminal using a font on the PyPortal
"""
import os
import time
import board
import displayio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text.label import Label
FONT_DIR = "/fonts/"
fonts = list(
filter(lambda x: x.endswith("bdf") and not x.startswith("."), os.listdir(FONT_DIR))
)
fonts = [bitmap_font.load_font(FONT_DIR + x) for x in fonts]
if len(fonts) == 0:
print("No fonts found in '{}'".format(FONT_DIR))
print("fade up")
# Fade up the backlight
for b in range(100):
board.DISPLAY.brightness = b / 100
time.sleep(0.01) # default (0.01)
demos = ["CircuitPython = Code + Community", "accents - üàêùéáçãÍóí", "others - αψ◌"]
splash = displayio.Group()
board.DISPLAY.show(splash)
max_y = 0
y = 0
for demo_text in demos:
for font in fonts:
if y >= board.DISPLAY.height:
y = 0
while len(splash):
splash.pop()
print("Font load {}".format(font.name))
area = Label(
font, text=demo_text, anchor_point=(0, 0), anchored_position=(0, y)
)
splash.append(area)
y += area.height
# Wait for the image to load.
try:
board.DISPLAY.refresh(target_frames_per_second=60)
except AttributeError:
board.DISPLAY.wait_for_frame()
# Wait for 1 minute (60 seconds)
time.sleep(60)
# Fade down the backlight
for b in range(100, -1, -1):
board.DISPLAY.brightness = b / 100
time.sleep(0.01) # default (0.01)
print("fade down")
time.sleep(10)
|
Wraptest example¶
Illustrates the wraptest feature
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example illustrates how to use the wrap_text_to_lines
helper function.
"""
import board
import terminalio
from adafruit_display_text import label, wrap_text_to_lines
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY
text = (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
"sed do eiusmod tempor incididunt ut labore et dolore magna "
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation "
"ullamco laboris nisi ut aliquip ex ea commodo consequat."
)
text = "\n".join(wrap_text_to_lines(text, 28))
text_area = label.Label(terminalio.FONT, text=text)
text_area.x = 10
text_area.y = 10
display.show(text_area)
while True:
pass
|
Wrap Pixel Test¶
Wrap Pixel Test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # SPDX-FileCopyrightText: 2021 Tim C, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Test the wrap_text_to_pixels function. Try changing WRAP_WIDTH or text
and observe the results. The red bar represents the full size of
WRAP_WIDTH.
"""
import board
import displayio
import terminalio
from adafruit_display_text import label, wrap_text_to_pixels
WRAP_WIDTH = 140
text = (
"CircuitPython is a programming language designed to simplify experimenting "
"and learning to code on low-cost microcontroller boards. "
)
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY
# Make the display context
main_group = displayio.Group()
display.show(main_group)
font = terminalio.FONT
print(text)
print(display.width)
text_area = label.Label(
font,
text="\n".join(wrap_text_to_pixels(text, WRAP_WIDTH, font)),
background_color=0x0000DD,
)
text_area.anchor_point = (0, 0)
text_area.anchored_position = (0, 0)
main_group.append(text_area)
# Create a bitmap with two colors
size_checker = displayio.Bitmap(WRAP_WIDTH, 10, 2)
# Create a two color palette
palette = displayio.Palette(2)
palette[0] = 0x0000DD
palette[1] = 0xDD0000
# Create a TileGrid using the Bitmap and Palette
tile_grid = displayio.TileGrid(size_checker, pixel_shader=palette)
tile_grid.y = text_area.bounding_box[1] + text_area.bounding_box[3] + 10
size_checker.fill(1)
main_group.append(tile_grid)
while True:
pass
|
Library Features Example¶
This examples shows the label
and bitmap_label
capabilities and features
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | # SPDX-FileCopyrightText: 2021 Jose David M.
#
# SPDX-License-Identifier: MIT
#############################
"""
This is an advanced demonstration of the display_text library capabilities
"""
import time
import board
import displayio
import terminalio
import fontio
from adafruit_display_text import label, bitmap_label
from adafruit_bitmap_font import bitmap_font
display = board.DISPLAY
main_group = displayio.Group()
MEDIUM_FONT = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")
BIG_FONT = bitmap_font.load_font("fonts/LibreBodoniv2002-Bold-27.bdf")
TIME_PAUSE = 2
bitmap = displayio.Bitmap(4, display.width, 2)
palette = displayio.Palette(2)
palette[0] = 0x004400
palette[1] = 0x00FFFF
horizontal_line = displayio.TileGrid(bitmap, pixel_shader=palette, x=155, y=0)
main_group.append(horizontal_line)
bitmap = displayio.Bitmap(display.width, 4, 2)
vertical_line = displayio.TileGrid(bitmap, pixel_shader=palette, x=0, y=110)
main_group.append(vertical_line)
# Tests
text_area = label.Label(terminalio.FONT, text="Circuit Python")
main_group.append(text_area)
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing position setter
text_area.x = 10
text_area.y = 10
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing creating label with initial position
text_area.text = "Testing initiating without text"
try:
text_middle = label.Label(terminalio.FONT)
except SyntaxError:
print("Fail setting-up label without text")
warning_text = label.Label(
BIG_FONT,
text="Test Fail",
x=display.width // 2,
y=display.height // 4,
background_color=0x004499,
)
main_group.append(warning_text)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_area.text = "Testing Position"
text_middle = label.Label(
terminalio.FONT, text="Circuit", x=display.width // 2, y=display.height // 2
)
main_group.append(text_middle)
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing Text Setter
text_area.text = "Testing Changing Text"
text_middle.text = "Python"
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing a and y getter and setter
text_area.text = "Testing Changing Position"
text_middle.x = text_middle.x - 50
text_middle.y = text_middle.y - 50
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing font Getter and setter
text_area.text = "Testing Changing FONT"
if isinstance(text_middle.font, fontio.BuiltinFont):
text_middle.font = MEDIUM_FONT
display.show(main_group)
time.sleep(TIME_PAUSE)
# Once this working we create another label with all the initial specs
main_group.pop()
# Testing Color
text_area.text = "Testing Color"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="Circuit Python",
x=display.width // 2,
y=display.height // 2,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_initial_specs.color = 0x004400
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Background Color
text_area.text = "Testing Background Color"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_initial_specs.background_color = 0x990099
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Background Color
text_area.text = "Testing Background Tight"
text_initial_specs = label.Label(
BIG_FONT,
text="aaaaq~",
x=0,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
background_tight=True,
)
main_group.append(text_initial_specs)
text_initial_specs = label.Label(
BIG_FONT,
text="aaaaq~",
x=90,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
background_tight=False,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
main_group.pop()
# Testing Padding
text_area.text = "Testing Padding"
text_initial_specs = label.Label(
BIG_FONT,
text="CircuitPython",
x=display.width // 4,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Anchor Point/ Anchored Position
text_area.text = "Testing Anchor Point/Anchored Position"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
try:
text_initial_specs.anchored_position = (100, 100)
text_initial_specs.anchor_point = (0.5, 0.5)
except TypeError:
print("Test is failing here")
main_group.pop()
warning_text = label.Label(
BIG_FONT,
text="Test Fail",
x=display.width // 2,
y=display.height // 4,
background_color=0x004499,
)
main_group.append(warning_text)
time.sleep(TIME_PAUSE)
display.show(main_group)
main_group.pop()
# Testing Scale
text_area.text = "Testing Scale"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_initial_specs.scale = 2
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Base Alignment
text_area.text = "Testing Base Alignment"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="python",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
base_alignment=True,
)
main_group.append(text_initial_specs)
text_initial_specs = label.Label(
BIG_FONT,
text="circuit",
x=display.width // 2 - 100,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
base_alignment=True,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
main_group.pop()
# Testing Direction
text_area.text = "Testing Direction-UPR"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="UPR",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Testing Direction-DWR"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="DWR",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Testing Direction-TTB"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="TTB",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Testing Direction-RTL"
text_initial_specs = label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="RTL",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
main_group.pop()
# Testing creating label with initial position
display.show(main_group)
time.sleep(TIME_PAUSE)
text_area = bitmap_label.Label(terminalio.FONT, text="Circuit Python")
main_group.append(text_area)
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing position setter
text_area.x = 10
text_area.y = 10
display.show(main_group)
time.sleep(TIME_PAUSE)
text_area.text = "Testing initiating without text"
try:
text_middle = label.Label(terminalio.FONT)
except TypeError:
print("Fail setting-up label without text")
warning_text = label.Label(
BIG_FONT,
text="Test Fail",
x=display.width // 2,
y=display.height // 4,
background_color=0x004499,
)
main_group.append(warning_text)
# Testing creating label with initial position
text_area.text = "Testing Position"
text_middle = bitmap_label.Label(
terminalio.FONT, text="Circuit", x=display.width // 2, y=display.height // 2
)
main_group.append(text_middle)
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing Text Setter
text_area.text = "Testing Changing Text"
text_middle.text = "Python"
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing a and y getter and setter
text_area.text = "Testing Changing Position"
text_middle.x = text_middle.x - 50
text_middle.y = text_middle.y - 50
display.show(main_group)
time.sleep(TIME_PAUSE)
# Testing font Getter and setter
text_area.text = "Testing Changing FONT"
if isinstance(text_middle.font, fontio.BuiltinFont):
print("Font was BuiltinFont")
text_middle.font = MEDIUM_FONT
display.show(main_group)
time.sleep(TIME_PAUSE)
# Once this working we create another label with all the initial specs
main_group.pop()
# Testing Color
text_area.text = "Testing Color"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="Circuit Python",
x=display.width // 2,
y=display.height // 2,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_initial_specs.color = 0x004400
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Background Color
text_area.text = "Testing Background Color"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_initial_specs.background_color = 0x990099
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Background Color
text_area.text = "Testing Background Tight"
text_initial_specs = bitmap_label.Label(
BIG_FONT,
text="aaaaq~",
x=0,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
background_tight=True,
)
main_group.append(text_initial_specs)
text_initial_specs = bitmap_label.Label(
BIG_FONT,
text="aaaaq~",
x=90,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
background_tight=False,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
main_group.pop()
# Testing Padding
text_area.text = "Testing Padding"
text_initial_specs = bitmap_label.Label(
BIG_FONT,
text="CircuitPython",
x=display.width // 4,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Anchor Point/ Anchored Position
text_area.text = "Testing Anchor Point/Anchored Position"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
try:
text_initial_specs.anchored_position = (100, 100)
text_initial_specs.anchor_point = (0.5, 0.5)
except TypeError:
print("Test is failing here")
main_group.pop()
warning_text = bitmap_label.Label(
BIG_FONT,
text="Test Fail",
x=display.width // 2,
y=display.height // 4,
background_color=0x004499,
)
main_group.append(warning_text)
time.sleep(TIME_PAUSE)
display.show(main_group)
main_group.pop()
# Testing Scale
text_area.text = "Testing Scale"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
text_initial_specs.scale = 2
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
# Testing Base Alignment
text_area.text = "Testing Base Alignment"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="python",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
base_alignment=True,
)
main_group.append(text_initial_specs)
text_initial_specs = bitmap_label.Label(
BIG_FONT,
text="circuit",
x=display.width // 2 - 100,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
base_alignment=True,
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
main_group.pop()
# Testing Direction
text_area.text = "Testing Direction-UPR"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="UPR",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Testing Direction-DWR"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="DWR",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Testing Direction-UPD"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="UPD",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Testing Direction-RTL"
text_initial_specs = bitmap_label.Label(
MEDIUM_FONT,
text="CircuitPython",
x=display.width // 2,
y=display.height // 2,
color=0xFFFFFF,
background_color=0x990099,
padding_right=10,
padding_top=10,
padding_bottom=10,
padding_left=10,
anchored_position=(display.width // 2, display.height // 2),
anchor_point=(0.5, 0.5),
label_direction="RTL",
)
main_group.append(text_initial_specs)
display.show(main_group)
time.sleep(TIME_PAUSE)
main_group.pop()
text_area.text = "Finished"
print("Tests finished")
|