-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
CircuitPython version
Adafruit CircuitPython 8.2.9 on 2023-12-06; LILYGO T-DISPLAY with rp2040
The behaviors was tested with all versions from the first support at 8.1.0 to the latest 9.0.0-alpha6 and is consistent across all versions. It even applies to the similar T-PicoC3. Details belowCode/REPL
# 23 Jun 2022 - @todbot / Tod Kurt
import time, random, board, displayio, vectorio, rainbowio
display = board.DISPLAY
maingroup = displayio.Group()
display.root_group = 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.05)Behavior
The refresh rate of this above code example of 20 moving disks is around 0.9 fps - some 1.2 seconds between each frame. Additionally all the firmware since 8.1.0 to 9.0.0 have one chaos pixel line at the bottom of the screen. A little distracting to be used in a GUI and interactive content.
Description
If I include the respective driver for the ST7789 display chip in the boot.py this problem does not appear. The frame rate is some 20 fps and responsive. Using the same code above in the code.py but having the following content in the boot.py resolves this issue:
import board, busio, displayio, fourwire
from adafruit_st7789 import ST7789
display.release_displays()
tft_dc = board.LCD_DC
tft_cs = board.LCD_CS
spi_clk = board.LCD_CLK
spi_mosi = board.LCD_MOSI
tft_rst = board.LCD_RESET
backlight = board.LCD_BACKLIGHT
spi = busio.SPI(spi_clk, spi_mosi)
display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst)
display = ST7789(
display_bus,
rotation=270,
width=240,
height=135,
rowstart=40,
colstart=53,
backlight_pin=backlight,
)So even though I call the board.DISPLAY it seems to address the driver loaded in the boot.py instead of the firmware driver. It does not work with my two T-PicoC3, though. But if I include the above code in the respective files and use this display constructor, it is responsive and no bottom pixel shift. Notice the colstart=53 for the additional information.
Additional information
The colstart=53 appears also in the function common_hal_busdisplay_busdisplay_construct() in the board.c of the board description for compiling the firmware as 5th parameter. Changing the number to 52 and recompiling the firmware solved this issue. Note as well that the rotation here (7th parameter) is given as 90 while my constructor above uses rotation=270,. Don't know why. The resulting orientation for both is the same.
One more observation: on one of my 3 T-Display rp2040 boards the firmware produces no output on the display at all. Same firmware on all 3 boards, but one activates only the backlight while the screen stays blank. Yet on all boards (including two additional T-PicoC3 boards) the above mentioned direct call of the adafruit_st7789.mpy library works fast and without issues.