Screen
The screen is a powerful output device, it is capable of rendering text, colours and complex graphics.
The screen size is:
160x128
The screen is organised with the top left hand side being the origin point of (0,0).
The width is 160 pixels, the height at 128 pixels.

The following code will write a word on the screen.
import board
import terminalio
from adafruit_display_text import label
display = board.DISPLAY
# Set text, font, and color
text = "HELLO WORLD"
font = terminalio.FONT
color = 0x0000FF
# Create the text label
text_area = label.Label(font, text=text, color=color)
# Set the location
text_area.x = 50
text_area.y = 80
# Show it
display.show(text_area)
# Loop forever so you can enjoy your image
while True:
pass
The following code will set the whole screen green.
import board
import time
import displayio
display = board.DISPLAY
splash = displayio.Group()
display.show(splash)
color_bitmap = displayio.Bitmap(160, 128, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)
# Loop forever so you can enjoy your image
while True:
pass
The code that sets the color_palette uses the value 0x00FF00 - where each two values represent the red, green and blue colours.
There are a large number of examples that can be used with your display, have a look at the following article (ignore the ePaper references).
Bouncing Text
import board
import time
import terminalio
from adafruit_display_text import label
import random
display = board.DISPLAY
# Set text, font, and color
text = "StudioBot"
font = terminalio.FONT
color = 0x0000FF # Blue
# Create the text label
text_area = label.Label(font, text=text, color=color)
x = 50
y = 80
x_direction = 1
y_direction = 1
# Set the location
text_area.x = x
text_area.y = y
# Show it
display.show(text_area)
# Loop forever so you can enjoy your image
while True:
x = x + 1 * x_direction
y = y + 1 * y_direction
if x >= 150:
x_direction = -1
text_area.color = random.randint(0, 0xFFFFFF)
elif x <= 0:
x_direction = 1
text_area.color = random.randint(0, 0xFFFFFF)
if y >= 120:
y_direction = -1
text_area.color = random.randint(0, 0xFFFFFF)
elif y <= 0:
y_direction = 1
text_area.color = random.randint(0, 0xFFFFFF)
text_area.x = x
text_area.y = y
time.sleep(0.01)
Last updated