Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes to the ST7789 1.47 Example that were required to work with raspberry pi pico w #34

Merged
merged 5 commits into from
Jan 21, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions examples/st7789_172x320_1.47_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,36 @@

"""
This test will initialize the display using displayio and draw a solid green
background, a smaller purple rectangle, and some yellow text.
background, a smaller purple rectangle, and some yellow text..
"""
import board
import busio
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

BORDER_WIDTH = 20
BORDER_WIDTH = 28
TEXT_SCALE = 3

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
# built-in, silkscreen labelled SPI bus
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
FoamyGuy marked this conversation as resolved.
Show resolved Hide resolved
tft_cs = board.D5
tft_dc = board.D6
tft_rst = board.D9

# If using a Raspberry Pi Pico or Pico-w
# Uncomment the below code to use GP (General Purpose) pins
# instead of D (Digital)

# spi = busio.SPI(board.GP2, board.GP3, board.GP4)
# tft_cs = board.GP5
# tft_dc = board.GP6
# tft_rst = board.GP7

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst)

display = ST7789(display_bus, width=320, height=172, colstart=34, rotation=270)
Expand All @@ -40,6 +51,7 @@
inner_bitmap = displayio.Bitmap(
display.width - (BORDER_WIDTH * 2), display.height - (BORDER_WIDTH * 2), 1
)

inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(
Expand All @@ -50,7 +62,7 @@
# Draw a label
text_area = label.Label(
terminalio.FONT,
text="Hello World!",
text="Hello World!!",
color=0xFFFF00,
scale=TEXT_SCALE,
anchor_point=(0.5, 0.5),
Expand Down