Last active
November 10, 2023 16:31
-
-
Save todbot/a23c8cb28e5925dfa79e6dba5c9d0962 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
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
# 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