Issues with multiple TFTs with PIL library

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mfk
 
Posts: 22
Joined: Mon Jan 28, 2013 3:40 pm

Issues with multiple TFTs with PIL library

Post by mfk »

Similar to the issues in the closed topic with a similar title (viewtopic.php?f=47&t=181241&p=881654&hi ... ts#p881654) I am having very confusing issues with three adafruit TFTs. Two 2.4 ILI9341 and one 3.5 HX8357. All on spi0 (shared mosi and clk) and independent cs, dc and reset. See the code below for the details on pins. All three screens mostly work at the same time....mostly. Depending on the order they are called one can get some odd bands of color on the edge, a mirror of what is on another display, flashes of the right graphic then something else. The code below is some very basic tests I have that shows the drivers, pins and clearing the screens followed by drawing a color rectangle. I have tried a number of things in code (such as changing the order, turning one on and the others off) and hardware fiddling but can not get a consistent result, i.e. drawing the graphics I want on a specific TFT in the color I select.

Code: Select all

#tft test rPi4 on spi0
import time
import digitalio
import board
import displayio
from PIL import Image, ImageDraw

from adafruit_rgb_display import color565
import adafruit_rgb_display.ili9341 as ili9341
import adafruit_rgb_display.hx8357 as hx8357

# Configuration for CS and DC pins
cs0_pin = digitalio.DigitalInOut(board.D8)
dc0_pin = digitalio.DigitalInOut(board.D5)
reset0_pin = digitalio.DigitalInOut(board.D6)
cs1_pin = digitalio.DigitalInOut(board.D7)
dc1_pin = digitalio.DigitalInOut(board.D12)
reset1_pin = digitalio.DigitalInOut(board.D16)
cs2_pin = digitalio.DigitalInOut(board.D25)
dc2_pin = digitalio.DigitalInOut(board.D23)
reset2_pin = digitalio.DigitalInOut(board.D24)

# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000

# Setup SPI bus using hardware SPI:
spi = board.SPI()

display2 = hx8357.HX8357(
     spi,
#     rotation=90,
     cs=cs2_pin,
     dc=dc2_pin,
     rst=reset2_pin,
     width=480,
     height=320
 )

display1 = ili9341.ILI9341(
     spi,
#     rotation=90,
     cs=cs1_pin,
     dc=dc1_pin,
     rst=reset1_pin,
     baudrate=BAUDRATE
 )

display0 = ili9341.ILI9341(
     spi,
#     rotation=90,
     cs=cs0_pin,
     dc=dc0_pin,
     rst=reset0_pin,
     baudrate=BAUDRATE
 )

xpos=120
ypos=160
# Main loop:
while True:
    # Clear the display
    display0.fill(0)
    display1.fill(0)
    display2.fill(0)
    time.sleep(2)
    # Draw a rectangle at x,y.
    img2=Image.new("RGB",(45,45), "blue")
    display2.image(img2, 0, xpos, ypos)
    img1=Image.new("RGB",(45,45), "green")
    display1.image(img1, 0, xpos, ypos)
    img0=Image.new("RGB",(45,45), "red")
    display0.image(img0, 0, xpos, ypos)
    # Pause 2 seconds.
    time.sleep(2)
    # Clear the screen.
    display2.fill(color565(175, 0, 0))
    display1.fill(color565(95, 95, 255))
    display0.fill(color565(0, 255, 0))
    # Pause 1 second.
    time.sleep(2)

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”