Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gallaugher/a28c1b62c922600c2c6eebc1909ef9f7 to your computer and use it in GitHub Desktop.
Save gallaugher/a28c1b62c922600c2c6eebc1909ef9f7 to your computer and use it in GitHub Desktop.
Just_st7735r_display.py
# 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