-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1c2897
commit 108f763
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import board | ||
import time | ||
import displayio | ||
import terminalio | ||
from adafruit_display_text.bitmap_label import Label | ||
import adafruit_imageload | ||
from fourwire import FourWire | ||
from vectorio import Circle | ||
from adafruit_gc9a01a import GC9A01A | ||
|
||
spi = board.SPI() | ||
tft_cs = board.D5 | ||
tft_dc = board.D6 | ||
tft_reset = board.D9 | ||
|
||
displayio.release_displays() | ||
|
||
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset) | ||
display = GC9A01A(display_bus, width=240, height=240) | ||
|
||
# --- Default Shapes/Text Demo --- | ||
main_group = displayio.Group() | ||
display.root_group = main_group | ||
|
||
bg_bitmap = displayio.Bitmap(240, 240, 2) | ||
color_palette = displayio.Palette(2) | ||
color_palette[0] = 0x00FF00 # Bright Green | ||
color_palette[1] = 0xAA0088 # Purple | ||
|
||
bg_sprite = displayio.TileGrid(bg_bitmap, pixel_shader=color_palette, x=0, y=0) | ||
main_group.append(bg_sprite) | ||
|
||
inner_circle = Circle(pixel_shader=color_palette, x=120, y=120, radius=100, color_index=1) | ||
main_group.append(inner_circle) | ||
|
||
text_group = displayio.Group(scale=2, x=50, y=120) | ||
text = "Hello World!" | ||
text_area = Label(terminalio.FONT, text=text, color=0xFFFF00) | ||
text_group.append(text_area) # Subgroup for text scaling | ||
main_group.append(text_group) | ||
|
||
# --- ImageLoad Demo --- | ||
blinka_group = displayio.Group() | ||
bitmap, palette = adafruit_imageload.load("/blinka_round.bmp", | ||
bitmap=displayio.Bitmap, | ||
palette=displayio.Palette) | ||
|
||
grid = displayio.TileGrid(bitmap, pixel_shader=palette) | ||
blinka_group.append(grid) | ||
|
||
while True: | ||
# show shapes/text | ||
display.root_group = main_group | ||
time.sleep(2) | ||
# show blinka bitmap | ||
display.root_group = blinka_group | ||
time.sleep(2) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries | ||
# SPDX-FileCopyrightText: Adapted from Melissa LeBlanc-Williams's Pi Demo Code | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
'''Raspberry Pi Graphics example for the 240x240 Round TFT''' | ||
|
||
import time | ||
import digitalio | ||
import board | ||
from PIL import Image, ImageDraw, ImageFont | ||
from adafruit_rgb_display import gc9a01a | ||
|
||
BORDER = 20 | ||
FONTSIZE = 24 | ||
|
||
cs_pin = digitalio.DigitalInOut(board.CE0) | ||
dc_pin = digitalio.DigitalInOut(board.D25) | ||
reset_pin = digitalio.DigitalInOut(board.D27) | ||
|
||
BAUDRATE = 24000000 | ||
|
||
spi = board.SPI() | ||
|
||
disp = gc9a01a.GC9A01A(spi, rotation=180, | ||
width=135, height=240, | ||
x_offset=53, y_offset=40, | ||
cs=cs_pin, | ||
dc=dc_pin, | ||
rst=reset_pin, | ||
baudrate=BAUDRATE, | ||
) | ||
|
||
width = disp.width | ||
height = disp.height | ||
|
||
# -------TEXT AND SHAPES--------- | ||
image1 = Image.new("RGB", (width, height)) | ||
draw1 = ImageDraw.Draw(image1) | ||
draw1.rectangle((0, 0, width, height), fill=(0, 255, 0)) # Green background | ||
|
||
draw1.rectangle( | ||
(BORDER, BORDER, width - BORDER - 1, height - BORDER - 1), fill=(170, 0, 136) | ||
) | ||
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE) | ||
text = "Hello\nWorld!" | ||
(font_width, font_height) = font.getsize(text) | ||
draw1.text( | ||
(30, height // 2 - font_height // 2-12), | ||
text, | ||
font=font, | ||
fill=(255, 255, 0), | ||
) | ||
|
||
# ------BLINKA JPEG DISPLAY---------- | ||
image2 = Image.open("blinka_round.jpg") | ||
image_ratio = image2.width / image2.height | ||
screen_ratio = width / height | ||
scaled_width = width | ||
scaled_height = image2.height * width // image2.width | ||
image2 = image2.resize((scaled_width, scaled_height), Image.BICUBIC) | ||
x = scaled_width // 2 - width // 2 | ||
y = scaled_height // 2 - height // 2 | ||
image2 = image2.crop((x, y, x + width, y + height)) | ||
|
||
while True: | ||
disp.image(image1) # show text | ||
time.sleep(2) | ||
disp.image(image2) # show blinka | ||
time.sleep(2) |