Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mechawrench/e244d0c0eb8d138e35abb5d804a5c7fe to your computer and use it in GitHub Desktop.
Save mechawrench/e244d0c0eb8d138e35abb5d804a5c7fe to your computer and use it in GitHub Desktop.
show how to use LILYGO T display RP2040 board in CircuitPython w/o explicit board support
# lilygo_t_display_rp2040_demo.py - show how to use LILYGO T display RP2040 board
# 23 Jun 2022 - @todbot / Tod Kurt
# https://github.com/Xinyuan-LilyGO/LILYGO-T-display-RP2040
# https://github.com/adafruit/circuitpython/pull/6037
# Install standard Raspberry Pi Pico UF2 firmware on the board
import time, random
import board
import busio, digitalio
import displayio
import vectorio, rainbowio
import adafruit_st7789
displayio.release_displays()
tft_pwr = board.GP22
tft_clk = board.GP2
tft_mosi = board.GP3
tft_cs = board.GP5
tft_dc = board.GP1
tft_rst = board.GP0
tft_bl = board.GP4
# must turn on power pin to display
pwr_pin = digitalio.DigitalInOut(tft_pwr)
pwr_pin.switch_to_output(value=True)
tft_spi = busio.SPI(clock=tft_clk, MOSI=tft_mosi)
display_bus = displayio.FourWire(tft_spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst)
display = adafruit_st7789.ST7789(display_bus,
width=135, height=240,
rowstart=40, colstart=53,
backlight_pin=tft_bl)
display.rotation=90
maingroup = displayio.Group()
display.show(maingroup)
# demo with a bunch of vectorio circles
for i in range(20):
palette = displayio.Palette(1)
palette[0] = rainbowio.colorwheel(random.randint(0,255))
x,y = random.randint(0,display.width), random.randint(0,display.height)
ball = vectorio.Circle(pixel_shader=palette, radius=20, x=x, y=y)
maingroup.append(ball)
while True:
for ball in maingroup:
ball.x = (ball.x + 1) % display.width
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment