www.joy
-
it.net
Pascalstr. 8 47506 Neukirchen
-
Vluyn
There you activate SPI under
5 Interfacing Options
→
P4 SPI
. Then run
the following command to restart the Raspberry Pi to put the changes
into effect.
sudo reboot
For this code example we use the library
, which was publis-
hed under the
. To do this, insert the following commands one
after the other to successfully install the library.
sudo apt
-
get update
sudo apt
-
get install python3
-
rpi.gpio python3
-
spidev python3
-
pip python3
-
pil
python3
-
numpy
git clone https://github.com/rusconi/Rpi
-
ST7789.git
cd Rpi
-
ST7789
sudo python3 setup.py install
Now you have successfully downloaded the library. You can download
the sample code
or use the following command to download it di-
rectly to your Raspberry Pi.
wget https://joy
-
it.net/files/files/Produkte/SBC
-
LCD01/SBC
-
LCD01
-
Python.zip
You must download this file to have the image file on your Raspberry Pi.
Now you can execute the following commands to project the image file
on your LCD.
unzip SBC
-
LCD01
-
Python
cd SBC
-
LCD01
-
Python
sudo python3 image.py Joy
-
IT
-
240x240.png
In the following you will additionally find our code:
import
sys
from
PIL
import
Image
import
ST7789
as
ST7789
# Save image from argument
picRAW
=
sys
.
argv
[
1
]
# Declare display
lcd
=
ST7789
.
ST7789
(
port
=
0
,
cs
=
ST7789
.
BG_SPI_CS_FRONT
,
dc
=
25
,
rst
=
27
,
backlight
=
18
,
mode
=
3
,
spi_speed_hz
=
8000000
)
lcd
.
begin
()
# Open image
pic
=
Image
.
open
(
picRAW
)
# Fit image to screen
pic
=
pic
.
resize
((
lcd
.
width
,
lcd
.
height
))
# Show image on display
lcd
.
display
(
pic
)