Download Print this page

Waveshare B0BWJBG98D Manual

1.28inch touch lcd

Advertisement

Quick Links

1 . 2 8 i n c h T o u c h L C D
O v e r v i e w
I n t r o d u c t i o n
W e p r o v i d e d e m o s o f R a s p b e r r y P i , R a s p b e r r y P i P i c o , S T M 3 2 ,
a n d A r d u i n o f o r t h i s p r o d u c t .
P a r a m e t e r s
O p e r a t i n g
3 . 3 V / 5 V
v o l t a g e
L C D c o n t r o l l e r
G C 9 A 0 1
T o u c h
C S T 8 1 6 S
c o n t r o l l e r
D i s p l a y p a n e l
I P S
D i s p l a y
Φ
d i m e n s i o n s
D i m e n s i o n s
3 9 . 1 5 × 3 7 m m
P l e a s e m a k e s u r e t h e p o w e r s u p p l y i s a s s a m e a s t h e l o g i c l e v e l , o r i t m a y c a u s e
a b n o r m a l o p e r a t i o n .
I n t e r f a c e D e s c r i p t i o n
P i n
V C C
G N D
M I S O
M O S I
S C L K
L C S _ C S
L C S _ D C
L C S _ R S T
L C S _ B L
T P _ S D A
T P _ S C L
T P _ I N T
T P _ R S T
L C D a n d C o n t r o l l e r
T h i s L C D a d o p t s b u i l t - i n d r i v e r G C 9 A 0 1 w i t h a r e s o l u t i o n o f 2 4 0 R G B × 2 4 0 d o t s , w h i c h
h a s a n i n t e r n a l G R A M o f 1 2 9 , 6 0 0 b y t e s . I t s u p p o r t s M C U p o r t w i t h 1 2 / 1 6 / 1 8 d a t a b u s ,
t h a t i s , t h e c o m m o n R G B f o r m a t o f R G B 4 4 4 , R G B 5 6 5 , a n d R G B 6 6 6 .
F o r m o s t L C D c o n t r o l l e r s , t h e c o m m u n i c a t i o n m o d e o f t h e c o n t r o l l e r c a n b e c o n f i g u r e d ,
u s u a l l y w i t h a n 8 0 8 0 p a r a l l e l i n t e r f a c e , t h r e e - w i r e S P I , f o u r - w i r e S P I , a n d o t h e r
c o m m u n i c a t i o n m e t h o d s . T h i s 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 G P I O p o r t s , 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 .
S o m e f r i e n d s m a y h a v e d o u b t s , t h e s c r e e n i s c i r c u l a r , s o w h i c h p o i n t i s t h e f i r s t p i x e l o f
t h e s c r e e n ? H o w t o d e t e r m i n e t h e c o o r d i n a t e s ?
I n f a c t , y o u c a n u n d e r s t a n d i t a s a s q u a r e s c r e e n w i t h a n i n s c r i b e d c i r c l e d r a w n
i n s i d e . W e o n l y d i s p l a y c o n t e n t i n t h i s i n s c r i b e d c i r c l e , a n d t h e p i x e l s i n o t h e r
p o s i t i o n s a r e d i r e c t l y d i s c a r d e d . M o s t o f t h e c i r c u l a r L C D s o n t h e m a r k e t a r e t h e
s a m e .
S P I 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 : T h e d i f f e r e n c e 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 i s t h a t t h e d a t a l i n e s e n t f r o m t h e
s l a v e t o t h e h o s t i s h i d d e n b e c a u s e i t o n l y n e e d s t o b e d i s p l a y e d . P l e a s e r e f e r t o
D a t a s h e e t P a g e 1 0 5 f o r t h e t a b l e .
R E S X i s r e s e t , i t i s p u l l e d l o w w h e n t h e m o d u l e i s p o w e r e d o n , u s u a l l y s e t t o 1 .
C S X i s t h e s l a v e c h i p s e l e c t i o n , a n d t h e c h i p w i l l b e e n a b l e d o n l y w h e n C S i s l o w .
D / C X i s t h e d a t a / c o m m a n d c o n t r o l p i n o f t h e c h i p , 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 t r a n s m i t t e d d a t a , t h a t i s , R G B d a t a .
S C L i s t h e S P I c o m m u n i c a t i o n c l o c k .
F o r S P I c o m m u n i c a t i o n , d a t a i s t r a n s m i t t e d w i t h t i m i n g , t h a t i s , t h e c o m b i n a t i o n o f c l o c k
p h a s e ( C P H A ) a n d c l o c k p o l a r i t y ( C P O L ) .
T h e l e v e l o f C P H A d e t e r m i n e s w h e t h e r t h e s e r i a l s y n c h r o n i z a t i o n c l o c k i s c o l l e c t e d o n
t h e f i r s t c l o c k t r a n s i t i o n e d g e o r t h e s e c o n d c l o c k t r a n s i t i o n e d g e . W h e n C P H A = 0 , d a t a
a c q u i s i t i o n i s p e r f o r m e d o n t h e f i r s t t r a n s i t i o n e d g e .
T h e l e v e l o f C P O L d e t e r m i n e s t h e i d l e s t a t 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 . C P O L =
0 , w h i c h i s a l o w l e v e l .
A s c a n b e s e e n f r o m t h e f i g u r e , w h e n t h e f i r s t f a l l i n g e d g e o f S C L K s t a r t s t o t r a n s m i t
d a t a , 8 - b i t d a t a i s t r a n s m i t t e d i n o n e c l o c k c y c l e , u s i n g S P I 0 , b i t - b y - b i t t r a n s m i s s i o n ,
h i g h - o r d e r f i r s t , a n d l o w - o r d e r l a s t .
T o u c h a n d C o n t r o l l e r
1 . 2 8 - i n c h T o u c h L C D i s c o m p o s e d o f s u r f a c e t o u g h e n e d g l a s s + t h i n f i l m F I L M m a t e r i a l ,
w h i c h h a s h i g h s t r e n g t h , s t r o n g h a r d n e s s , a n d g o o d l i g h t t r a n s m i t t a n c e . T h e m a t c h i n g
d r i v e r c h i p i s C S T 8 1 6 S s e l f - c a p a c i t a n c e t o u c h c h i p , w h i c h s u p p o r t s t h e s t a n d a r d I 2 C
c o m m u n i c a t i o n p r o t o c o l s t a n d a r d , w h i c h c a n r e a l i z e 1 0 K h z ~ 4 0 0 K h z c o n f i g u r a b l e
c o m m u n i c a t i o n r a t e .
I 2 C C o m m u n i c a t i o n P r o t o c o l
T h e 7 - b i t d e v i c e a d d r e s s o f t h e c h i p i s 0 x 1 5 , t h a t i s , t h e d e v i c e w r i t i n g a d d r e s s i s 0 x 2 A ,
a n d r e a d i n g a d d r e s s i s 0 x 2 B .
W a v e f o r m i n t r o d u c t i o n :
W r i t e a s i n g l e b y t e : ( w r i t e 0 x 0 1 t o 0 x 1 F r e g i s t e r )
W r i t e m u l t i p l e b y t e s c o n s e c u t i v e l y ( w r i t e 0 x 2 0 , 0 x 0 1 t o 0 x 1 E a n d 0 x 1 F
r e s p e c t i v e l y )
R e a d a s i n g l e b y t e ( r e a d a s i n g l e b y t e f r o m 0 x 2 1 )
R e a d m u l t i p l e b y t e s c o n s e c u t i v e l y ( r e a d 3 b y t e s f r o m 0 x 2 1 , 0 x 2 2 , 0 x 2 3 )
R a s p b e r r y P i U s e r M a n u a l
H a r d w a r e C o n n e c t i o n
E x a m p l e
E n a b l e d S P I a n d I 2 C I n t e r f a c e
O p e n R a s p b e r r y P i a n d e n t e r t h e f o l l o w i n g c o m m a n d s i n t h e c o n f i g i n t e r f a c e .
sudo raspi-config
Choose Interfacing Options -> SPI -> Yes Enable SPI interface
Choose Interfacing Options -> I2C -> Yes Enable I2C interface
A n d t h e n r e b o o t t h e 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 S P I h a s n o t b e e n o c c u p i e d b y o t h e r d e v i c e s , a n d y o u c a n c h e c k i t i n
/ 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 y
W i r i n g P i
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
# Run gpio -v and version 2.70 will appear. If it does not appear, it mean
s that there is an error in the installation
P y t h o n
#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 smbus
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 smbus
sudo pip3 install spidev
D o w n l o a d T e s t D e m o
O p e n t h e R a s p b e r r y P i , a n d e x e c u t e :
sudo apt-get install unzip -y
cd ~
sudo wget https://www.waveshare.com/w/upload/f/fb/1.28inch_Touch_LCD_RPI.z
ip
sudo unzip ./1.28inch_Touch_LCD_RPI.zip
cd 1.28inch_Touch_LCD_RPI
R u n T e s t D e m o
E x e c u t e t h e f o l l o w i n g c o m m a n d s i n t h e R a s p b e r r y P i , o t h e r w i s e , y o u c a n n o t f i n d 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 .
C
C o m p i l e i t a g a i n a n d i t m a y t a k e a f e w s e c o n d s :
cd ~
cd 1.28inch_Touch_LCD_RPI/c
sudo make clean
sudo make -j
sudo ./main
P y t h o n
cd ~
cd 1.28inch_Touch_LCD_RPI/python/examples
sudo python 1inch28_LCD_test.py
R u n t h e d e m o c o r r e s p o n d i n g t o t h e s c r e e n , a n d t h e d e m o s u p p o r t s p y t h o n 2 / 3 .
A P I ( C a n d P y t h o n a r e o p t i o n a l )
R a s p b e r r y P i s e r i e s c a n u s e t h e s a m e d e m o a s t h e y h a v e e m b e d d e d s y s t e m s w i t h h i g h
c o m p a t i b i l i t y .
T h e d e m o h a s t h r e e p a r t s : t h e u n d e r l a y e r h a r d w a r e i n t e r f a c e , t h e m i d d l e L C D d r i v e r , a n d
t h e u p p e r a p p l i c a t i o n .
C
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
W e h a v e c a r r i e d o u t t h e b o t t o m l a y e r p a c k a g e , 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 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 a r e 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,
and Dev library respectively.
2. WiringPi library is used by default as there is no external interrupt i
n BCM2835 and Dev library.
D a t a t y p e :
#define UBYTE
#define UWORD
#define UDOUBLE uint32_t
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 :
void DEV_Module_Init(void);
void DEV_Module_Exit(void);
Note:
1. Here is how to address GPIO before or after using the LCD.
G P I O r e a d / w r i t e
void
DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE
DEV_Digital_Read(UWORD Pin);
S P I r e a d a n d 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 , 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 . ,
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 , a n d 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;
C h o o s e I m a g e b u f f e r : c h o o s e I m a g e b u f f e r f o r c r e a t i n g m o r e i m a g e p r o p e r t i e s . T h e
i m a g e b u f f e r c a n b e v a r i e d , a n d y o u c a n c h o o s e t h e i m a g e y o u c r e a t e d .
void Paint_SelectImage(UBYTE *image)
Parameter:
image: the name of the image buffer is actually a pointer to it
s first address.
S e t 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 o f t h e p o i n t i n t h e b u f f e r : h e r e i s t h e m o s t i m p o r t a n t
f u n c t i o n i n G U I , t h a t i s , a b o u t h o w t o a d d r e s s 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 o f t h e p o i n t
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 , a n d 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 points by
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 t h e l i n e : I n t h e i m a g e b u f f e r , d r a w a 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 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 a 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 , 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 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 , a n d
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 , a n d 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 , a n d 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 , 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 , a n d 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 , a n d
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 , a n d 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 , 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
W r i t e n u m b e r s w i t h d e c i m a l s : I n t h e i m a g e c a c h 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 ,
w r i t e a s t r i n g o f n u m b e r s t h a t c a n b e n u m b e r e d 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
d);
Parameter:
Xstart: The left vertex X coordinate of the character
Ystart: The left vertex Y coordinate of the font
Nummber: The numbers shown, saved here using a double, are common
enough
Decimal_Point: Displays a few digits after the decimal point
Font: Ascii code visual character font library, the following font
s are available 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 , F o r 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 , 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, generally 0
by default
U s e r D e m o T e s t
T h e a b o v e t h r e e c h a p t e r s h a v e i n t r o d u c e d t h r e e d e m o s t r u c t u r e s o f L i n u x , h e r e w e
i n t r o d u c e t h e u s e r t e s t d e m o .
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 P I \ c \ e x a m p l e ; I f y o u n e e d t o r u n t h e t e s t d e m o , y o u
n e e d t o r u n m i a n d e m o .
U n d e r t h e L i n u x c o m m a n d m o d e , y o u n e e d t o e x e c u t e t h e f o l l o w i n g c o m m a n d s a g a i n :
make clean
make -j
sudo ./main
P y t h o n ( F o r R a s p b e r r y P i )
A p p l i c a b l e f o r p y t h o n a n d p y t h o n 3 .
P y t h o n i s 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 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 h o w t o e x i t :
def module_init()
def Touch_module_init()
def module_exit()
Note:
1. Here is how to address GPIO before or after using the LCD.
2. The module_init() and Touch_module_init() functions are automatically c
alled in the init() function on the LCD and the touch screen respectively,
but the module_exit() function needs to be called by itself.
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)
I 2 C r e a d a n d w r i t e d a t a .
def i2c_write_byte( Addr, val)
def i2c_read_byte(Addr)
p y t h o n i n t h e f o l l o w i n g d i r e c t o r i e s :
R P I \ p y t h o n \ e x a m p l e s \
E x e c u t e t h e f o l l o w i n g c o m m a n d s a g a i n i n t h e L i n u x c o m m a n d m o d e :
sudo python 1inch28_LCD_test.py
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
t h e l o g i c a l l a y e r l i k e C a n d c a n d i r e c t l y c a l l 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 a 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 o f 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 a 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 a 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 a 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 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 a 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 t o u s e . T o d r a w E n g l i s h
c h a r a c t e r s , 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 s , 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 w o - e l e m e n t t u p l e w i t h ( 4 0
f i l l i s f o n t c o l o r , f i l l = " W H I T E " m e a n s t h a t t h e f o n t c o l o r i s w h i t e . A l s o , y o u c a n u s e f i l l =
( 1 2 8 , 2 5 5 , 1 2 8 ) , t h e n u m b e r i n t h e ( ) c o r r e s p o n d s t o t h e R G B v a l u e , a n d t h e n y o u c a n
a c c u r a t 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 d i s p l a y s "
a n d 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 p i c t u r e s :
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 :
P y t h o n ' s i m a g e l i b r a r y i s v e r y p o w e r f u l , i f y o u n e e d t o i m p l e m e n t m o r e , y o u c a n l e a r n o n
t h e w e b s i t 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
R a s p b e r r y P i P i c o
H a r d w a r e C o n n e c t i o n
C / C + + D e v e l o p m e n t E n v i r o n m e n t I n s t a l l a t i o n
B e f o r e u s i n g t h e d e m o s a n d t u t o r i a l s , y o u n e e d t o s e t u p a d e v e l o p m e n t e n v i r o n m e n t
a n d l e a r n t h e b a s i c m e t h o d s .
P i c o - G e t - S t a r t - W i n d o w s
P i c o - G e t - S t a r t - R P I
S o f t w a r e E n v i r o n m e n t D e b u g g i n g
I n o r d e r t o f a c i l i t a t e t h e d e v e l o p m e n t o f P i c o b o a r d s u s i n g M i c r o P y t h o n o n t h e c o m p u t e r ,
i t i s r e c o m m e n d e d t o d o w n l o a d T h o n n y I D E .
D o w n l o a d
T h o n n y I D E
T h o n n y I D E d o w n l o a d l i n k ( w i n d o w s )
T h o n n y w e b s i t e
A f t e r i n s t a l l i n g , p l e a s e c o n f i g u r e t h e l a n g u a g e a n d t h e e n v i r o n m e n t f o r t h e f i r s t t i m e .
N o t e t h a t w e s h o u l d c h o o s e t h e R a s p b e r r y P i o p t i o n i n t h e b o a r d e n v i r o n m e n t .
C o n f i g u r e t h e M i c r p y t h o n e n v i r o n m e n t a n d s e l e c t t h e P i c o p o r t .
F i r s t c o n n e c t t h e R a s p b e r r y P i P i c o t o t h e c o m p u t e r , l e f t - c l i c k o n t h e c o n f i g u r a t i o n
e n v i r o n m e n t o p t i o n 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 o n n y - - > s e l e c t c o n f i g u r e a n
i n t e r p r e t e r .
I n t h e p o p - u p w i n d o w b a r , s e l e c t M i c r o P y t h o n ( R a s p b e r r y P i P i c o ) , a n d s e l e c t t h e
c o r r e s p o n d i n g p o r t .
C l i c k O K t o r e t u r n t o t h e m a i n i n t e r f a c e o f T h o n n y , d o w n l o a d t h e
P i c o , a n d t h e n c l i c k t h e s t o p b u t t o n t o d i s p l a y t h e c u r r e n t l y u s e d e n v i r o n m e n t i n t h e
S h e l l w i n d o w .
P i c o d o w n l o a d f i r m w a r e l i b r a r y m e t h o d i n w i n d o w s : P r e s s a n d h o l d t h e B O O T b u t t o n
a n d c o n n e c t t o t h e c o m p u t e r , r e l e a s e t h e B O O T b u t t o n , a n d a r e m o v a b l e d i s k w i l l
a p p e a r o n t h e c o m p u t e r a n d c o p y t h e f i r m w a r e l i b r a r y i n t o i t .
R a s p b e r r y P i
O p e n t h e R a s p b e r r y P i a n d e x e c u t e :
sudo apt-get install p7zip-full
cd ~
sudo wget https://www.waveshare.com/w/upload/3/3e/1.28inch_Touch_LCD_Pico.
zip
unzip 1.28inch_Touch_LCD_Pico.zip
cd ~/1.28inch_Touch_LCD_Pico
cd c/build/
H o w t o U s e D e m o s
C
T h e f o l l o w i n g t u t o r i a l i s o p e r a t e d o n
a n d p o r t a b i l i t y , i t c a n b e s u c e s s u f u l l y c o m p i l e d o n t h e P C . T h e o p e r a t i o n m y b e a l i t t l e
d i f f e r e n t , y o u n e e d t o j u d g e i t b y y o u r s e l v e s .
C o m p i l e , p l e a s e m a k e s u r e i t i s i n t h e c d i r e c t o r y :
cd ~/1.28inch_Touch_LCD_Pico/c/
C r e a t e a n d e n t e r b u i l d d i r e c t o r y , a d d S D K : . . / . . / p i c o - s d k i s y o u r S D K d i r e c t o r y . I n o u r
e x a m p l e d e m o , t h e r e i s " b u i l d " , y o u c a n d i r e c t l y e n t e r :
cd build
export PICO_SDK_PATH=../../pico-sdk
(Note: please correctly write your SDK path)
E x e c u t e c m a k e a n d a u t o m a t i c a l l y g e n e r a t e M a k e f i l e .
cmake ..
E x e c u t e m a k e t o g e n e r a t e t h e e x e c u t a b l e f i l e , y o u m a y w a i t f o r a l o n g t i m e a s i t i s t h e f i r s t
t i m e t o b e c o m p i l e d .
make -j9
A f t e r c o m p i l i n g , u f 2 f i l e w i l l g e n e r a t e . P r e s s t h e b u t t o n o n t h e P i c o b o a r d , P i c o c a n c o n n e c t
t o t h e U S B p o r t o f t h e R a s p b e r r y P i v i a a M i c r o U S B c a b l e , a n d t h e n r e l e a s e t h e b u t t o n s .
A f t e r c o n n e c t i n g , R a s p b e r r y P i w i l l a u t o m a t i c a l l y i d e n t i f y a m o v a b l e d i s k ( R P I - R P 2 ) , a n d
c o p y m a i n . u f 2 i n t h e b u i l d f i l e t o t h e r e c o g n i z a b l e m o v a b l e d i s k ( R P I - R P 2 ) .
cp main.uf2 /media/pi/RPI-RP2/
P y t h o n
1 . O n t h e R a s p b e r r y P i , c o p y ~ / 1 . 2 8 i n c h _ T o u c h _ L C D _ P i c o / p y t h o n / r p 2 - p i c o - 2 0 2 2 1 1 2 5 -
v 1 . 1 9 . 1 . u f 2 t o P i c o .
2 . O p e n T h o n n y I D E o n t h e R a s p b e r r y P i ( c l i c k R a s p b e r r y P i l o g o - > P r o g r a m m i n g - >
T h o n n y P y t h o n I D E ) , a n d y o u c a n c h e c k t h e v e r s i o n i n f o r m a t i o n i n H e l p - > A b o u t
T h o n n y .
T o e n s u r e y o u r v e r s i o n t h a t y o u r v e r s i o n i n c l u d e s t h e p a c k a g e s u p p o r t e d P i c o , y o u c a n c l i c k
T o o l s - > O p t i o n s . . . - > I n t e r p r e t e r , c h o o s e M i c r o P y t h o n ( R a s p b e r r y P i P i c o a n d t t y A C M 0
p o r t ) . A s s h o w n b e l o w :
I f y o u r c u r r e n t T h o n n y v e r s i o n h a s n o p a c k a g e s u p p o r t i n g P i c o , y o u c a n e n t e r t h e f o l l o w i n g
c o m m a n d s t o u p d a t e T h o n n y I D E .
sudo apt upgrade thonny
3 . C l i c k F i l e - > O p e n . . . - > ~ / 1 . 2 8 i n c h T o u c h L C D P i c o / p y t h o n / 1 . 2 8 i n c h _ T o u c h _ L C D . p y , a n d
t h e n r u n t h e s c r i p t .
W i n d o w s
C l i c k t o d o w n l o a d
1 . 2 8 - i n c h T o u c h L C D P i c o f o l d e r .
C
A f t e r e n t e r i n g 1 . 2 8 i n c h _ T o u c h _ L C D _ P i c o \ c , y o u c a n o p e n t h e p r o j e c t w i t h v s c o d e .
C h o o s e t h e C o m p i l e r .
S t a r t t o c o m p i l e .
F i n i s h .
C o p y t h e m a i n . u f 2 f i l r i n b u i l d t o P i c o , a n d t h e n i t c a n a u t o m a t i c a l l y r u n t h e d e m o .
P y t h o n
1 . P r e s s t h e B O O T S E T b u t t o n o n t h e P i c o a n d c o n n e c t t h e p i c o t o t h e U S B p o r t o f t h e
c o m p u t e r w i t h a M i c r o U S B c a b l e . R e l e a s e t h e b u t t o n w h e n t h e c o m p u t e r i d e n t i f i e s a
m o v a b l e d i s k ( R P I - R P 2 ) .
2 . C o p y r p 2 - p i c o - 2 0 2 2 1 1 2 5 - v 1 . 1 9 . 1 . u f 2 f i l e i n t h e p y t h o n d i r e c t o r y t o t h e r e c o g n i z a b l e
m o v a b l e d i s k
3 . O p e n T h o n n y I D E ( N o t e : p l e a s e u s e t h e l a t e s t v e r s i o n o f T h o n n y , o t h e r w i s e t h e r e i s
n o P i c o s u p p o r t i n g p a c k a g e . C u r r e n t l y , t h e n e w e s t v e r s i o n i n W i n d o w s i s v 3 . 3 . 3 . )
4 . C l i c k T o o l - > S e t t i n g - > E x p l a i n e r . s e l e c t t h e P i c o a n d t h e c o r r e s p o n d i n g p o r t a s s h o w n
b e l o w :
5 . F i l e - > O p e n - > 1 . 2 8 i n c h _ T o u c h _ L C D . p y , c l i c k t o r u n , t h e e f f e c t i s s h o w n a s b e l o w .
W e p r o v i d e a s i m p l e d e m o f o r y o u . . .
D e m o A n a l y s i s
C
B o t t o m h a r d w a r e i n t e r f a c e
W e p a c k a g e t h e b o t t o m h a r d w a r e l a y e r f o r e a s i l y p o r t i n g t o t h e d i f f e r e n t h a r d w a r e
p l a t f o r m s .
D E V _ C o n f i g . c ( . h ) i n t h e d i r e c t o r y : . . . \ c \ l i b \ C o n f i g
D a t a t y p e
#define UBYTE
#define UWORD
#define UDOUBLE uint32_t
M o d u l e i n i t i a l i z e a n d e x i t :
void DEV_Module_Init(void);
void DEV_Module_Exit(void);
Note:
1. The functions above are used to initialize the display or exit handle.
G P I O w r i t e / r e a d
void
DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE
DEV_Digital_Read(UWORD Pin);
S P I t r a n s m i t s d a t a .
void DEV_SPI_WriteByte(UBYTE Value);
I 2 C w r i t e a n d r e a d d a t a .
void DEV_I2C_Write_Byte(uint8_t addr, uint8_t reg, uint8_t Value);
void DEV_I2C_Write_nByte(uint8_t addr, uint8_t *pData, uint32_t Len);
uint8_t DEV_I2C_Read_Byte(uint8_t addr, uint8_t reg);
void DEV_I2C_Read_nByte(uint8_t addr, uint8_t reg, uint8_t *pData, uint32_
t Len);
A p p l i c a t i o n f u n c t i o n s
W e p r o v i d e b a s i c G U I f u n c t i o n s f o r t e s t i n g , l i k e d r a w p o i n t , l i n e , s t r i n g , a n d s o o n . T h e G U I
f u n c t i o n c a n b e f o u n d i n d i r e c t o r y : . . \ 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 u s e d c a n b e f o u n d 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 \ F o n t s .
C r e a t e a n e w i m a g e , y o u c a n s e t t h e i m a g e n a m e , w i d t h , h e i g h t , r o t a t e a n g l e , a n d c o l o r .
void Paint_NewImage(UWORD *image, UWORD Width, UWORD Height, UWORD Rotate,
UWORD Color, UWORD Depth)
Parameter:
image: Name of the image buffer, this is a pointer;
Width: Width of the image;
Height: Height of the image;
Rotate: Rotate the angle of the Image;
Color: The initial color of the image;
Depth: Depth of the color
S e l e c t i m a g e b u f f e r : 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 b u f f e r s a t t h e s a m e t i m e a n d s e l e c t
t h e c e r t a i n o n e a n d d r a w b y t h i s f u n c t i o n .
void Paint_SelectImage(UBYTE *image)
Parameter:
image: The name of the image buffer, this is a pointer;
S e t p o i n t d i s p l a y s p o s i t i o n a n d c o l o r i n t h e c a c h e : H e r e i s t h e c o r e f u n c t i o n o f t h e G U I ,
t h e p r o c e s s i n g p o i n t d i s p l a y s p o s i t i o n a n d c o l o r i n t h e c a c h e .
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
Parameter:
Xpoint: Point X position in the image cache
Ypoint: Point Y position in the image cache
Color: The color in which the dot is displayed
I m a g e c a c h e f i l l c o l o r : f i l l t h e i m a g e c a c h e t o a c e r t a i n c o l o r , g e n e r a l l y a s t h e r o l e o f
s c r e e n w h i t e n i n g
void Paint_Clear(UWORD Color)
Parameter:
Color: The filling color
I m a g e c a c h e p a r t w i n d o w f i l l c o l o r : f i l l a c e r t a i n p a r t o f t h e i m a g e c a c h e w i n d o w 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 t h e r o l e o f w i n d o w w h i t e n i n g , o f t e n u s e d f o r t h e d i s p l a y o f
t i m e , r e f r e s h i n g w h i t e f o r o n e s e c o n d .
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color)
Parameter:
Xstart: The X start coordinate of the window
Ystart: The Y-start coordinate of the window
Xend: The X endpoint coordinates of the window
Yend: The Y-end coordinates of the window
Color: The color of the fill
D r a w p o i n t : D r a w a p o i n t a t t h e p o s i t i o n
c o n f i g u r e t h e c o l o r , s i z e , a n d s t y l e .
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Do
t_Pixel, DOT_STYLE Dot_Style)
Parameter:
Xpoint: X-axis position of the point.
Ypoint: Y-axis position of the point
Color: Color of the point
Dot_Pixel: Size of the point, 8 sizes are available.
Dot_Style: The style of the point, defines the extended mode of th
e point.
D r a w t h e l i n e : D r a w a 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 ) i n t h e i m a g e b u f f e r , y o u
c a n c o n f i g u r e t h e c o l o r , w i d t h , a n d s t y l e .
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UW
ORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
Parameter:
Xstart: Xstart of the line
Ystart: Ystart of the line
Xend: Xend of the line
Yend: Yend of the line
Color: Color of the line
Line_width: Width of the line, 8 sizes are available.
Line_Style: Style of the line, Solid or Dotted.
D r a w a r e c t a n g l e : 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 o n f i g u r e t h e c o l o r , w i d t h , a n d s t y l e .
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen
d, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
Parameter:
Xstart: Xstart of the rectangle.
Ystart: Ystart of the rectangle.
Xend: Xend of the rectangle.
Yend: Yend of the rectangle.
Color: Color of the rectangle
Line_width: The width of the edges. 8 sizes are available.
Draw_Fill: Style of the rectangle, empty or filled.
D r a w c i r c l e : D r a w a c i r c l e i n t h e i m a g e b u f f e r , u s e ( 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
a n d R a d i u s a s t h e r a d i u s . Y o u c a n c o n f i g u r e t h e c o l o r , w i d t h o f t h e l i n e , a n d s t y l e o f a
c i r c l e .
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD
Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
Parameter:
X_Center: X-axis of center
Y_Center: Y-axis of center
Radius: radius of the circle
Color: The color of the circle
Line_width: The width of the arc, 8 sizes are available.
Draw_Fill: Style of the circle: empty or filled.
S h o w A s c i i c h a r a c t e r : S h o w a c h a r a c t e r i n ( X s t a r t , Y s t a r t ) p o s i t i o n , y o u c a n c o n f i g u r e t h e
f o n t , f o r e g r o u n d , a n d b a c k g r o u n d .
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFO
NT* Font, UWORD Color_Foreground, UWORD Color_Background)
Parameter:
Xstart: Xstart of the character
Ystart: Ystart of the character
Ascii_Char: Ascii char
Font: five fonts are available:
Color_Foreground: foreground color
Color_Background: background color
D r a w E n g l i s h s t r i n g : I n ( 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 c o d e 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 , 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, UWORD Color_Background)
Parameter:
Xstart: Xstart of the string
Ystart: Ystart of the string
pString: String
Font: five fonts are available:
Color_Foreground: foreground color
Color_Background: background color
D r a w C h i n e s e s t r i n g : D r a w C h i n e s e s t r i n g a t ( X s t a r t Y s t a r t ) o f t h e i m a g e b u f f e r . Y o u c a n
c o n f i g u r e f o n t s ( G B 2 3 1 2 ) , f o r e g r o u n d , a n d b a c k g r o u n d .
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString,
cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
Parameter:
Xstart: Xstart of string
Ystart: Ystart of string
pString: string
Font: GB2312 fonts, two fonts are available
Color_Foreground: Foreground color
Color_Background: Background color
D r a w n u m b 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 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 t h e A s c i i f o n t , f o n t f o r e g r o u n d c o l o r , 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, UWORD Color_Background);
Parameter:
Xstart: Left vertex X coordinate
Ystart: Left vertex Y coordinate
Nummber: The displayed number is stored in a 32-bit int type, whic
h can be displayed up to 2147483647.
Digit: Display decimal places
Color_Foreground: Foreground color
Color_Background: Background color
D i s p l a y t i m e : I n ( 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 f o r a p e r i o d o f t i m e , 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 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 , a n d 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, UWORD Color_Foreground)
Parameter:
Xstart: The left vertex X coordinate of the character
Ystart: The left vertex Y coordinate of the character
pTime: The displayed time, here defines a time structure, just pas
s the number of hours, minutes, and seconds to the parameter
Font: Ascii font, five fonts are available
Color_Foreground: Foreground
Color_Background: Background
M i c r o P y t h o n ( A p p l i c a b l e f o r R a s p b e r r y P i P i c o )
F o r b a s i c l i b r a r y , y o u c a n r e f e r t o
h e r e
.
S e e
t h i s l i n k
S T M 3 2 U s e r G u i d e
H a r d w a r e C o n n e c t i o n
D e m o D o w n l o a d
T h i s d e m o i s d e v e l o p e d b y t h e H A L l i b r a r y .
C l i c k h e r e
t o d o w n l o a d , o p e n L C D _ d e m o . u v p r o j x i n t h e 1 . 2 8 - i n c h T o u c h L C D
S T M 3 2 / M D K - A R M d i r e c t o r y , a n d t h e n y o u c a n s e e t h e d e m o .
O p e n L C D _ 1 i n c h 2 8 _ t e s t . c t o s e e t h e d e m o a n d t h e c o m p i l e i t a g a i n .
D e m o D e s c r i p t i o n
B o t t o m 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 uint32_t
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 :
void DEV_Module_Init(void);
void DEV_Module_Exit(void);
Note:
1. Here is how to address GPIO before or after using the LCD.
2. After using DEV_Module_Exit, LCD will close.
G P I O r e a d s a n d w r i t e s d a t a .
void
DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE
DEV_Digital_Read(UWORD Pin);
S P I r e a d s a n d w r i t e s d a t a :
void
DEV_SPI_WRITE(UBYTE _dat);
I 2 C r e a d s a n d w r i t e s d a t a :
void I2C_Write_Byte(uint8_t Cmd, uint8_t value);
int I2C_Read_Byte(uint8_t Cmd)
void I2C_Read_nByte(UBYTE Cmd,UBYTE *Buf,UBYTE num)
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 o n 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 , a n d 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 the
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 , a n 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 , a n d 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 , a n d 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 , a 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 , a n d 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 a 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 , 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 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 , a n d 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 , a n d 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 , a n d 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 , 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 th
e 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 n u m b e r s w i t h d e c i m a l s : A t t h e l e f t v e r t e x o f ( X s t a r t Y s t a r t ) , 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 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_DrawFloatNum(UWORD Xpoint, UWORD Ypoint, double Nummber, UBYTE
Decimal_Point, sFONT* Font, UWORD Color_Foreground, UWORD
d);
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
Nummber: the number displayed here is saved as a double
Decimal_Point: Display the number after the decimal point
Font: Ascii visual character font library, the following Fonts
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 , 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 as a good time structure, as long as
the 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 U s e r G u i d e
A r d u i n o I D E I n s t a l l a t i o n T u t o r i a l
A r d u i n o I D E I n s t a l l a t i o n T u t o r i a l
H a r d w a r e C o n n e c t i o n
R u n t h e D e m o
C l i c k t o d o w n l o a d t h e d e m o , a n d t h e n d e c o m p r e s s i t . T h e d e m o i s i n 1 . 2 8 - i n c h T o u c h L C D
A r d u i n o \ L C D _ 1 i n c h 2 8 _ T o u c h .
I n s a l l A r d u i n o I D E a n d t h e n r u n L C D _ 1 i n c h 2 8 _ T o u c h . i n o f i l e .
O p e n t h e d e m o , a n d 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 a s 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 .
A n d t h e n c l i c k c o m p i l e a n d d o w n l o a d .
D e m o D e s c r i p t i o n
F i l e I n t r o d u c t i o n
O p e n . . \ 1 . 2 8 i n c h T o u c h L C D A r d u i n o \ L C D _ 1 i n c h 2 8 _ T o u c h d i r e c t o r y :
A m o n g w h i c h :
L C D _ 1 i n c h 2 8 _ T o u c h . i n o : O p e n i t 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 ) : t h e L C D d r i v e r d e m o .
T o u c h _ D r i v e r . c p p ( . h ) : t h e d r i v e r d e m o f o r t h e t o u c h s c r e e n .
D E V _ C o n f i g . c p p ( . h ) : 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 , p a c k a g e t h e p i n l e v e l o f r e a d i n g a n d
w r i t i n g , S P I d a t a t r a n s m i s s i o n , a n d t h e 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 : d i f f e r e n t
f o n t s i z e s .
i m a g e . c p p ( . h ) : i m a g e d a t a , w i t h I m g 2 L c d ( d o w n l o a d i n
B M P p i c t u r e t o 1 6 - b i t r e a l R G B p i c t u r e a r r a y s .
T h e d e m o i n c l u d e s t h e b o t t o m 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 d r i v e r , a n d t h e u p p e r
a p p l i c a t i o n .
B o t t o m H a r d w a r e I n t e r f a c e
I n D E V _ C o n f i g . c p p ( . h ) , t h e s e t w o f i l e s d e f i n e t h e h a r d w a r e i n t e r f a c e a n d p a c k a g e f u n c t i o n s
s u c h a s t h e r e a d i n g a n d w r i t i n g p i n l e v e l , d e l a y , S P I t r a n s m i s s i o n , a n d I 2 C t r a n s m i s s i o n .
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 a p i n , t h e s e c o n d o n e i s t h e v o l t a g e 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 a 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 v o l t a g 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 D a t a O u t p u t
DEV_SPI_WRITE(unsigned char data)
T h e p a r a m e t e r i s c h a r , o c c u p y i n g 8 b i t s .
I 2 C R e a d i n g a n d W r i t i n g D a t a
void DEV_I2C_Write_Byte(UBYTE DevAddr, UBYTE RegAddr, UBYTE value)
UBYTE DEV_I2C_Read_Byte(UBYTE DevAddr, UBYTE RegAddr)
void DEV_I2C_Read_nByte(UBYTE DevAddr,UBYTE Cmd, UBYTE *data, UBYTE num)
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 o n w h i c h G U I d e p e n d e n t i s f o n t * . c p p
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 , a n d 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 the
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 , a n 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 , a n d 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 , a n d 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 , a n d 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, 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 a 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 , 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 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, DRAW_FILL Draw_Fill)
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, DRAW_FILL Draw_Fill)
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, in 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, 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
Ascii_Char: indicates the Ascii character
Font: Ascii visual character library, in the Fonts folder, provides th
e 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, 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
PString: string, string is a pointer
Font: Ascii visual character library, in the Fonts folder, provides th
e 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 , a n d 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 , a n d 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, 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
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 , a n d 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 , 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, UWORD Color_Background)
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 th
e 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 n u m b e r s w i t h d e c i m a l s : A t t h e l e f t v e r t e x o f ( X s t a r t Y s t a r t ) , 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 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_DrawFloatNum(UWORD Xpoint, UWORD Ypoint, double Nummber, UBYTE
Decimal_Point, sFONT* Font, UWORD Color_Foreground, UWORD
d);
Parameters:
Xstart: the x-coordinate of the left vertex of a character
Ystart: the Y coordinate of the font's left vertex
Nummber: The number displayed here is saved as a double
Decimal_Point: Display the number after the decimal point
Font: Ascii visual character font library, the following Fonts
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 , 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, 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
PTime: display time, here defined as a good time structure, as long as
the hour, minute, and second bits of data to the parameter;
Font: Ascii visual character library, in the Fonts folder, provides th
e 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 i m a g e : A t ( X s t a r t Y s t a r t ) i s t h e l e f t v e r t e x , a n I m a g e o f W I m a g e w i d t h a n d H
I m a g e h e i g h t i s d i s p l a y e d .
void Paint_DrawImage(const unsigned char *image, UWORD xStart, UWORD yStar
t, UWORD W_Image, UWORD H_Image)
Parameters:
image: Image address, which points to the image information you wa
nt to display
Xstart: The left vertex X coordinate of the character
Ystart: The left vertex Y coordinate of the character
W_Image: image width
H_Image: image height
R e s o u r c e
D o c u m e n t
1 . 2 8 i n c h _ T o u c h _ L C D _ S c h e m a t i c . p d f
D e m o
1 . 2 8 i n c h _ T o u c h _ L C D _ D e m o . z i p
S o f t w a r e
Z i m o 2 2 1 . 7 z
I m a g e 2 L c d . 7 z
I m a g e 2 L c d I m a g e M o d u l o
D a t a s h e e t
G C 9 A 0 1 A . p d f
C S T 8 1 6 S _ r e g i s t e r _ d e c l a r a t i o n . p d f
C S T 8 1 6 S D a t a s h e e t E N . p d f
F A Q
Q u e s t i o n :
W h a t i s t h e b i g g e s t p o w e r c o n s u m p t i o n o f 1 . 2 8 i n c h T o u c h L C D ?
A n s w e r :
3 . 3 V 3 3 . 2 m A
S u p p o r t
I f y o u r e q u i r e t e c h n i c a l s u p p o r t , p l e a s e g o t o t h e p a g e a n d o p e n a t i c k e t .
R e s o l u t i o n
C o m m u n i c a t i o n
i n t e r f a c e
C o m m u n i c a t i o n
i n t e r f a c e
T o u c h t y p e
3 2 . 4 m m
P i x e l s i z e
Φ
3 8 . 5 m m
L C D d a t a / c o m m a n d p i n , l o w f o r c o m m a n d , h i g h f o r d a t a .
M o d u l e P i n
V C C
G N D
M I S O
M O S I
S C L K
L C S _ C S
L C S _ D C
L C S _ R S T
L C S _ B L
T P _ S D A
T P _ S C L
T P _ I N T
T P _ R S T
uint8_t
uint16_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: A font of 5*8
font12: 7*12 font
font16: The font of 11*16
font20: A font of 14*20
font24: The font of 17*24
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
P i n
V C C
G N D
M I S O
M O S I
S C L K
L C S _ C S
L C S _ D C
L C S _ R S T
L C S _ B L
T P _ S D A
T P _ S C L
T P _ I N T
T P _ R S T
a n d i n s t a l l i t b y s t e p s .
1 . 2 8 i n c h T o u c h L C D P i c o . z i p
R P I - R P 2 ) .
uint8_t
uint16_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;
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
font12:7*12
font16:11*16
font20:14*20
font24:17*24
font8:5*8
font12:7*12
font16:11*16
font20:14*20
font24:17*24的
font12CN:ascii 11*21,Chinese 16*21
font24CN:ascii 24*41,Chinese 32*41
font8:5*8
font12:7*12
font16:11*16
font20:14*20
font24:17*24
font8:5*8
font12:7*12
font16:11*16
font20:14*20
font24:17*24
f o r g r a p h i c l i b r a r y u s a g e .
M o d u l e P i n
V C C
G N D
M I S O
M O S I
S C L K
L C S _ C S
L C S _ D C
L C S _ R S T
L C S _ B L
T P _ S D A
T P _ S C L
T P _ I N T
T P _ R S T
uint8_t
uint16_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,
,
,
,
,
,
,
,
font8:5*8 font
font12:7*12 font
font16:11*16 font
font20:14*20 font
font24:17*24 font
M o d u l e P i n
V C C
G N D
M I S O
M O S I
S C L K
L C S _ C S
L C S _ D C
L C S _ R S T
L C S _ B L
T P _ S D A
T P _ S C L
T P _ I N T
T P _ R S 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,
= 1,
,
,
,
,
,
,
,
font8:5*8 font
font12:7*12 font
font16:11*16 font
font20:14*20 font
font24:17*24 font
2 4 0 × 2 4 0
p i x e l s
4 - w i r e S P I
I 2 C
C a p a c i t i v e
0 . 1 3 5 ×
0 . 1 3 5 m m
F u n c t i o n
P o w e r i n p u t ( 3 . 3 V / 5 V )
G r o u n d
S P I M I S O p i n
S P I M O S I p i n
S P I C L K p i n
L C D c h i p s e l e c t i o n p i n , l o w a c t i v e
L C D r e s e t p i n , l o w a c t i v e
L C D b a c k l i g h t p i n
T P d a t a p i n
T P c l o c k p i n
T P i n t e r r u p t p i n
T P r e s e t p i n , l o w a c t i v e
R a s p b e r r y P i ( B C M )
3 . 3 V
G N D
9
1 0
1 1
8
2 5
2 7
1 8
2
3
4
1 7
= 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)
, i t d o e s n o t n e e d t o w r i t e c o d e f r o m
5 0 ) a s t h e l e f t v e r t e x , a n d u s e f o n t 2 ,
p i l
R a s p b e r r y P i P i c o
3 . 3 V
G N D
G P 1 2
G P 1 1
G P 1 0
G P 9
G P 1 4
G P 8
G P 1 5
G P 6
G P 7
G P 1 7
G P 1 6
R a s p b e r r y P i
. A s c M a k e f e a t u r e s m u l t i - p l a t f o r m s
, d e c o m p r e s s t h e p a c k a g e a n d g o t o t h e
X p o i n t , Y p o i n t
= 1,
,
,
,
,
,
,
,
= 1,
= 1,
,
,
,
,
,
,
,
= 1,
,
,
,
,
,
,
,
= 1,
,
,
,
,
,
,
,
P i c o p y t h o n s d k . p d f
S T M 3 2 F 1 0 3 R B
3 . 3 V
G N D
P A 6
P A 7
P A 5
P B 6
P A 8
P A 9
P C 7
P B 9
P B 8
P B 1 0
P A 1 0
// 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)
A r d u i n o u n o
# R e s o u r c 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,
// 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
1 . 2 8 i n c h T o u c h L C D
1 . 2 8 " , 2 4 0 x 2 4 0
S P I , I 2 C
// 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
Color_Backgroun
微 雪电子
f i r m w a r e l i b r a r y
o f t h e i m a g e b u f f e r , y o u c a n
// 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
, f o r m o r e d e t a i l s , y o u c a n
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
Color_Backgroun
5 V
G N D
1 2
1 1
1 3
1 0
7
8
9
S D A
S C L
3
4
) , y o u c a n c o n v e r t a n y
h
f i l e .
// 2 X 2
// 3 X 3
// 4 X 4
// 5 X 5
// 6 X 6
// 7 X 7
// 8 X 8
Color_Backgroun
" i n F o n t 3 ,
t o
c l i c k

Advertisement

loading
Need help?

Need help?

Do you have a question about the B0BWJBG98D and is the answer not in the manual?

Questions and answers