1 . 3 i n c h L C D M o d u l e
O v e r v i e w
I n t r o d u c t i o n
T h i s p r o d u c t p r o v i d e s R a s p b e r r y P i , S T M 3 2 , A r d u i n o e x a m p l e s
S p e c i f i c a t i o n
O p e r a t i n g v o l t a g e : 3 . 3 V / 5 V
v o l t a g e a r e c o n s i s t e n t , o t h e r w i s e i t w i l l n o t w o r k p r o p e r l y )
I n t e r f a c e : S P I
L C D t y p e : I P S
C o n t r o l l e r : S T 7 7 8 9
R e s o l u t i o n : 2 4 0 ( H ) R G B x 2 4 0 ( V )
D i s p l a y a r e a : 2 3 . 4
P i x e l s i z e : 0 . 0 9 7 5
D i m e n s i o n : 4 5 x 3 1 ( m m )
I n t e r f a c e D e s c r i p t i o n
R a s p b e r r y P i h a r d w a r e c o n n e c t i o n
P l e a s e c o n n e c t t h e L C D t o y o u r R a s p b e r r y P i b y t h e 8 P I N c a b l e a c c o r d i n g t o t h e t a b l e
b e l o w
U s e t h e p i n h e a d e r o r P H 2 . 0 8 P I N i n t e r f a c e , y o u n e e d t o c o n n e c t a c c o r d i n g t o t h e f o l l o w i n g
t a b l e
C o n n e c t t o R a s p b e r r y P i
L C D
V C C
G N D
D I N
C L K
C S
D S
R S T
B L
T h e 1 . 3 i n c h L C D u s e s t h e P H 2 . 0 8 P I N i n t e r f a c e , w h i c h c a n b e c o n n e c t e d t o t h e R a s p b e r r y
P i a c c o r d i n g t o t h e a b o v e t a b l e :
c o l o r o f t h e w i r i n g i n t h e p i c t u r e i s f o r r e f e r e n c e o n l y , a n d t h e a c t u a l c o l o r s h a l l p r e v a i l . )
S T M 3 2 h a r d w a r e c o n n e c t i o n
T h e e x a m p l e w e p r o v i d e i s b a s e d o n S T M 3 2 F 1 0 3 R B T 6 , a n d t h e c o n n e c t i o n m e t h o d
p r o v i d e d i s a l s o t h e c o r r e s p o n d i n g p i n o f S T M 3 2 F 1 0 3 R B T 6 . I f y o u n e e d t o t r a n s p l a n t t h e
p r o g r a m , p l e a s e c o n n e c t a c c o r d i n g t o t h e a c t u a l p i n .
S T M 3 2 F 1 0 3 Z E T c o n n e c t i o n p i n c o r r e s p o n d e n c e
T a k e t h e
X N U C L E O - F 1 0 3 R B d e v e l o p m e n t b o a r d
e x a m p l e , t h e c o n n e c t i o n i s a s f o l l o w s :
A r d u i n o h a r d w a r e c o n n e c t i o n
A r d u i n o U N O C o n n e c t i o n p i n c o r r e s p o n d e n c e
T h e c o n n e c t i o n d i a g r a m i s a s f o l l o w s ( c l i c k t o e n l a r g e ) :
L C D a n d t h e c o n t r o l l e r
T h e b u i l t - i n c o n t r o l l e r u s e d i n t h i s L C D i s S T 7 7 8 9 V W , w h i c h i s a n L C D c o n t r o l l e r w i t h 2 4 0 x
R G B x 3 2 0 p i x e l s , w h i l e t h e p i x e l s o f t h i s L C D i t s e l f a r e 1 3 5 ( H ) R G B x 2 4 0 ( V ) . T h e r e a r e t w o
t y p e s o f h o r i z o n t a l a n d v e r t i c a l s c r e e n s , s o t h e i n t e r n a l R A M o f t h e L C D i s n o t f u l l y u s e d .
T h e L C D s u p p o r t s 1 2 - b i t , 1 6 - b i t a n d 1 8 - b i t i n p u t c o l o r f o r m a t s p e r p i x e l , n a m e l y R G B 4 4 4 ,
R G B 5 6 5 , R G B 6 6 6 t h r e e c o l o r f o r m a t s , t h i s d e m o u s e s R G B 5 6 5 c o l o r f o r m a t , w h i c h i s a l s o a
c o m m o n l y u s e d R G B f o r m a t
T h e L C D u s e s a f o u r - w i r e S P I c o m m u n i c a t i o n i n t e r f a c e , w h i c h c a n g r e a t l y s a v e t h e G P I O
p o r t , a n d t h e c o m m u n i c a t i o n s p e e d w i l l b e f a s t e r .
C o m m u n i c a t i o n P r o t o c o l
N o t e : D i f f e r e n t f r o m t h e t r a d i t i o n a l S P I p r o t o c o l , t h e d a t a l i n e f r o m t h e s l a v e t o t h e m a s t e r
i s h i d d e n s i n c e t h e d e v i c e o n l y h a s d i s p l a y r e q u i r e m e n t .
R E S X I s t h e r e s e t p i n , i t s h o u l d b e l o w w h e n p o w e r i n g t h e m o d u l e a n d b e h i g h e r a t o t h e r
t i m e s ;
C S X i s s l a v e c h i p s e l e c t , w h e n C S i s l o w , t h e c h i p i s e n a b l e d .
D / C X i s d a t a / c o m m a n d c o n t r o l p i n , w h e n D C = 0 , w r i t e c o m m a n d , w h e n D C = 1 , w r i t e
d a t a
S D A i s t h e d a t a p i n f o r t r a n s m i t t i n g R G B d a t a , i t w o r k s a s t h e M O S I p i n o f S P I i n t e r f a c e ;
S C L w o r k a s t h e S C L K p i n s o f S P I i n t e r f a c e .
S P I c o m m u n i c a t i o n h a s d a t a t r a n s f e r t i m i n g , w h i c h i s c o m b i n e d b y C P H A a n d C P O L .
C P O L d e t e r m i n e s t h e l e v e l o f t h e s e r i a l s y n c h r o n o u s c l o c k a t i d l e s t a t e . W h e n C P O L = 0 ,
t h e l e v e l i s L o w . H o w e v e r , C P O L h a s l i t t l e e f f e c t t o t h e t r a n s m i s s i o n .
C P H A d e t e r m i n e s w h e t h e r d a t a i s c o l l e c t e d a t t h e f i r s t c l o c k e d g e o r a t t h e s e c o n d c l o c k
e d g e o f s e r i a l s y n c h r o n o u s c l o c k ; w h e n C P H L = 0 , d a t a i s c o l l e c t e d a t t h e f i r s t c l o c k e d g e .
T h e r e a r e 4 S P I c o m m u n i c a t i o n m o d e s . S P I 0 i s c o m m o n l y u s e d , i n w h i c h C P H L = 0 , C P O L
= 0 .
W o r k i n g w i t h R a s p i b e r r y
E n a b l e S P I i n t e r f a c e
P S : I f y o u a r e u s i n g t h e s y s t e m o f t h e B u l l s e y e b r a n c h , y o u n e e d t o c h a n g e " a p t - g e t " t o
" a p t " , t h e s y s t e m o f t h e B u l l s e y e b r a n c h o n l y s u p p o r t s P y t h o n 3 .
O p e n t e r m i n a l , u s e c o m m a n d t o e n t e r t h e c o n f i g u r a t i o n p a g e
sudo raspi-config
Choose Interfacing Options -> SPI -> Yes
R e b o o t R a s p b e r r y P i
sudo reboot
P l e a s e m a k e s u r e t h e S P I i s n o t o c c u p i e d b y o t h e r d e v i c e s , y o u c a n c h e c k i n t h e m i d d l e o f
/ b o o t / c o n f i g . t x t
I n s t a l l L i b r a r i e s
I n s t a l l B C M 2 8 3 5 l i b r a r i e s
#Open the Raspberry Pi terminal and run the following command
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz
tar zxvf bcm2835-1.68.tar.gz
cd bcm2835-1.68/
sudo ./configure && sudo make && sudo make check && sudo make install
# For more information, please refer to the official website: http://www.a
irspayce.com/mikem/bcm2835/
I n s t a l l w i r i n g P i l i b r a r i e s
#Open the Raspberry Pi terminal and run the following command
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (earlier than before, you may not
need to execute), you may need to upgrade:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear. If it does not appear, the ins
tallation is wrong
#Bullseye branch system use the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
# Run gpio -v and version 2.60 will appear. If it does not appear, it mean
s that there is an installation error
I n s t a l l P y t h o n l i b r a r i e s
#python2
sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-pil
sudo apt-get install python-numpy
sudo pip install RPi.GPIO
sudo pip install spidev
#python3
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo pip3 install RPi.GPIO
sudo pip3 install spidev
D o w n l o a d E x a m p l e s
O p e n R a s p b e r r y P i t e r m i n a l a n d r u n t h e f o l l o w i n g c o m m a n d
sudo apt-get install unzip -y
sudo wget https://www.waveshare.com/w/upload/8/8d/LCD_Module_RPI_code.zip
sudo unzip ./LCD_Module_RPI_code.zip
cd LCD_Module_RPI_code/RaspberryPi/
R u n t h e d e m o c o d e s
P l e a s e g o i n t o t h e R a s p b e r r y P i d i r e c t o r y ( d e m o c o d e s ) f i r s t a n d r u n t h e c o m m a n d s i n
t e r m i n a l
C c o d e s
R e - c o m p i l e t h e d e m o c o d e s
cd c
sudo make clean
sudo make -j 8
T h e t e s t p r o g r a m o f a l l s c r e e n s c a n b e c a l l e d d i r e c t l y b y e n t e r i n g t h e c o r r e s p o n d i n g s i z e
sudo ./main Screen Size
D e p e n d i n g o n t h e L C D , o n e o f t h e f o l l o w i n g c o m m a n d s s h o u l d b e e n t e r e d :
#0.96inch LCD Module
sudo ./main 0.96
#1.14inch LCD Module
sudo ./main 1.14
#1.28inch LCD Module
sudo ./main 1.28
#1.3inch LCD Module
sudo ./main 1.3
#1.47inch LCD Module
sudo ./main 1.47
#1.54inch LCD Module
sudo ./main 1.54
#1.8inch LCD Module
sudo ./main 1.8
#2inch LCD Module
sudo ./main 2
#2.4inch LCD Module
sudo ./main 2.4
p y t h o n
E n t e r t h e p y t h o n p r o g r a m d i r e c t o r y a n d r u n t h e c o m m a n d l s - l
cd python/examples
ls -l
T e s t p r o g r a m s f o r a l l s c r e e n s c a n b e v i e w e d , s o r t e d b y s i z e :
0 i n c h 9 6 _ L C D _ t e s t . p y : 0 . 9 6 i n c h L C D t e s t p r o g r a m
1 i n c h 1 4 _ L C D _ t e s t . p y : 1 . 1 4 i n c h L C D t e s t p r o g r a m
1 i n c h 2 8 _ L C D _ t e s t . p y : 1 . 2 8 i n c h L C D t e s t p r o g r a m
1 i n c h 3 _ L C D _ t e s t . p y : 1 . 3 i n c h L C D t e s t p r o g r a m
1 i n c h 4 7 _ L C D _ t e s t . p y : 1 . 4 7 i n c h L C D t e s t p r o g r a m
1 i n c h 5 4 _ L C D _ t e s t . p y : 1 . 5 4 i n c h L C D t e s t p r o g r a m
1 i n c h 8 _ L C D _ t e s t . p y : 1 . 8 i n c h L C D t e s t p r o g r a m
2 i n c h _ L C D _ t e s t . p y : 2 i n c h L C D t e s t p r o g r a m
2 i n c h 4 _ L C D _ t e s t . p y : 2 i n c h 4 L C D t e s t p r o g r a m
J u s t r u n t h e p r o g r a m c o r r e s p o n d i n g t o t h e s c r e e n , t h e p r o g r a m s u p p o r t s p y t h o n 2 / 3
# python2
sudo python 0inch96_LCD_test.py
sudo python 1inch14_LCD_test.py
sudo python 1inch28_LCD_test.py
sudo python 1inch3_LCD_test.py
sudo python 1inch47_LCD_test.py
sudo python 1inch54_LCD_test.py
sudo python 1inch8_LCD_test.py
sudo python 2inch_LCD_test.py
sudo python 2inch4_LCD_test.py
# python3
sudo python3 0inch96_LCD_test.py
sudo python3 1inch14_LCD_test.py
sudo python3 1inch28_LCD_test.py
sudo python3 1inch3_LCD_test.py
sudo python3 1inch47_LCD_test.py
sudo python3 1inch54_LCD_test.py
sudo python3 1inch8_LCD_test.py
sudo python3 2inch_LCD_test.py
sudo python3 2inch4_LCD_test.py
F B C P p o r t i n g
P S : F B C P i s c u r r e n t l y n o t c o m p a t i b l e w i t h 6 4 - b i t R a s p b e r r y P i s y s t e m , i t i s r e c o m m e n d e d
t o u s e 3 2 - b i t s y s t e m .
F r a m e b u f f e r u s e s a v i d e o o u t p u t d e v i c e t o d r i v e a v i d e o d i s p l a y d e v i c e f r o m a m e m o r y
b u f f e r c o n t a i n i n g c o m p l e t e f r a m e d a t a . S i m p l y p u t , a m e m o r y a r e a i s u s e d t o s t o r e t h e
d i s p l a y c o n t e n t , a n d t h e d i s p l a y c o n t e n t c a n b e c h a n g e d b y c h a n g i n g t h e d a t a i n t h e
m e m o r y .
T h e r e i s a n o p e n s o u r c e p r o j e c t o n g i t h u b : f b c p - i l i 9 3 4 1 . C o m p a r e d w i t h o t h e r f b c p
p r o j e c t s , t h i s p r o j e c t u s e s p a r t i a l r e f r e s h a n d D M A t o a c h i e v e a s p e e d o f u p t o 6 0 f p s
D o w n l o a d D r i v e r s
sudo apt-get install cmake -y
cd ~
wget https://www.waveshare.com/w/upload/1/18/Waveshare_fbcp.zip
unzip Waveshare_fbcp.zip
cd Waveshare_fbcp/
sudo chmod +x ./shell/*
M e t h o d 1 : U s e a s c r i p t ( r e c o m m e n d e d )
H e r e w e h a v e w r i t t e n s e v e r a l s c r i p t s t h a t a l l o w u s e r s t o q u i c k l y u s e f b c p a n d r u n
c o r r e s p o n d i n g c o m m a n d s a c c o r d i n g t o t h e i r o w n s c r e e n
I f y o u u s e a s c r i p t a n d d o n o t n e e d t o m o d i f y i t , y o u c a n i g n o r e t h e s e c o n d m e t h o d b e l o w .
N o t e : T h e s c r i p t w i l l r e p l a c e t h e c o r r e s p o n d i n g / b o o t / c o n f i g . t x t a n d / e t c / r c . l o c a l a n d
r e s t a r t , i f t h e u s e r n e e d s , p l e a s e b a c k u p t h e r e l e v a n t f i l e s i n a d v a n c e .
#0.96inch LCD Module
sudo ./shell/waveshare-0inch96
#1.14inch LCD Module
sudo ./shell/waveshare-1inch14
#1.3inch LCD Module
sudo ./shell/waveshare-1inch3
#1.44inch LCD Module
sudo ./shell/waveshare-1inch44
#1.54inch LCD Module
sudo ./shell/waveshare-1inch54
#1.8inch LCD Module
sudo ./shell/waveshare-1inch8
#2inch LCD Module
sudo ./shell/waveshare-2inch
#2.4inch LCD Module
sudo ./shell/waveshare-2inch4
M e t h o d 2 : M a n u a l c o n f i g u r a t i o n
E n v i r o n m e n t C o n f i g u r a t i o n
R a s p b e r r y P i ' s v c 4 - k m s - v 3 d w i l l c a u s e f b c p t o f a i l , s o w e n e e d t o c l o s e v c 4 - k m s - v 3 d b e f o r e
i n s t a l l i n g i n f b c p
sudo nano /boot/config.txt
J u s t b l o c k t h e s t a t e m e n t c o r r e s p o n d i n g t o t h e p i c t u r e b e l o w .
A r e b o o t i s t h e n r e q u i r e d .
sudo reboot
C o m p i l e a n d r u n
mkdir build
cd build
cmake [options] ..
sudo make -j
sudo ./fbcp
R e p l a c e i t b y y o u r s e l f a c c o r d i n g t o t h e L C D M o d u l e y o u u s e , a b o v e c m a k e [ o p t i o n s ] . .
#0.96inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_0INCH96_LCD=ON -DBACKLIG
HT_CONTROL=ON -DSTATISTICS=0 ..
#1.14inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH14_LCD=ON -DBACKLIG
HT_CONTROL=ON -DSTATISTICS=0 ..
#1.3inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH3_LCD=ON -DBACKLIGH
T_CONTROL=ON -DSTATISTICS=0 ..
#1.54inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH54_LCD=ON -DBACKLIG
HT_CONTROL=ON -DSTATISTICS=0 ..
#1.8inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH8_LCD=ON -DBACKLIGH
T_CONTROL=ON -DSTATISTICS=0 ..
#2inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_2INCH_LCD=ON -DBACKLIGHT
_CONTROL=ON -DSTATISTICS=0 ..
#2.4inch LCD Module
sudo cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_2INCH4_LCD=ON -DBACKLIGH
T_CONTROL=ON -DSTATISTICS=0 ..
S e t u p t o s t a r t a u t o m a t i c a l l y
sudo cp ~/Waveshare_fbcp/buil
d/fbcp /usr/local/bin/fbcp
sudo nano /etc/rc.local
A d d f b c p & b e f o r e e x i t 0 . N o t e t h a t y o u
m u s t a d d " & " t o r u n i n t h e
b a c k g r o u n d , o t h e r w i s e t h e s y s t e m
m a y n o t b e a b l e t o s t a r t .
S e t t h e d i s p l a y r e s o l u t i o n
S e t t h e u s e r i n t e r f a c e d i s p l a y s i z e i n t h e / b o o t / c o n f i g . t x t f i l e .
sudo nano /boot/config.txt
T h e n a d d t h e f o l l o w i n g l i n e s a t t h e e n d o f t h e c o n f i g . t x t .
hdmi_force_hotplug=1
hdmi_cvt=[options]
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
display_rotate=0
R e p l a c e t h e a b o v e h d m i _ c v t = [ o p t i o n s ] a c c o r d i n g t o t h e L C D M o d u l e y o u a r e u s i n g .
#2.4inchinch LCD Module & 2inchinch LCD Module
hdmi_cvt=640 480 60 1 0 0 0
#1.8inch LCD Module
hdmi_cvt=400 300 60 1 0 0 0
#1.3inch LCD Module & 1.54inch LCD Module
hdmi_cvt=300 300 60 1 0 0 0
#1.14inch LCD Module
hdmi_cvt=300 170 60 1 0 0 0
#0.96inch LCD Module
hdmi_cvt=300 150 60 1 0 0 0
A n d t h e n r e b o o t t h e s y s t e m
sudo reboot
A f t e r r e b o o t i n g t h e s y s t e m , t h e R a s p b e r r y P i O S u s e r i n t e r f a c e w i l l b e d i s p l a y e d .
A P I D e s c r i p t i o n
T h e R a s p b e r r y P i s e r i e s c a n s h a r e a s e t o f p r o g r a m s , b e c a u s e t h e y a r e a l l e m b e d d e d
s y s t e m s , a n d t h e c o m p a t i b i l i t y i s r e l a t i v e l y s t r o n g .
T h e p r o g r a m i s d i v i d e d i n t o b o t t o m - l a y e r h a r d w a r e i n t e r f a c e , m i d d l e - l a y e r L C D s c r e e n
d r i v e r , a n d u p p e r - l a y e r a p p l i c a t i o n ;
C
H a r d w a r e i n t e r f a c e
W e h a v e c a r r i e d o u t t h e l o w - l e v e l e n c a p s u l a t i o n , i f y o u n e e d t o k n o w t h e i n t e r n a l
i m p l e m e n t a t i o n c a n g o t o t h e c o r r e s p o n d i n g d i r e c t o r y t o c h e c k , f o r t h e r e a s o n t h a t t h e
h a r d w a r e p l a t f o r m a n d t h e i n t e r n a l i m p l e m e n t a t i o n a r e d i f f e r e n t
Y o u c a n o p e n D E V _ C o n f i g . c ( . h ) t o s e e d e f i n i t i o n s , w h i c h i n t h e d i r e c t o r y
R a s p b e r r y P i \ c \ l i b \ C o n f i g
1.There are three ways for C to drive:BCM2835 library, WiringPi library an
d Dev library respectively
2.We use Dev libraries by default. If you need to change to
ringPi libraries ,please open RaspberryPi\c\Makefile and modify lines 13-1
5 as follows:
D a t a t y p e
#define UBYTE
#define UWORD
#define UDOUBLE
M o d u l e i n i t i a l i z a t i o n a n d e x i t p r o c e s s i n g .
void DEV_Module_Init(void);
void DEV_Module_Exit(void);
Note:
Here is some GPIO processing before and after using the LCD screen.
G P I O r e a d a n d w r i t e :
void
DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE
DEV_Digital_Read(UWORD Pin);
S P I w r i t e d a t a
void DEV_SPI_WriteByte(UBYTE Value);
U p p e r a p p l i c a t i o n
I f y o u n e e d t o d r a w p i c t u r e s , o r d i s p l a y C h i n e s e a n d E n g l i s h c h a r a c t e r s , w e p r o v i d e s o m e
b a s i c f u n c t i o n s h e r e a b o u t s o m e g r a p h i c s p r o c e s s i n g i n t h e d i r e c t o r y
R a s p b e r r y P i \ c \ l i b \ G U I \ G U I _ P a i n t . c ( . h ) .
T h e f o n t s c a n b e f o u n d i n R a s p b e r r y P i \ c \ l i b \ F o n t s d i r e c t o r y .
N e w I m a g e P r o p e r t i e s : C r e a t e a n e w i m a g e b u f f e r , t h i s p r o p e r t y i n c l u d e s t h e i m a g e
b u f f e r n a m e , w i d t h , h e i g h t , f l i p A n g l e , c o l o r .
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate,
UWORD Color)
Parameters:
Image: the name of the image buffer, which is actually a pointer to
the first address of the image buffer;
Width: image buffer Width;
Height: the Height of the image buffer;
Rotate: Indicates the rotation Angle of an image
Color: the initial Color of the image;
S e l e c t i m a g e b u f f e r : T h e p u r p o s e o f t h e s e l e c t i o n i s t h a t y o u c a n c r e a t e m u l t i p l e i m a g e
a t t r i b u t e s , t h e r e c a n b e m u l t i p l e i m a g e s b u f f e r , y o u c a n s e l e c t e a c h i m a g e y o u c r e a t e .
void Paint_SelectImage(UBYTE *image)
Parameters:
Image: the name of the image buffer, which is actually a pointer to
the first address of the image buffer;
I m a g e R o t a t i o n : S e t t h e r o t a t i o n A n g l e o f t h e s e l e c t e d i m a g e , p r e f e r a b l y a f t e r
P a i n t _ S e l e c t I m a g e ( ) , y o u c a n c h o o s e t o r o t a t e 0 , 9 0 , 1 8 0 , 2 7 0 .
void Paint_SetRotate(UWORD Rotate)
Parameters:
Rotate: ROTATE_0, ROTATE_90, ROTATE_180, and ROTATE_270 correspond
to 0, 90, 180, and 270 degrees.
I m a g e m i r r o r f l i p : S e t t h e m i r r o r f l i p o f t h e s e l e c t e d i m a g e . Y o u c a n c h o o s e n o m i r r o r ,
h o r i z o n t a l m i r r o r , v e r t i c a l m i r r o r , o r i m a g e c e n t e r m i r r o r .
void Paint_SetMirroring(UBYTE mirror)
Parameters:
Mirror: indicates the image mirroring mode. MIRROR_NONE, MIRROR_HO
RIZONTAL, MIRROR_VERTICAL, MIRROR_ORIGIN correspond to no mirror, horizont
al mirror, vertical mirror, and image center mirror respectively.
S e t p o i n t s o f t h e d i s p l a y p o s i t i o n a n d c o l o r i n t h e b u f f e r : h e r e i s t h e c o r e G U I f u n c t i o n ,
p r o c e s s i n g p o i n t s d i s p l a y p o s i t i o n a n d c o l o r i n t h e b u f f e r .
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
Parameters:
Xpoint: the X position of a point in the image buffer
Ypoint: Y position of a point in the image buffer
Color: indicates the Color of the dot
I m a g e b u f f e r f i l l c o l o r : F i l l s t h e i m a g e b u f f e r w i t h a c o l o r , u s u a l l y u s e d t o f l a s h t h e
s c r e e n i n t o b l a n k .
void Paint_Clear(UWORD Color)
Parameters:
Color: fill Color
T h e f i l l c o l o r o f a c e r t a i n w i n d o w i n t h e i m a g e b u f f e r : t h e i m a g e b u f f e r p a r t o f t h e
w i n d o w f i l l e d w i t h a c e r t a i n c o l o r , u s u a l l y u s e d t o f r e s h t h e s c r e e n i n t o b l a n k , o f t e n u s e d
f o r t i m e d i s p l a y , f r e s h t h e l a s t s e c o n d o f t h e s c r e e n .
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color)
Parameters:
Xstart: the x-starting coordinate of the window
Ystart: the y-starting coordinate of the window
Xend: the x-end coordinate of the window
Yend: the y-end coordinate of the window
Color: fill Color
D r a w p o i n t : I n t h e i m a g e b u f f e r , d r a w p o i n t s o n ( X p o i n t , Y p o i n t ) , y o u c a n c h o o s e t h e
c o l o r , t h e s i z e o f t h e p o i n t , t h e s t y l e o f t h e p o i n t .
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Do
t_Pixel, DOT_STYLE Dot_Style)
Parameters:
Xpoint: indicates the X coordinate of a point.
Ypoint: indicates the Y coordinate of a point.
Color: fill Color
Dot_Pixel: The size of the dot, the demo provides 8 size pointss b
y default.
Dot_Style: the size of a point that expands from the center of the
point or from the bottom left corner of the point to the right and up.
D r a w l i n e : I n t h e i m a g e b u f f e r , d r a w l i n e f r o m ( X s t a r t , Y s t a r t ) t o ( X e n d , Y e n d ) , y o u c a n
c h o o s e t h e c o l o r , t h e w i d t h a n d t h e s t y l e o f t h e l i n e .
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UW
ORD Color, LINE_STYLE Line_Style ,
Parameters:
Xstart: the x-starting coordinate of a line
Ystart: the y-starting coordinate of the a line
Xend: the x-end coordinate of a line
Yend: the y-end coordinate of a line
Color: fill Color
Line_width: The width of the line, the demo provides 8 sizes of wi
dth by default.
Line_Style: line style. Select whether the lines are joined in a s
traight or dashed way.
D r a w r e c t a n g l e : I n t h e i m a g e b u f f e r , d r a w a r e c t a n g l e f r o m ( X s t a r t , Y s t a r t ) t o ( X e n d ,
Y e n d ) , y o u c a n c h o o s e t h e c o l o r , t h e w i d t h o f t h e l i n e , w h e t h e r t o f i l l t h e i n s i d e o f t h e
r e c t a n g l e .
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color, DOT_PIXEL Line_width,
Parameters:
Xstart: the starting X coordinate of the rectangle
Ystart: the starting Y coordinate of the rectangle
Xend: the x-end coordinate of the rectangle
Yend: the y-end coordinate of the rectangle
Color: fill Color
Line_width: The width of the four sides of a rectangle. And the de
mo provides 8 sizes of width by default.
Draw_Fill: Fill, whether to fill the inside of the rectangle
D r a w c i r c l e : I n t h e i m a g e b u f f e r , d r a w a c i r c l e o f R a d i u s w i t h ( X _ C e n t e r Y _ C e n t e r ) a s t h e
c e n t e r . Y o u c a n c h o o s e t h e c o l o r , t h e w i d t h o f t h e l i n e , a n d w h e t h e r t o f i l l t h e i n s i d e o f
t h e c i r c l e .
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD
Color, DOT_PIXEL Line_width,
Parameters:
X_Center: the x-coordinate of the center of the circle
Y_Center: the y-coordinate of the center of the circle
Radius: indicates the Radius of a circle
Color: fill Color
Line_width: The width of the arc, with a default of 8 widths
Draw_Fill: fill, whether to fill the inside of the circle
W r i t e A s c i i c h a r a c t e r : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a n
A s c i i c h a r a c t e r , y o u c a n s e l e c t A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r .
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFO
NT* Font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y-coordinate of the left vertex of a character
Ascii_Char: indicates the Ascii character
Font: Ascii visual character library, in the Fonts folder the demo
provides the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e E n g l i s h s t r i n g : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a
s t r i n g o f E n g l i s h c h a r a c t e r s , y o u c a n c h o o s e A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t
f o r e g r o u n d c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString,
sFONT* Font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PString: string, string is a pointer
Font: Ascii visual character library, in the Fonts folder the demo
provides the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e C h i n e s e s t r i n g : i n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a
s t r i n g o f C h i n e s e c h a r a c t e r s , y o u c a n c h o o s e c h a r a c t e r f o n t , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r o f t h e G B 2 3 1 2 e n c o d i n g
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString,
cFONT* font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PString: string, string is a pointer
Font: GB2312 encoding character Font library, in the Fonts folder
the demo provides the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e n u m b e r s : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a s t r i n g
o f n u m b e r s , y o u c a n c h o o s e A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r .
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Fon
t, UWORD Digit, UWORD Color_Foreground,
Parameters:
Xpoint: the x-coordinate of the left vertex of a character
Ypoint: the Y coordinate of the left vertex of the font
Nummber: indicates the number displayed, which can be a decimal
Digit: It's a decimal number
Font: Ascii visual character library, in the Fonts folder the demo
provides the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
D i s p l a y t i m e : i n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , d i s p l a y t i m e , y o u
c a n c h o o s e A s c i i v i s u a l c h a r a c t e r f o n t , f o n t f o r e g r o u n d c o l o r , f o n t b a c k g r o u n d c o l o r . ;
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT*
Font, UWORD Color_Background,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PTime: display time, A time structure is defined here, as long as
the hours, minutes and seconds are passed to the parameters;
Font: Ascii visual character library, in the Fonts folder the demo
provides the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
R e a d t h e l o c a l b m p i m a g e a n d w r i t e i t t o t h e c a c h e
F o r L i n u x o p e r a t i n g s y s t e m s s u c h a s R a s p b e r r y P i , y o u c a n r e a d a n d w r i t e p i c t u r e s F o r
R a s p b e r r y P i , i n t h e d i r e c t o r y : R a s p b e r r y P i \ c \ l i b \ G U I \ G U I _ B M P f i l e . c ( . h )
UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart)
parameter:
path: the relative path of the BMP image
Xstart: The X coordinate of the left vertex of the image, generally
0 is passed by default
Ystart: The Y coordinate of the left vertex of the picture, general
ly 0 by default
T e s t i n g C o d e f o r U s e r s
F o r R a s p b e r r y P i , i n t h e d i r e c t o r y : R a s p b e r r y P i \ c \ e x a m p l e s , f o r a l l t h e t e s t c o d e ;
I f y o u n e e d t o r u n t h e 0 . 9 6 - i n c h L C D t e s t p r o g r a m , y o u n e e d t o a d d 0 . 9 6 a s a p a r a m e t e r
w h e n r u n n i n g t h e m a i n d e m o .
R e - e x e c u t e i n L i n u x c o m m a n d m o d e a s f o l l o w s :
make clean
make
sudo ./main 0.96
P y t h o n ( f o r R a s p b e r r y P i )
W o r k s w i t h p y t h o n a n d p y t h o n 3
F o r p y t h o n , h i s c a l l s a r e n o t a s c o m p l i c a t e d a s C
R a s p b e r r y P i : R a s p b e r r y P i \ p y t h o n \ l i b \
l c d c o n f i g . p y
M o d u l e i n i t i a l i z a t i o n a n d e x i t p r o c e s s i n g .
def module_init()
def module_exit()
Note:
1. Here is some GPIO processing before and after using the LCD screen.
2. The module_init() function is automatically called in the INIT () initi
alizer on the LCD, but the module_exit() function needs to be called by it
self
G P I O r e a d a n d w r i t e :
def
digital_write(pin, value)
def
digital_read(pin)
S P I w r i t e d a t a .
def spi_writebyte(data)
x x x _ L C D _ t e s t . p y ( x x x i n d i c a t e s t h e s i z e , i f i t i s a 0 . 9 6 i n c h L C D , i t i s
0 i n c h 9 6 _ L C D _ t e s t . p y , a n d s o o n )
p y t h o n i s i n t h e f o l l o w i n g d i r e c t o r y :
R a s p b e r r y P i : R a s p b e r r y P i \ p y t h o n \ e x a m p l e s \
I f y o u r p y t h o n v e r s i o n i s p y t h o n 2 a n d y o u n e e d t o r u n t h e 0 . 9 6 i n c h L C D t e s t p r o g r a m , r e -
e x e c u t e i t a s f o l l o w s i n l i n u x c o m m a n d m o d e :
sudo python 0inch96_LCD_test.py
I f y o u r p y t h o n v e r s i o n i s p y t h o n 3 a n d y o u n e e d t o r u n t h e 0 . 9 6 i n c h L C D t e s t p r o g r a m , r e -
e x e c u t e t h e f o l l o w i n g i n l i n u x c o m m a n d m o d e :
sudo python3 0inch96_LCD_test.py
A b o u t R o t a t i o n S e t t i n g s
I f y o u n e e d t o s e t t h e s c r e e n r o t a t i o n i n t h e p y t h o n p r o g r a m , y o u c a n s e t i t b y t h e
s t a t e m e n t i m _ r = i m a g e 1 . r o t a t e ( 2 7 0 ) .
im_r= image1.rotate(270)
R o t a t i o n e f f e c t , t a k e 1 . 5 4 a s a n e x a m p l e , t h e o r d e r i s 0 ° , 9 0 ° , 1 8 0 ° , 2 7 0 °
G U I f u n c t i o n s
P y t h o n h a s a n i m a g e l i b r a r y
l o g i c a l l a y e r l i k e C , c a n d i r e c t l y c a l l t o t h e i m a g e l i b r a r y f o r i m a g e p r o c e s s i n g . T h e f o l l o w i n g
w i l l t a k e 1 . 5 4 i n c h L C D a s a n e x a m p l e , w e p r o v i d e a b r i e f d e s c r i p t i o n f o r t h e d e m o .
I t n e e d s t o u s e t h e i m a g e l i b r a r y a n d i n s t a l l t h e l i b r a r y .
sudo apt-get install python3-pil
A n d t h e n i m p o r t t h e l i b r a r y
from PIL import Image,ImageDraw,ImageFont.
A m o n g t h e m , I m a g e i s t h e b a s i c l i b r a r y , I m a g e D r a w i s t h e d r a w i n g f u n c t i o n , a n d
I m a g e F o n t i s t h e t e x t f u n c t i o n .
D e f i n e a n i m a g e c a c h e t o f a c i l i t a t e d r a w i n g , w r i t i n g a n d o t h e r f u n c t i o n s o n t h e p i c t u r e
image1 = Image.new("RGB", (disp.width, disp.height), "WHITE")
T h e f i r s t p a r a m e t e r d e f i n e s t h e c o l o r d e p t h o f t h e i m a g e , w h i c h i s d e f i n e d a s " 1 " t o i n d i c a t e
t h e b i t m a p o f o n e - b i t d e p t h . T h e s e c o n d p a r a m e t e r i s a t u p l e t h a t d e f i n e s t h e w i d t h a n d
h e i g h t o f t h e i m a g e . T h e t h i r d p a r a m e t e r d e f i n e s t h e d e f a u l t c o l o r o f t h e b u f f e r , w h i c h i s
d e f i n e d a s " W H I T E " .
C r e a t e a d r a w i n g o b j e c t b a s e d o n I m a g e 1 o n w h i c h a l l d r a w i n g o p e r a t i o n s w i l l b e
p e r f o r m e d o n h e r e .
draw = ImageDraw.Draw(image1)
D r a w l i n e .
draw.line([(20, 10),(70, 60)], fill = "RED",width = 1)
T h e f i r s t p a r a m e t e r i s a f o u r - e l e m e n t t u p l e s t a r t i n g a t ( 0 , 0 ) a n d e n d i n g a t ( 1 2 7 , 0 ) . D r a w a
l i n e . F i l l = " 0 " m e a n s t h e c o l o r o f t h e l i n e i s w h i t e .
D r a w r e c t a n g l e .
draw.rectangle([(20,10),(70,60)],fill = "WHITE",outline="BLACK")
T h e f i r s t a r g u m e n t i s a t u p l e o f f o u r e l e m e n t s . ( 2 0 , 1 0 ) i s t h e c o o r d i n a t e v a l u e i n t h e u p p e r
l e f t c o r n e r o f t h e r e c t a n g l e , a n d ( 7 0 , 6 0 ) i s t h e c o o r d i n a t e v a l u e i n t h e l o w e r r i g h t c o r n e r o f
t h e r e c t a n g l e . F i l l = " W H I T E " m e a n s B L A C K i n s i d e , a n d o u t l i n e = " B L A C K " m e a n s t h e c o l o r
o f t h e o u t l i n e i s b l a c k .
D r a w c i r c l e .
draw.arc((150,15,190,55),0, 360, fill =(0,255,0)
D r a w a n i n s c r i b e d c i r c l e i n t h e s q u a r e , t h e f i r s t p a r a m e t e r i s a t u p l e o f 4 e l e m e n t s , w i t h
( 1 5 0 , 1 5 ) a s t h e u p p e r l e f t c o r n e r v e r t e x o f t h e s q u a r e , ( 1 9 0 , 5 5 ) a s t h e l o w e r r i g h t c o r n e r
v e r t e x o f t h e s q u a r e , s p e c i f y i n g t h e l e v e l m e d i a n l i n e o f t h e r e c t a n g u l a r f r a m e i s t h e a n g l e
o f 0 d e g r e e s , t h e s e c o n d p a r a m e t e r i n d i c a t e s t h e s t a r t i n g a n g l e , t h e t h i r d p a r a m e t e r
i n d i c a t e s t h e e n d i n g a n g l e , a n d f i l l = 0 i n d i c a t e s t h a t t h e t h e c o l o r o f t h e l i n e i s w h i t e . I f
t h e f i g u r e i s n o t s q u a r e a c c o r d i n g t o t h e c o o r d i n a t i o n , y o u w i l l g e t a n e l l i p s e .
B e s i d e s t h e a r c f u n c t i o n , y o u c a n a l s o u s e t h e c h o r d f u n c t i o n f o r d r a w i n g s o l i d c i r c l e .
draw.ellipse((150,65,190,105), fill = 0)
T h e f i r s t p a r a m e t e r i s t h e c o o r d i n a t i o n o f t h e e n c l o s i n g r e c t a n g l e . T h e s e c o n d a n d t h i r d
p a r a m e t e r s a r e t h e b e g i n n i n g a n d e n d d e g r e e s o f t h e c i r c l e . T h e f o u r t h p a r a m e t e r i s t h e f i l l
c o l o r o f t h e c i r c l e .
C h a r a c t e r .
T h e I m a g e F o n t m o d u l e n e e d s t o b e i m p o r t e d a n d i n s t a n t i a t e d :
Font1 = ImageFont.truetype("../Font/Font01.ttf",25)
Font2 = ImageFont.truetype("../Font/Font01.ttf",35)
Font3 = ImageFont.truetype("../Font/Font02.ttf",32)
Y o u c a n u s e t h e f o n t s o f W i n d o w s o r o t h e r f o n t s w h i c h i s i n t t c f o r m a t . .
N o t e : E a c h c h a r a c t e r l i b r a r y c o n t a i n s d i f f e r e n t c h a r a c t e r s ; I f s o m e c h a r a c t e r s c a n n o t b e
d i s p l a y e d , i t i s r e c o m m e n d e d t h a t y o u c a n r e f e r t o t h e e n c o d i n g s e t r o u s e d . T o d r a w
E n g l i s h c h a r a c t e r , y o u c a n d i r e c t l y u s e t h e f o n t s ; f o r C h i n e s e c h a r a c t e r , y o u n e e d t o a d d a
s y m b o l u :
draw.text((40, 50), 'WaveShare', fill = (128,255,128),font=Font2)
text= u"微雪电子"
draw.text((74, 150),text, fill = "WHITE",font=Font3)
T h e f i r s t p a r a m e t e r i s a t u p l e o f 2 e l e m e n t s , w i t h ( 4 0 , 5 0 ) a s t h e l e f t v e r t e x , t h e f o n t i s
F o n t 2 , a n d t h e f i l l i s t h e f o n t c o l o r . Y o u c a n d i r e c t l y m a k e f i l l = " W H I T E " , b e c a u s e t h e
r e g u l a r c o l o r v a l u e i s a l r e a d y d e f i n e d W e l l , o f c o u r s e , y o u c a n a l s o u s e f i l l = ( 1 2 8 , 2 5 5 , 1 2 8 ) ,
t h e p a r e n t h e s e s c o r r e s p o n d t o t h e v a l u e s o f t h e t h r e e R G B c o l o r s s o t h a t y o u c a n p r e c i s e l y
c o n t r o l t h e c o l o r y o u w a n t . T h e s e c o n d s e n t e n c e s h o w s M i c r o S n o w E l e c t r o n i c s , u s i n g
F o n t 3 , t h e f o n t c o l o r i s w h i t e .
r e a d l o c a l i m a g e
image = Image.open('../pic/LCD_1inch28.jpg')
T h e p a r a m e t e r i s t h e i m a g e p a t h .
O t h e r f u n c t i o n s .
F o r m o r e i n f o r m a t i o n , y o u c a n r e f e r t o
U s i n g w i t h S T M 3 2
S o f t w a r e d e s c r i p t i o n
T h e d e m o i s d e v e l o p e d b a s e d o n t h e H A L l i b r a r y . D o w n l o a d t h e d e m o , f i n d t h e S T M 3 2
p r o g r a m f i l e d i r e c t o r y , a n d o p e n t h e L C D _ d e m o . u v p r o j x i n t h e
S T M 3 2 \ S T M 3 2 F 1 0 3 R B T 6 \ M D K - A R M d i r e c t o r y t o c h e c k t h e p r o g r a m .
O p e n m a i n . c , y o u c a n s e e a l l t h e t e s t p r o g r a m s , r e m o v e t h e c o m m e n t s i n f r o n t o f t h e
t e s t p r o g r a m s o n t h e c o r r e s p o n d i n g s c r e e n , a n d r e c o m p i l e a n d d o w n l o a d .
L C D _ 0 i n 9 6 _ t e s t ( ) 0 . 9 6 i n c h L C D t e s t p r o g r a m
L C D _ 1 i n 1 4 _ t e s t ( ) 1 . 1 4 i n c h L C D t e s t p r o g r a m
L C D _ 1 i n 2 8 _ t e s t ( ) 1 . 2 8 i n c h L C D t e s t p r o g r a m
L C D _ 1 i n 3 _ t e s t ( ) 1 . 3 i n c h L C D t e s t p r o g r a m
L C D _ 1 i n 5 4 _ t e s t ( ) 1 . 5 4 i n c h L C D t e s t p r o g r a m
L C D _ 1 i n 8 _ t e s t ( ) 1 . 8 i n c h L C D t e s t p r o g r a m
L C D _ 2 i n _ t e s t ( ) 2 i n c h L C D t e s t p r o g r a m
P r o g r a m d e s c r i p t i o n
U n d e r l y i n g h a r d w a r e i n t e r f a c e
D a t a t y p e
#define UBYTE
#define UWORD
#define UDOUBLE
M o d u l e i n i t i a l i z a t i o n a n d e x i t p r o c e s s i n g
UBYTE
System_Init(void);
void
System_Exit(void);
Note:
1.here is some GPIO processing before and after using the LCD screen.
2.After the System_Exit(void) function is used, the OLED display will be t
urned off;
W r i t e a n d r e a d G P I O
void
DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE
DEV_Digital_Read(UWORD Pin);
S P I w r i t e d a t a
UBYTE
SPI4W_Write_Byte(uint8_t value);
T h e U p p e r A p p l i c a t i o n
F o r t h e s c r e e n , i f y o u n e e d t o d r a w p i c t u r e s , d i s p l a y C h i n e s e a n d E n g l i s h c h a r a c t e r s ,
d i s p l a y p i c t u r e s , e t c . , y o u c a n u s e t h e u p p e r a p p l i c a t i o n t o d o , a n d w e p r o v i d e s o m e b a s i c
f u n c t i o n s h e r e a b o u t s o m e g r a p h i c s p r o c e s s i n g i n t h e d i r e c t o r y
S T M 3 2 \ S T M 3 2 F 1 0 3 R B \ U s e r \ G U I _ D E V \ G U I _ P a i n t . c ( . h )
N o t e : B e c a u s e o f t h e s i z e o f t h e i n t e r n a l R A M o f S T M 3 2 a n d a r d u i n o , t h e G U I i s d i r e c t l y
w r i t t e n t o t h e R A M o f t h e L C D .
T h e c h a r a c t e r f o n t w h i c h G U I d e p e n d e n t i s i n t h e d i r e c t o r y
S T M 3 2 \ S T M 3 2 F 1 0 3 R B \ U s e r \ F o n t s
N e w I m a g e P r o p e r t i e s : C r e a t e a n e w i m a g e p r o p e r t y , t h i s p r o p e r t y i n c l u d e s t h e i m a g e
b u f f e r n a m e , w i d t h , h e i g h t , f l i p A n g l e , c o l o r .
void Paint_NewImage(UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
Parameters:
Width: image buffer Width;
Height: the Height of the image buffer;
Rotate: Indicates the rotation Angle of an image
Color: the initial Color of the image;
S e t t h e c l e a r s c r e e n f u n c t i o n , u s u a l l y c a l l t h e c l e a r f u n c t i o n o f L C D d i r e c t l y .
void Paint_SetClearFuntion(void (*Clear)(UWORD));
parameter:
Clear : Pointer to the clear screen function, used to quickly clear th
e screen to a certain color;
S e t t h e d r a w i n g p i x e l f u n c t i o n
void Paint_SetDisplayFuntion(void (*Display)(UWORD,UWORD,UWORD));
parameter:
Display: Pointer to the pixel drawing function, which is used to write
data to the specified location in the internal RAM of the LCD;
S e l e c t i m a g e b u f f e r : t h e p u r p o s e o f t h e s e l e c t i o n i s t h a t y o u c a n c r e a t e m u l t i p l e i m a g e
a t t r i b u t e s , i m a g e b u f f e r c a n e x i s t m u l t i p l e , y o u c a n s e l e c t e a c h i m a g e y o u c r e a t e .
void Paint_SelectImage(UBYTE *image)
Parameters:
Image: the name of the image cache, which is actually a pointer to the
first address of the image buffer
I m a g e R o t a t i o n : S e t t h e s e l e c t e d i m a g e r o t a t i o n A n g l e , p r e f e r a b l y a f t e r
P a i n t _ S e l e c t I m a g e ( ) , y o u c a n c h o o s e t o r o t a t e 0 , 9 0 , 1 8 0 , 2 7 0 .
void Paint_SetRotate(UWORD Rotate)
Parameters:
Rotate: ROTATE_0, ROTATE_90, ROTATE_180, and ROTATE_270 correspond to
0, 90, 180, and 270 degrees respectively;
I m a g e m i r r o r f l i p : S e t t h e m i r r o r f l i p o f t h e s e l e c t e d i m a g e . Y o u c a n c h o o s e n o m i r r o r ,
h o r i z o n t a l m i r r o r , v e r t i c a l m i r r o r , o r i m a g e c e n t e r m i r r o r .
void Paint_SetMirroring(UBYTE mirror)
Parameters:
Mirror: indicates the image mirroring mode. MIRROR_NONE, MIRROR_HORIZO
NTAL, MIRROR_VERTICAL, MIRROR_ORIGIN correspond to no mirror, horizontal m
irror, vertical mirror, and about image center mirror respectively.
S e t p o i n t s o f d i s p l a y p o s i t i o n a n d c o l o r i n t h e b u f f e r : h e r e i s t h e c o r e G U I f u n c t i o n ,
p r o c e s s i n g p o i n t s d i s p l a y p o s i t i o n a n d c o l o r i n t h e b u f f e r .
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
Parameters:
Xpoint: the X position of a point in the image buffer
Ypoint: Y position of a point in the image buffer
Color: indicates the Color of the dot
I m a g e b u f f e r f i l l c o l o r : F i l l s t h e i m a g e b u f f e r w i t h a c o l o r , u s u a l l y u s e d t o f l a s h t h e
s c r e e n i n t o b l a n k .
void Paint_Clear(UWORD Color)
Parameters:
Color: fill Color
I m a g e b u f f e r p a r t o f t h e w i n d o w f i l l i n g c o l o r : t h e i m a g e b u f f e r p a r t o f t h e w i n d o w f i l l e d
w i t h a c e r t a i n c o l o r , g e n e r a l l y a s a w i n d o w w h i t e w a s h i n g f u n c t i o n , o f t e n u s e d f o r t i m e
d i s p l a y , w h i t e w a s h i n g o n a s e c o n d
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color)
Parameters:
Xstart: the x-starting coordinate of the window
Ystart: indicates the Y starting point of the window
Xend: the x-end coordinate of the window
Yend: indicates the y-end coordinate of the window
Color: fill Color
D r a w p o i n t s : I n t h e i m a g e b u f f e r , d r a w p o i n t s o n ( X p o i n t , Y p o i n t ) , y o u c a n c h o o s e t h e
c o l o r , t h e s i z e o f t h e p o i n t , t h e s t y l e o f t h e p o i n t .
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Do
t_Pixel, DOT_STYLE Dot_Style)
Parameters:
Xpoint: indicates the X coordinate of a point
Ypoint: indicates the Y coordinate of a point
Color: fill Color
Dot_Pixel: The size of the dot, providing a default of eight size poin
ts
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
Dot_Style: the size of a point that expands from the center of the poi
nt or from the bottom left corner of the point to the right and up
typedef enum {
DOT_FILL_AROUND
DOT_FILL_RIGHTUP,
} DOT_STYLE;
L i n e d r a w i n g : I n t h e i m a g e b u f f e r , l i n e f r o m ( X s t a r t , Y s t a r t ) t o ( X e n d , Y e n d ) , y o u c a n
c h o o s e t h e c o l o r , l i n e w i d t h , l i n e s t y l e .
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UW
ORD Color, LINE_STYLE Line_Style ,
Parameters:
Xstart: the x-starting coordinate of a line
Ystart: indicates the Y starting point of a line
Xend: x-terminus of a line
Yend: the y-end coordinate of a line
Color: fill Color
Line_width: The width of the line, which provides a default of eight w
idths
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
Line_Style: line style. Select whether the lines are joined in a strai
ght or dashed way
typedef enum {
LINE_STYLE_SOLID = 0,
LINE_STYLE_DOTTED,
} LINE_STYLE;
D r a w r e c t a n g l e : I n t h e i m a g e b u f f e r , d r a w a r e c t a n g l e f r o m ( X s t a r t , Y s t a r t ) t o ( X e n d ,
Y e n d ) , y o u c a n c h o o s e t h e c o l o r , t h e w i d t h o f t h e l i n e , w h e t h e r t o f i l l t h e i n s i d e o f t h e
r e c t a n g l e .
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color, DOT_PIXEL Line_width,
Parameters:
Xstart: the starting X coordinate of the rectangle
Ystart: indicates the Y starting point of the rectangle
Xend: X terminus of the rectangle
Yend: specifies the y-end coordinate of the rectangle
Color: fill Color
Line_width: The width of the four sides of a rectangle. Default ei
ght widths are provided
typedef enum {
} DOT_PIXEL;
Draw_Fill: Fill, whether to fill the inside of the rectangle
typedef enum {
} DRAW_FILL;
D r a w c i r c l e : I n t h e i m a g e b u f f e r , d r a w a c i r c l e o f R a d i u s w i t h ( X _ C e n t e r Y _ C e n t e r ) a s t h e
c e n t e r . Y o u c a n c h o o s e t h e c o l o r , t h e w i d t h o f t h e l i n e , a n d w h e t h e r t o f i l l t h e i n s i d e o f
t h e c i r c l e .
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD
Color, DOT_PIXEL Line_width,
Parameters:
X_Center: the x-coordinate of the center of a circle
Y_Center: Y coordinate of the center of a circle
Radius: indicates the Radius of a circle
Color: fill Color
Line_width: The width of the arc, with a default of 8 widths
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
Draw_Fill: fill, whether to fill the inside of the circle
typedef enum {
DRAW_FILL_EMPTY = 0,
DRAW_FILL_FULL,
} DRAW_FILL;
W r i t e A s c i i c h a r a c t e r : I n t h e i m a g e b u f f e r , a t ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a n
A s c i i c h a r a c t e r , y o u c a n s e l e c t A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r .
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFO
NT* Font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
Ascii_Char: indicates the Ascii character
Font: Ascii visual character library, in the Fonts folder provides the
following Fonts:
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e E n g l i s h s t r i n g : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a
s t r i n g o f E n g l i s h c h a r a c t e r s , c a n c h o o s e A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d
c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString,
sFONT* Font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PString: string, string is a pointer
Font: Ascii visual character library, in the Fonts folder provides the
following Fonts:
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e C h i n e s e s t r i n g : i n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a
s t r i n g o f C h i n e s e c h a r a c t e r s , y o u c a n c h o o s e G B 2 3 1 2 e n c o d i n g c h a r a c t e r f o n t , f o n t
f o r e g r o u n d c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString,
cFONT* font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PString: string, string is a pointer
Font: GB2312 encoding character Font library, in the Fonts folder prov
ides the following Fonts:
Font12CN: ASCII font 11*21, Chinese font 16*21
Font24CN: ASCII font24 *41, Chinese font 32*41
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e n u m b e r s : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a s t r i n g
o f n u m b e r s , y o u c a n c h o o s e A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r .
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Fon
t, UWORD Digit, UWORD Color_Foreground,
Parameters:
Xpoint: the x-coordinate of the left vertex of a character
Ypoint: the Y coordinate of the left vertex of the font
Nummber: indicates the number displayed, which can be a decimal
Digit: It's a decimal number
Font: Ascii visual character library, in the Fonts folder provides the
following Fonts:
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Color_Foreground: Font color
Color_Background: indicates the background color
D i s p l a y t i m e : i n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , d i s p l a y t i m e , y o u
c a n c h o o s e A s c i i v i s u a l c h a r a c t e r f o n t , f o n t f o r e g r o u n d c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT*
Font, UWORD Color_Background,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PTime: display time, here defined a good time structure, as long as th
e hour, minute and second bits of data to the parameter;
Font: Ascii visual character library, in the Fonts folder provides the
following Fonts:
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Color_Foreground: Font color
Color_Background: indicates the background color
A r d u i n o S o f t w a r e D e s c r i p t i o n
T e m p l a t e : A r d u i n o I D E I n s t a l l a t i o n S t e p s
N o t e : T h e d e m o s a r e a l l t e s t e d o n A r d u i n o u n o . I f y o u n e e d o t h e r t y p e s o f A r d u i n o , y o u
n e e d t o d e t e r m i n e w h e t h e r t h e c o n n e c t e d p i n s a r e c o r r e c t .
R u n p r o g r a m
I n t h e p r o d u c t e n c y c l o p e d i a i n t e r f a c e d o w n l o a d
A r d u i n o p r o g r a m i s l o c a t e d a t ~ / A r d u i n o / ...
P l e a s e s e l e c t t h e c o r r e s p o n d i n g p r o g r a m a c c o r d i n g t o t h e L C D s c r e e n m o d e l t o o p e n
Y o u c a n v i e w t e s t p r o g r a m s f o r a l l s c r e e n s i z e s , s o r t e d b y s i z e :
F o r e x a m p l e , 1 . 5 4 i n c h L C D M o d u l e . O p e n t h e L C D _ 1 i n c h 5 4 f o l d e r a n d r u n t h e
L C D _ 1 i n c h 5 4 . i n o f i l e .
O p e n t h e p r o g r a m , s e l e c t t h e d e v e l o p m e n t b o a r d m o d e l A r d u i n o U N O
S e l e c t t h e c o r r e s p o n d i n g C O M p o r t
T h e n c l i c k t o c o m p i l e a n d d o w n l o a d
P r o g r a m D e s c r i p t i o n
D o c u m e n t I n t r o d u c t i o n
T a k e A r d u i n o U N O c o n t r o l l i n g a 1 . 5 4 - i n c h L C D a s a n e x a m p l e , o p e n t h e
A r d u i n o \ L C D _ 1 i n c h 5 4 d i r e c t o r y :
O f w h i c h :
L C D _ 1 i n c h 5 4 . i n o : o p e n w i t h A r d u i n o I D E ;
L C D _ D r i v e r . c p p ( . h ) : i s t h e d r i v e r o f t h e L C D s c r e e n ;
D E V _ C o n f i g . c p p ( . h ) : I t i s t h e h a r d w a r e i n t e r f a c e d e f i n i t i o n , w h i c h e n c a p s u l a t e s t h e r e a d
a n d w r i t e p i n l e v e l s , S P I t r a n s m i s s i o n d a t a , a n d p i n i n i t i a l i z a t i o n ;
f o n t 8 . c p p , f o n t 1 2 . c p p , f o n t 1 6 . c p p , f o n t 2 0 . c p p , f o n t 2 4 . c p p , f o n t 2 4 C N . c p p , f o n t s . h : f o n t s f o r
c h a r a c t e r s o f d i f f e r e n t s i z e s ;
i m a g e . c p p ( . h ) : i s t h e i m a g e d a t a , w h i c h c a n c o n v e r t a n y B M P i m a g e i n t o a 1 6 - b i t t r u e c o l o r
i m a g e a r r a y t h r o u g h I m g 2 L c d ( d o w n l o a d a b l e i n t h e d e v e l o p m e n t d a t a ) .
T h e p r o g r a m i s d i v i d e d i n t o b o t t o m - l a y e r h a r d w a r e i n t e r f a c e , m i d d l e - l a y e r L C D s c r e e n
d r i v e r , a n d u p p e r - l a y e r a p p l i c a t i o n ;
U n d e r l y i n g h a r d w a r e i n t e r f a c e
T h e h a r d w a r e i n t e r f a c e i s d e f i n e d i n t h e t w o f i l e s D E V _ C o n f i g . c p p ( . h ) , a n d f u n c t i o n s s u c h
a s r e a d a n d w r i t e p i n l e v e l , d e l a y , a n d S P I t r a n s m i s s i o n a r e e n c a p s u l a t e d .
w r i t e p i n l e v e l
void DEV_Digital_Write(int pin, int value)
T h e f i r s t p a r a m e t e r i s t h e p i n , a n d t h e s e c o n d i s t h e h i g h a n d l o w l e v e l .
R e a d p i n l e v e l
int DEV_Digital_Read(int pin)
T h e p a r a m e t e r i s t h e p i n , a n d t h e r e t u r n v a l u e i s t h e l e v e l o f t h e r e a d p i n .
D e l a y
DEV_Delay_ms(unsigned int delaytime)
m i l l i s e c o n d l e v e l d e l a y .
S P I o u t p u t d a t a
DEV_SPI_WRITE(unsigned char data)
T h e p a r a m e t e r i s c h a r t y p e , o c c u p y i n g 8 b i t s .
T h e u p p e r a p p l i c a t i o n
F o r t h e s c r e e n , i f y o u n e e d t o d r a w p i c t u r e s , d i s p l a y C h i n e s e a n d E n g l i s h c h a r a c t e r s ,
d i s p l a y p i c t u r e s , e t c . , y o u c a n u s e t h e u p p e r a p p l i c a t i o n t o d o , a n d w e p r o v i d e s o m e b a s i c
f u n c t i o n s h e r e a b o u t s o m e g r a p h i c s p r o c e s s i n g i n t h e d i r e c t o r y G U I _ P a i n t . c ( . h )
N o t e : B e c a u s e o f t h e s i z e o f t h e i n t e r n a l R A M o f S T M 3 2 a n d a r d u i n o , t h e G U I i s d i r e c t l y
w r i t t e n t o t h e R A M o f t h e L C D .
T h e f o n t s u s e d b y t h e G U I a l l d e p e n d o n t h e f o n t * . c p p ( h ) f i l e s u n d e r t h e s a m e f i l e
N e w I m a g e P r o p e r t i e s : C r e a t e a n e w i m a g e p r o p e r t y , t h i s p r o p e r t y i n c l u d e s t h e i m a g e
b u f f e r n a m e , w i d t h , h e i g h t , f l i p A n g l e , c o l o r .
void Paint_NewImage(UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
Parameters:
Width: image buffer Width;
Height: the Height of the image buffer;
Rotate: Indicates the rotation Angle of an image
Color: the initial Color of the image;
S e t t h e c l e a r s c r e e n f u n c t i o n , u s u a l l y c a l l t h e c l e a r f u n c t i o n o f L C D d i r e c t l y .
void Paint_SetClearFuntion(void (*Clear)(UWORD));
parameter:
Clear : Pointer to the clear screen function, used to quickly clear th
e screen to a certain color;
S e t t h e d r a w i n g p i x e l f u n c t i o n .
void Paint_SetDisplayFuntion(void (*Display)(UWORD,UWORD,UWORD));
parameter:
Display: Pointer to the pixel drawing function, which is used to write
data to the specified location in the internal RAM of the LCD;
S e l e c t i m a g e b u f f e r : t h e p u r p o s e o f t h e s e l e c t i o n i s t h a t y o u c a n c r e a t e m u l t i p l e i m a g e
a t t r i b u t e s , i m a g e b u f f e r c a n e x i s t m u l t i p l e , y o u c a n s e l e c t e a c h i m a g e y o u c r e a t e .
void Paint_SelectImage(UBYTE *image)
Parameters:
Image: the name of the image cache, which is actually a pointer to the
first address of the image buffer
I m a g e R o t a t i o n : S e t t h e s e l e c t e d i m a g e r o t a t i o n A n g l e , p r e f e r a b l y a f t e r
P a i n t _ S e l e c t I m a g e ( ) , y o u c a n c h o o s e t o r o t a t e 0 , 9 0 , 1 8 0 , 2 7 0 .
void Paint_SetRotate(UWORD Rotate)
Parameters:
Rotate: ROTATE_0, ROTATE_90, ROTATE_180, and ROTATE_270 correspond to
0, 90, 180, and 270 degrees respectively;
I m a g e m i r r o r f l i p : S e t t h e m i r r o r f l i p o f t h e s e l e c t e d i m a g e . Y o u c a n c h o o s e n o m i r r o r ,
h o r i z o n t a l m i r r o r , v e r t i c a l m i r r o r , o r i m a g e c e n t e r m i r r o r .
void Paint_SetMirroring(UBYTE mirror)
Parameters:
Mirror: indicates the image mirroring mode. MIRROR_NONE, MIRROR_HORIZO
NTAL, MIRROR_VERTICAL, MIRROR_ORIGIN correspond to no mirror, horizontal m
irror, vertical mirror, and about image center mirror respectively.
S e t p o i n t s o f d i s p l a y p o s i t i o n a n d c o l o r i n t h e b u f f e r : h e r e i s t h e c o r e G U I f u n c t i o n ,
p r o c e s s i n g p o i n t s d i s p l a y p o s i t i o n a n d c o l o r i n t h e b u f f e r .
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
Parameters:
Xpoint: the X position of a point in the image buffer
Ypoint: Y position of a point in the image buffer
Color: indicates the Color of the dot
I m a g e b u f f e r f i l l c o l o r : F i l l s t h e i m a g e b u f f e r w i t h a c o l o r , u s u a l l y u s e d t o f l a s h t h e
s c r e e n i n t o b l a n k .
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color)
Parameters:
Xstart: the x-starting coordinate of the window
Ystart: indicates the Y starting point of the window
Xend: the x-end coordinate of the window
Yend: indicates the y-end coordinate of the window
Color: fill Color
D r a w p o i n t s : I n t h e i m a g e b u f f e r , d r a w p o i n t s o n ( X p o i n t , Y p o i n t ) , y o u c a n c h o o s e t h e
c o l o r , t h e s i z e o f t h e p o i n t , t h e s t y l e o f t h e p o i n t .
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Do
t_Pixel, DOT_STYLE Dot_Style)
Parameters:
Xpoint: indicates the X coordinate of a point
Ypoint: indicates the Y coordinate of a point
Color: fill Color
Dot_Pixel: The size of the dot, providing a default of eight size poin
ts
typedef enum {
} DOT_PIXEL;
Dot_Style: the size of a point that expands from the center of the poi
nt or from the bottom left corner of the point to the right and up
typedef enum {
} DOT_STYLE;
L i n e d r a w i n g : I n t h e i m a g e b u f f e r , l i n e f r o m ( X s t a r t , Y s t a r t ) t o ( X e n d , Y e n d ) , y o u c a n
c h o o s e t h e c o l o r , l i n e w i d t h , l i n e s t y l e .
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UW
ORD Color, LINE_STYLE Line_Style ,
Parameters:
Xstart: the x-starting coordinate of a line
Ystart: indicates the Y starting point of a line
Xend: x-terminus of a line
Yend: the y-end coordinate of a line
Color: fill Color
Line_width: The width of the line, which provides a default of eig
ht widths
Line_Style: line style. Select whether the lines are joined in a s
traight or dashed way
D r a w r e c t a n g l e : I n t h e i m a g e b u f f e r , d r a w a r e c t a n g l e f r o m ( X s t a r t , Y s t a r t ) t o ( X e n d ,
Y e n d ) , y o u c a n c h o o s e t h e c o l o r , t h e w i d t h o f t h e l i n e , w h e t h e r t o f i l l t h e i n s i d e o f t h e
r e c t a n g l e .
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color, DOT_PIXEL Line_width,
Parameters:
Xstart: the starting X coordinate of the rectangle
Ystart: indicates the Y starting point of the rectangle
Xend: X terminus of the rectangle
Yend: specifies the y-end coordinate of the rectangle
Color: fill Color
Line_width: The width of the four sides of a rectangle. Default ei
ght widths are provided
typedef enum {
} DOT_PIXEL;
Draw_Fill: Fill, whether to fill the inside of the rectangle
typedef enum {
} DRAW_FILL;
D r a w c i r c l e : I n t h e i m a g e b u f f e r , d r a w a c i r c l e o f R a d i u s w i t h ( X _ C e n t e r Y _ C e n t e r ) a s t h e
c e n t e r . Y o u c a n c h o o s e t h e c o l o r , t h e w i d t h o f t h e l i n e , a n d w h e t h e r t o f i l l t h e i n s i d e o f
t h e c i r c l e .
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD
Color, DOT_PIXEL Line_width,
Parameters:
X_Center: the x-coordinate of the center of a circle
Y_Center: Y coordinate of the center of a circle
Radius: indicates the Radius of a circle
Color: fill Color
Line_width: The width of the arc, with a default of 8 widths
typedef enum {
} DOT_PIXEL;
Draw_Fill: fill, whether to fill the inside of the circle
typedef enum {
} DRAW_FILL;
W r i t e A s c i i c h a r a c t e r : I n t h e i m a g e b u f f e r , a t ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a n
A s c i i c h a r a c t e r , y o u c a n s e l e c t A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r .
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFO
NT* Font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
Ascii_Char: indicates the Ascii character
Font: Ascii visual character library, in the Fonts folder provides
the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e E n g l i s h s t r i n g : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a
s t r i n g o f E n g l i s h c h a r a c t e r s , c a n c h o o s e A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d
c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString,
sFONT* Font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PString: string, string is a pointer
Font: Ascii visual character library, in the Fonts folder provides
the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e C h i n e s e s t r i n g : i n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a
s t r i n g o f C h i n e s e c h a r a c t e r s , y o u c a n c h o o s e G B 2 3 1 2 e n c o d i n g c h a r a c t e r f o n t , f o n t
f o r e g r o u n d c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString,
cFONT* font, UWORD Color_Foreground,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PString: string, string is a pointer
Font: GB2312 encoding character Font library, in the Fonts folder
provides the following Fonts:
W r i t e n u m b e r s : I n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a s t r i n g
o f n u m b e r s , y o u c a n c h o o s e A s c i i v i s u a l c h a r a c t e r l i b r a r y , f o n t f o r e g r o u n d c o l o r , f o n t
b a c k g r o u n d c o l o r .
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Fon
t, UWORD Digit, UWORD Color_Foreground,
Parameters:
Xpoint: the x-coordinate of the left vertex of a character
Ypoint: the Y coordinate of the left vertex of the font
Nummber: indicates the number displayed, which can be a decimal
Digit: It's a decimal number
Font: Ascii visual character library, in the Fonts folder provides
the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
W r i t e n u m b e r s w i t h d e c i m a l s : a t ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , w r i t e a s t r i n g o f
n u m b e r s w i t h d e c i m a l s , y o u c a n c h o o s e A s c i i c o d e v i s u a l c h a r a c t e r f o n t , f o n t f o r e g r o u n d
c o l o r , f o n t b a c k g r o u n d c o l o r
void Paint_DrawFloatNum(UWORD Xpoint, UWORD Ypoint, double Nummber, UBYTE
Decimal_Point, sFONT* Font, UWORD Color_Foreground, UWORD Color_Backgroun
d);
parameter:
Xstart: the X coordinate of the left vertex of the character
Ystart: Y coordinate of the left vertex of the font
Nummber: the displayed number, which is saved in double type here
Decimal_Point: Displays the number of digits after the decimal po
int
Font: Ascii code visual character font library, the following fon
ts are provided in the Fonts folder:
Color_Foreground: font color
Color_Background: background color
D i s p l a y t i m e : i n t h e i m a g e b u f f e r , u s e ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , d i s p l a y t i m e , y o u
c a n c h o o s e A s c i i v i s u a l c h a r a c t e r f o n t , f o n t f o r e g r o u n d c o l o r , f o n t b a c k g r o u n d c o l o r .
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT*
Font, UWORD Color_Background,
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
PTime: display time, here defined a good time structure, as long a
s the hour, minute and second bits of data to the parameter;
Font: Ascii visual character library, in the Fonts folder provides
the following Fonts:
Color_Foreground: Font color
Color_Background: indicates the background color
D i s p l a y i m a g e : a t ( X s t a r t Y s t a r t ) a s t h e l e f t v e r t e x , d i s p l a y a n i m a g e w h o s e w i d t h i s
W _ I m a g e a n d h e i g h t i s H _ I m a g e ;
void Paint_DrawImage(const unsigned char *image, UWORD xStart, UWORD yStar
t, UWORD W_Image, UWORD H_Image)
parameter:
image: image address, pointing to the image information you want to
display
Xstart: the X coordinate of the left vertex of the character
Ystart: Y coordinate of the left vertex of the font
W_Image: Image width
H_Image: Image height
V i s i o n F i v e 2
A d a p t i v e M o d e l
0 . 9 6 i n c h L C D M o d u l e
1 . 1 4 i n c h L C D M o d u l e
1 . 2 8 i n c h L C D M o d u l e
1 . 3 i n c h L C D M o d u l e
1 . 5 4 i n c h L C D M o d u l e
1 . 8 i n c h L C D M o d u l e
2 i n c h L C D M o d u l e
2 . 4 i n c h L C D M o d u l e
H a r d w a r e C o n n e c t i o n
V i s i o n F i v e 2 P i n C o n n e c t i o n
L C D
V C C
G N D
D I N
C L K
C S
D C
R S T
B L
I n s t a l l C o r r e s p o n d i n g L i b r a r i e s
apt-get install pip
pip install VisionFive.gpio
apt-get install python3-numpy
apt-get install python3-pil
D e m o D o w n l o a d
apt-get install p7zip-full
wget https://www.waveshare.com/w/upload/e/e9/LCD_Module_code.7z
7z x LCD_Module_code.7z -o./LCD_Module_code
cd LCD_Module_code/VisionFive/python/example/
R u n t h e C o r r e s p o n d i n g D e m o A c c o r d i n g t o t h e S c r e e n Y o u
P u r c h a s e d
python3 0inch96_LCD_test.py
python3 1inch14_LCD_test.py
python3 1inch28_LCD_test.py
python3 1inch3_LCD_test.py
python3 1inch54_LCD_test.py
python3 1inch8_LCD_test.py
python3 2inch_LCD_test.py
python3 2inch4_LCD_test.py
R e s o u r c e s
U s e r M a n u a l
S c h e m a t i c
P r o g r a m
E x a m p l e p r o g r a m s
S o f t w a r e
l c d
I m a g e 2 L c d
D a t a s h e e t
S T 7 7 8 9 V W
F A Q
Q u e s t i o n :
W h y d o e s n ' t t h e s c r e e n d i s p l a y p r o p e r l y w h e n c o n n e c t e d t o a n
A r d u i n o ?
A n s w e r :
W h e n u s i n g a n A r d u i n o , p l e a s e m a k e s u r e i t i s p l u g g e d i n t o a 5 v p o w e r s u p p l y .
( P l e a s e e n s u r e t h a t t h e p o w e r s u p p l y v o l t a g e a n d l o g i c
(
)
(
H
x 2 3 . 4
V
(
)
(
H
x 0 . 0 9 7 5
( P l e a s e c o n n e c t a c c o r d i n g t o t h e p i n d e f i n i t i o n t a b l e . T h e
L C D
V C C
G N D
D I N
C L K
C S
D C
R S T
B L
L C D
V C C
G N D
D I N
C L K
C S
D C
R S T
B L
:
uint8_t
uint16_t
uint32_t
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
typedef enum {
DOT_FILL_AROUND
DOT_FILL_RIGHTUP,
} DOT_STYLE;
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
typedef enum {
LINE_STYLE_SOLID = 0,
LINE_STYLE_DOTTED,
} LINE_STYLE;
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
typedef enum {
DRAW_FILL_EMPTY = 0,
DRAW_FILL_FULL,
} DRAW_FILL;
DRAW_FILL Draw_Fill)
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
typedef enum {
DRAW_FILL_EMPTY = 0,
DRAW_FILL_FULL,
} DRAW_FILL;
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font12CN: ASCII font 11*21, Chinese font 16*21
Font24CN: ASCII font24 *41, Chinese font 32*41
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
P I L o f f i c i a l l i b r a r y l i n k
uint8_t
uint16_t
uint32_t
= 1,
,
,
,
,
,
,
,
= 1,
= 1,
,
,
,
,
,
,
,
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
DRAW_FILL_EMPTY = 0,
DRAW_FILL_FULL,
DRAW_FILL Draw_Fill)
= 1,
,
,
,
,
,
,
,
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
DOT_FILL_AROUND
DOT_FILL_RIGHTUP,
typedef enum {
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
} DOT_PIXEL;
typedef enum {
LINE_STYLE_SOLID = 0,
LINE_STYLE_DOTTED,
} LINE_STYLE;
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
DRAW_FILL_EMPTY = 0,
DRAW_FILL_FULL,
DRAW_FILL Draw_Fill)
DOT_PIXEL_1X1
DOT_PIXEL_2X2
DOT_PIXEL_3X3
DOT_PIXEL_4X4
DOT_PIXEL_5X5
DOT_PIXEL_6X6
DOT_PIXEL_7X7
DOT_PIXEL_8X8
DRAW_FILL_EMPTY = 0,
DRAW_FILL_FULL,
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font12CN: ASCII font 11*21, Chinese font 16*21
Font24CN: ASCII font24 *41, Chinese font 32*41
Color_Foreground: Font color
Color_Background: indicates the background color
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
Font8: 5*8 font
Font12: 7*12 font
Font16: 11*16 font
Font20: 14*20 font
Font24: 17*24 font
)
m m
)
V
m m
R a s p b e r r y P i
B C M 2 8 3 5
3 . 3 V
G N D
M O S I
S C L K
C E 0
2 5
2 7
1 8
d e v e l o p e d b y o u r c o m p a n y a s a n
to enable SPI interface
= 1,
// 1 x 1
,
,
,
,
,
,
,
= 1,
LINE_STYLE Line_Style)
= 1,
// 1 x 1
,
,
,
,
,
,
,
DRAW_FILL Draw_Fill)
= 1,
,
,
,
,
,
,
,
= 1,
,
,
,
,
,
,
,
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Foreground)
, i t d o n o t n e e d t o w r i t e c o d e f r o m t h e
h t t p : / / e f f b o t . o r g / i m a g i n g b o o k
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
LINE_STYLE Line_Style)
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
DRAW_FILL Draw_Fill)
= 1,
// 1 x 1
,
,
,
,
,
,
,
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Foreground)
t h e p r o g r a m
= 1,
,
,
,
,
,
,
,
= 1,
LINE_STYLE Line_Style)
= 1,
,
,
,
,
,
,
,
DRAW_FILL Draw_Fill)
= 1,
,
,
,
,
,
,
,
= 1,
,
,
,
,
,
,
,
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Background)
UWORD Color_Foreground)
V i s i o n F i v e 2 B o a r d P i n N o .
3 . 3 V
G N D
1 9
2 3
2 4
2 2
1 3
1 2
1 . 3 i n c h L C D M o d u l e
R e s o l u t i o n : 2 4 0 x 2 4 0
S T M 3 2
3 . 3 V
G N D
P A 7
P A 5
P B 6
P A 8
P A 9
P C 7
U N O
5 V
G N D
D 1 1
D 1 3
D 1 0
D 7
D 8
D 9
BCM2835 or Wi
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
p i l
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
, a n d t h e n u n z i p i t . T h e
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
// 1 x 1
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
B o a r d
3 . 3 V
G N D
1 9
2 3
2 4
2 2
1 3
1 2
Need help?
Do you have a question about the B09QG49MG8 and is the answer not in the manual?
Questions and answers