I'm running the test code below on a Raspi4 (ubuntu-core) to draw on a Mini PiTFT (https://www.adafruit.com/product/4484).
I'm finding it takes about 1.5 seconds to draw each image. Is that the best performance to be expected driving this device over SPI using python? I need a image refresh around 10fps or better for my application. I'd prefer to keep everything in python if possible, but C/C++ isn't out of the question. It does need to stay on the Raspberry Pi platform.
Code: Select all
# Display
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = None
BAUDRATE = 64000000
spi = board.SPI()
# Create the ST7789 display:
# library expects a display that is 240x320,
# Our physical display is 240x240 so we need to offset by 80
disp = st7789.ST7789(
spi,
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
width=240,
height=240,
x_offset=0,
y_offset=80,
)
# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
height = disp.height # we swap height/width to rotate it to landscape!
width = disp.width
rotation = 0
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 72)
images = []
for i in range(0, 10):
images.append(Image.new("RGB", (width, height)))
draw = ImageDraw.Draw(images[i])
draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0))
text_w, text_h = font.getsize(str(i))
draw.text((disp.width/2 - text_w/2, disp.height/2 - text_h/2 ), str(i), font=font, fill="#FFFFFF")
while True:
for image in images:
disp.image(image, rotation)
print(f"{time.asctime()}")
Thanks,
David