here is how I did it
that's how I connected the screens to the Raspberry Pi:
Then execute this commands:
sudo pip3 install adafruit-circuitpython-rgb-display
sudo apt-get install fonts-dejavu
sudo apt-get install python3-pil
sudo apt-get install libopenjp2-7 libtiff5 libatlas-base-dev
pip3 install adafruit-blinka
this is for the coding for python
Now we need to enable the SPI
so to do that we need to execute this command
sudo nano /boot/config.txt
usually this line is commented so uncomment by simply removing the "#" before it
and add the following line also :
dtoverlay=spi1-1cs
then Ctrl+S and Ctrl+X
now if you want to check if everything is fine tell now:
execute the following command:
ls -l /dev/spi*
you should see this
and you can use this code it would work:
import time
import subprocess
import digitalio
import board
import busio
from PIL import Image, ImageDraw, ImageFont
from adafruit_rgb_display import ili9341
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)
cs_pin1 = digitalio.DigitalInOut(board.D18)
dc_pin1 = digitalio.DigitalInOut(board.D26)
reset_pin1 = digitalio.DigitalInOut(board.D6)
# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000
# Setup SPI bus using hardware SPI:
spi1 = busio.SPI(board.SCK_1, MOSI=board.MOSI_1, MISO=board.MISO_1)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
# 0.96" SSD1331
disp = ili9341.ILI9341(
spi,
rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
)
disp1 = ili9341.ILI9341(
spi1,
rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
cs=cs_pin1,
dc=dc_pin1,
rst=reset_pin1,
baudrate=BAUDRATE,
)
if disp.rotation % 180 == 90:
height = disp.width # we swap height/width to rotate it to landscape!
width = disp.height
else:
width = disp.width # we swap height/width to rotate it to landscape!
height = disp.height
image = Image.new("RGB", (width, height))
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0))
disp.image(image)
disp1.image(image)
# First define some constants to allow easy positioning of text.
padding = -2
x = 0
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 24)
while True:
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=0)
cmd = "hostname -I | cut -d' ' -f1"
IP = "IP: " + subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
CPU = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'"
MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\''
Disk = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" # pylint: disable=line-too-long
Temp = subprocess.check_output(cmd, shell=True).decode("utf-8")
# Write four lines of text.
y = padding
draw.text((x, y), IP, font=font, fill="#FFFFFF")
y += font.getsize(IP)[1]
draw.text((x, y), CPU, font=font, fill="#FFFF00")
y += font.getsize(CPU)[1]
draw.text((x, y), MemUsage, font=font, fill="#00FF00")
y += font.getsize(MemUsage)[1]
draw.text((x, y), Disk, font=font, fill="#0000FF")
y += font.getsize(Disk)[1]
draw.text((x, y), Temp, font=font, fill="#FF00FF")
# Display image.
disp.image(image)
disp1.image(image)
time.sleep(0.0001)
this only works with the ili9341 driver display i am not aware of how I would do it with a different driver
But if you want to find out how to do it I used these websites:
-enter link description here
-enter link description here
-enter link description here
Here is a picture of it