Created
May 15, 2025 21:57
-
-
Save gallaugher/a28c1b62c922600c2c6eebc1909ef9f7 to your computer and use it in GitHub Desktop.
Just_st7735r_display.py
This file contains hidden or 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
# st7735r_display_160x128.py | |
import board | |
import displayio | |
import busio | |
import pwmio | |
import terminalio | |
from adafruit_display_text import label | |
import adafruit_st7735r | |
displayio.release_displays() | |
# SPI setup (SPI0) | |
spi = busio.SPI(clock=board.GP2, MOSI=board.GP3) | |
# PWM Backlight | |
backlight = pwmio.PWMOut(board.GP9, frequency=5000, duty_cycle=65535) | |
# Display bus using ST7735R wiring | |
display_bus = displayio.FourWire( | |
spi, | |
command=board.GP6, # DC | |
chip_select=board.GP7, # CS | |
reset=board.GP8 # RST | |
) | |
# THE CRUCIAL LINE (use ST7735R, native portrait, rotate into landscape) | |
display = adafruit_st7735r.ST7735R( | |
display_bus, | |
width=160, | |
height=128, | |
bgr=True, | |
rotation=90, | |
colstart=0, | |
rowstart=0 | |
) | |
# Root group | |
splash = displayio.Group() | |
display.root_group = splash | |
# Background fill | |
bg_bitmap = displayio.Bitmap(160, 128, 1) | |
bg_palette = displayio.Palette(1) | |
bg_palette[0] = 0x0033FF # Blue | |
bg = displayio.TileGrid(bg_bitmap, pixel_shader=bg_palette) | |
splash.append(bg) | |
# Text label | |
text_group = displayio.Group(scale=2, x=20, y=70) | |
text = label.Label(terminalio.FONT, text="Make Awesome!!", color=0xFFFF00) | |
text_group.append(text) | |
splash.append(text_group) | |
while True: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment