WAVESHARE 1.9inch LCD Mini Display Module User Guide

June 2, 2024
WAVESHARE

1.9inch LCD Mini Display Module

“`html

Specifications:

  • Display Size: 1.9 inches
  • Interface: GH1.25 8PIN
  • Communication Protocol: SPI
  • Compatible with: Raspberry Pi

Product Usage Instructions:

Hardware Connection:

Please connect the LCD to your Raspberry Pi using the provided
8PIN cable. Follow the pin configuration table below:

LCD VCC GND DIN CLK
Raspberry Pi BCM2835 3.3V GND MOSI

Enable SPI Interface:

To enable the SPI interface on your Raspberry Pi:

  1. Open the terminal and enter the command: sudo raspi-config

  2. Choose Interfacing Options -> SPI -> Yes to enable
    SPI

  3. Reboot your Raspberry Pi using the command: sudo reboot

C Demo:

To run the C demo:

  1. Install BCM2835 library by running the provided commands in the
    terminal

  2. Install wiringPi library (optional) using the commands
    provided

  3. Download the demo files, compile, and run using the given
    instructions

Python Demo:

To run the Python demo:

  1. Install necessary Python libraries for Python2 or Python3 as
    per your requirement

  2. Download the demo files following the provided
    instructions

Frequently Asked Questions (FAQ):

Q: How do I check if the SPI interface is enabled?

A: You can check if SPI is enabled by verifying ‘dtparam=spi=on’
in /boot/config.txt and using ls /dev/spi* to see if SPI is
occupied.

Q: What should I do if SPI is occupied?

A: If SPI is occupied, it is recommended to temporarily close
other driver coverages to free up SPI. You can use ls /dev/spi* to
check for occupied SPI instances.

Q: How can I run the test demos for all screen sizes?

A: You can call the test demos by inputting the corresponding
screen size in the terminal. For example, sudo ./main 1.9 for the
1.9-inch screen.

“`

1.9inch LCD Module

Overview

1.9inch LCD Module

Specifications

Operating voltage: 3.3V / 5V (Please ensure that the power supply voltage is consistent with the logic voltage, otherwise it will not work normally.) Communication Interface: SPI Display Panel: IPS Driver: ST7789V2 Resolution: 170 (H) RGB × 320 (V) Display Dimensions: 22.70 × 42.72mm Pixel Pitch: 0.1335 × 0.1335 mm Module Dimensions: 27.3 × 51.2mm

1.9inch 170 × 320, SPI

LCD And Controller
The built-in driver of the 1.9-inch LCD Module is ST7789V2, which is the LCD controller with 240 x RGB x 320, and the resolution of the LCD is 170 (H) RGB × 320 (V). Moreover, the internal RAM of the LCD is not fully used as it can be initialized as a portrait and horizontal screen. This LCD supports the input RGB format of 12 bits, 16 bits, and 18 bits, that is, RGB444, RGB565, and RGB666. The demo used here is RGB565, which is the RGB format we generally used. As the LCD adopts 4-wire SPI, it is not only faster in communication, but also saves more GPIO headers.
Communication Protocol

Note: the difference with the traditional SPI protocol is the data pin from the slave device to the host device is hidden as it only needs to display. Please refer to the Datasheet Page 66. RESX is reset, pulled low when the module is powered on, and is usually set to 1. CSX is the slave device chip selection, low active. D/CX is the data/command control pin of the chip. Write command when DC=0, write data when DC=1. SDA is the transmitted data, that is, RGB data. SCL is the SPI communication clock. For SPI communication, data is transmitted in sequence, that is, the combination of CPHA (Clock Phase) and CPOL (Clock Polarity). CPHA controls whether the data is collected on the 1st or 2nd edge of SCLK. When CPHA = 0, the data is acquired at the 1st edge of SCLK. CPOL controls the idle state level of the SCLK. When CPOL = 0, it is at a low level. From the above figure, you can see that it starts to transfer the data at the 1st edge of the SCLK. 8-bit data is transferred in one clock cycle, and with SPI0, the data is transmitted from high to low in bits.
Raspberry Pi

Hardware Connection

Please connect the LCD to your Raspberry Pi with the 8PIN cable according to the table below.

Connect to Raspberry Pi

LCD
VCC GND DIN CLK
CS DS RST BL

BCM2835 3.3V GND MOSI SCLK CE0 25 27 18

Raspberry Pi

Board 3.3V GND
19 23 24 22 13 12

The 1.9inch LCD uses the GH1.25 8PIN interface, which can be connected to the Raspberry Pi according to the above table: (Please connect according to the pin definition table. The color of the wiring in the picture is for reference only, and the actual color shall prevail.)

Enable SPI Interface
Open the terminal, and use the following command to enter the configuration page:
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable the SPI interface

Reboot Raspberry Pi
sudo reboot
Check /boot/config.txt, and you can see ‘dtparam=spi=on’ is written.
In order to make sure SPI is not occupied, it is recommended to temporarily close other driver coverage. You can use “ls /dev/spi*” to check whether SPI is occupied. If the terminal outputs “/dev/spidev0.0″ and ” /dev/spidev0.1″, it means SPI is in normal condition.
C Demo
Install BCM2835

Open the Raspberry Pi terminal and run the following command wget

http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz tar zxvf bcm2835-1.71.tar.gz cd bcm2835-1.71/ 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/
Install wiringPi (optional)

Open the Raspberry Pi terminal and run the following commands: sudo apt-get

install wiringpi #For Raspberry Pi systems after May 2019 (earlier ones do not need to be e xecuted), an upgrade may be required: 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, it mean s that there is an error in the installation.

The Bullseye branching system uses the following commands: 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 error in the installation.
Demo download
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/
Recompile and it may take a few seconds.
cd c sudo make clean sudo make -j 8
The test demos for all screens can be called directly by inputting the corresponding size:
sudo ./main 1.9
Python Demo
Install libraries

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
Demo download
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/
Enter the python demo directory and run “ls -l”
cd python/examples ls -l

You can see all the test demos for LCDs, and they are classified according to the sizes.

0inch96_LCD_test.py 1inch14_LCD_test.py 1inch28_LCD_test.py 1inch3_LCD_test.py 1inch47_LCD_test.py 1inch54_LCD_test.py 1inch8_LCD_test.py 1inch9_LCD_test.py 2inch_LCD_test.py 2inch4_LCD_test.py

0.96inch LCD test demo 1.14inch LCD test demo 1.28inch LCD test demo 1.3inch LCD test demo 1.47inch LCD test demo 1.54inchLCD test demo 1.8inch LCD test demo 1.9inch LCD test demo 2inch LCD test demo 2.4inch LCD test demo

Run the corresponding demo and it supports python2/3.

python2 sudo python 1inch9_LCD_test.py # python3 sudo python3

1inch9_LCD_test.py

FBCP Porting
Framebuffer uses a video output device to drive a video display device from a memory buffer containing complete frame data. Simply put, a memory area is used to store the display content, and the display content can be changed by changing the data in the memory. There is an open source project on github: fbcp-ili9341. Compared with other fbcp projects, this project uses partial refresh and DMA to achieve a speed of up to 60fps.
Download Drivers
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/*
Method 1: Use a script (Recommended)
Here we have written several scripts that allow users to quickly use fbcp and run corresponding commands according to their own screen If you use a script and do not need to modify it, you can ignore the second method below. Note: The script will replace the corresponding /boot/config.txt and /etc/rc.local and restart, if the user needs, please back up the relevant files in advance.

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
Method 2: Manual Configuration
Environment Configuration
Raspberry Pi’s vc4-kms-v3d will cause fbcp to fail, so we need to close vc4 -kms-v3d before installing in fbcp.
sudo nano /boot/config.txt
Just block the statement corresponding to the picture below:

Reboot:
sudo reboot
Compile and run
mkdir build cd build cmake [options] .. sudo make -j sudo ./fbcp
Replace it by yourself according to the LCD Module you use, above cmake [options] ..

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 ..
Set up to start automatically
sudo cp ~/Waveshare_fbcp/buil d/fbcp /usr/local/bin/fbcp sudo nano /etc/rc.local
Add fbcp& before exit 0. Note that you must add “&” to run in the background, otherwise the system may not be able to start.
Set the display resolution
Set the user interface display size in the /boot/config.txt file.
sudo nano /boot/config.txt
Then add the following lines at the end of the config.txt.
hdmi_force_hotplug=1 hdmi_cvt=[options] hdmi_group=2 hdmi_mode=1 hdmi_mode=87 display_rotate=0
Replace the above hdmi_cvt=[options] according to the LCD Module you are using.

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

And then reboot the system:
sudo reboot
After rebooting the system, the Raspberry Pi OS user interface will be displayed.

STM32

Hardware Connection

The demo we provided is based on STM32F103RBT6, and it is connected corresponding to the STM32F103RBT6 pins. If you need to port the program, you can connect it according to the actual pins.

STM32F103ZET Pin Connection Correspondence
LCD VCC GND DIN CLK
CS DC RST BL

STM32 3.3V GND PA7 PA5 PB6 PA8 PA9 PC7

Take the XNUCLEO-F103RB developed by our company as an example, the connection is as follows:

Run Demo
Download the demo and find the STM32 file directory, open LCD_demo.uvprojx in the directory of STM32STM32F103RBT6MDK-ARM, then you can see the demo.
Open main.c and you can see all the test demos. As we use the 1.9-inch LCD Module, we need to remove the comment in front of “LCD_1in9_test();” and recompile and download.

Demo Description

Underlying Hardware Interface

Data type

define UBYTE #define UWORD #define UDOUBLE

uint8_t uint16_t uint32_t

Module initialization and exit processing
void DEV_Module_Init(void); void DEV_Module_Exit(void); Note: 1. Here is the processing of some GPIO before and after using the LCD scre en; 2. After the DEV_Module_Exit function is used, the LCD display will be tur ned off;

Write and read GPIO
void DEV_Digital_Write(UWORD Pin, UBYTE Value); UBYTE DEV_Digital_Read(UWORD Pin);
SPI writes data
void DEV_SPI_WRITE(UBYTE _dat);

Upper Application
For LCDs, it is the upper application that draws pictures, displays Chines/English characters, displays pictures, etc. Many friends have asked about some graphics processing. We provide some basic functions here. You can find the GUI in the following directory: STM32STM32F103RBUserGUI_DEVGUI_Paint.c(.h) Note: GUI is directly written in the LCD RAM due to the RAM limits of the STM32 and Arduino.

The following directory is the fonts for GUI dependencies: STM32STM32F103RBUserFonts

New image properties: the image properties include: the name of the image cache, width, height, rotating angle, and color.
void Paint_NewImage(UWORD Width, UWORD Height, UWORD Rotate, UWORD Color); Parameters:
Width: the width of the image cache Height: the height of the image cache Rotate: the rotating angle of the image cache Color: the color of the image cache
Set the screen clearing function, usually calling the clear function of the LCD;
void Paint_SetClearFuntion(void (Clear)(UWORD)); Parameters:
Clear: A pointer to the screen clearing function, which is used to quickly clear the screen into a certain color;
Set the function of drawing pixels, usually calling the DrawPaint function of LCD;
void Paint_SetDisplayFuntion(void (
Display)(UWORD,UWORD,UWORD)); Parameters:
Display: Pointer to the function of drawing pixels, which is used to write data to the specified location of LCD internal RAM;
Select image cache: select image cache, the purpose of selection is that you can create multiple image properties, image caches can exist multiple, and you can select each image you created.
void Paint_SelectImage(UBYTE *image) Parameters:
image: The name of the image cache, which is actually a pointer to the f irst address of the image cache;
Image rotation: set the rotating angle of the chosen image, and is recommended to use it after “Paint_SelectImage()”, and you can choose to rotate 0, 90, 180, 270.
void Paint_SetRotate(UWORD Rotate) Parameters:
Rotate: image selection angle, you can choose ROTATE_0, ROTATE_90, ROTAT E_180, and ROTATE_270 corresponding to 0, 90, 180, and 270 degrees respect ively
Note: Under different selection angles, the coordinates correspond to different starting pixels. Here we take 1.14 as an example, and the four pictures are 0°, 90°, 180°, and 270° in order. for reference only:

Image mirror flip: set the mirror flip of the selected image, you can choose none mirror, horizontal mirror, vertical mirror, or image center mirror.
void Paint_SetMirroring(UBYTE mirror) Parameters:
mirror: MIRROR_NONEMIRROR_HORIZONTALMIRROR_VERTICALMIRROR_ORI GIN respectively corresponding to none mirroring, horizontal mirroring, ve rtical mirroring, image center mirroring

Set the display position and color of the point in the cache: here is the core function of the GUI for processing points’ position and color in the cache.
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color) Parameters:
Xpoint: the X position of the point in the image cache Ypoint: the Y position of the point in the image cache Color : the color of the point display

Image cache fills color: fill the image cache with a certain color, generally for flashing the screen into blank.
void Paint_Clear(UWORD Color) Parameters:
Color: fill color

Filling color of part of the image cache window: fill a certain part of the window of the image cache with a certain color, generally used as a window whitening function, often used for time display, whitening for one second.
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen d, UWORD Color) Parameter:
Xstart: X start coordinates of the window Ystart: Y start coordinates of the window Xend: X end coordinates of the window Yend: Y end coordinates of the window Color: Fill color

Draw points: In the image cache, draw points on (Xpoint, Ypoint), you can choose the color, point size, and point style.

void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Do

t_Pixel, DOT_STYLE Dot_Style)

Parameters:

Xpoint: X coordinate of the point

Ypoint: Y coordinate of the point

Color: fill color

Dot_Pixel: Point size, providing default 8 size points

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Dot_Style: The style of the point, the way of size expansion is to

expand with the point as the center or to expand with the point as the low

er left corner to the upper right.

typedef enum {

DOT_FILL_AROUND = 1,

DOT_FILL_RIGHTUP,

} DOT_STYLE;

Draw a line: draw a line from (Xstart, Ystart) to (Xend, Yend) in the image cache, you can choose the color, line width, and line style.

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 coordinate of the starting point of the line

Ystart: The Y coordinate of the starting point of the line

Xend: The X endpoint coordinate of the line

Yend: The Y end point coordinate of the line

Color: Fill color

Line_width: The width of the line, providing 8 default widths

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Line_Style: Line style, select whether the lines are connected in

a straight line or a dotted line.

typedef enum {

LINE_STYLE_SOLID = 0,

LINE_STYLE_DOTTED,

} LINE_STYLE;

Draw a rectangle: In the image cache, draw a rectangle from (Xstart, Ystart) to (Xend, Yend), you can choose the color, the width of the line, and whether to fill the inside of the rectangle.

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 X coordinate of the starting point of the rectangle

Ystart: The Y coordinate of the starting point of the rectangle

Xend: X coordinate of the rectangle’s endpoint

Yend: Y coordinate of the rectangle’s endpoint

Color: The color filled in

Line_width: The width of the four sides of the rectangle, providin

g 8 default widths

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Draw_Fill: fill, whether to fill the inside of the rectangle

typedef enum {

DRAW_FILL_EMPTY = 0,

DRAW_FILL_FULL,

} DRAW_FILL;

Draw a circle: In the image cache, with (X_Center Y_Center) as the center, draw a circle with Radius, you can choose the color, the width of the line, and whether to fill the inside of the circle.

void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD

Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)

Parameters:

X_Center: X coordinate of the center of the circle

Y_Center: Y coordinate of the center of the circle Radius Circle radius

Color: fill color

Line_width: The width of the arc, providing 8 default widths

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Draw_Fill: fill, whether to fill the inside of the circle

typedef enum {

DRAW_FILL_EMPTY = 0,

DRAW_FILL_FULL,

} DRAW_FILL;

Write Ascii characters: in the image buffer, write an Ascii character at (Xstart Ystart) as the left vertex, you can choose Ascii code visual character font library, font foreground color, and font background color.
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 the character Ystart: The Y coordinate of the left vertex of the character Ascii_Char Ascii characters Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font85
8 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Write English character strings: in the image cache, at (Xstart Ystart) as the left vertex, write a string of English characters, you can choose Ascii code visual character font library, font foreground color, font background color;
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 the character Ystart: The Y coordinate of the left vertex of the font pString: string, string is a pointer Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font858 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Write Chinese character strings: in the image cache, at (Xstart Ystart) as the left vertex, write a string of Chinese characters, you can choose GB2312 coded character font, font foreground color, font background color;
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 the character Ystart: The Y coordinate of the left vertex of the character pString: string, string is a pointer Font: The GB2312 coded character font library provides the followi ng fonts in the Fonts folder:
font12CNascii character font 11
21, Chinese font 1621 font24CNascii character font 2441, Chinese font 3241 Color_Foreground: font color Color_Background: background color
Write numbers: In the image cache, write a string of numbers at (Xstart Ystart) as the left vertex, you can choose Ascii code visual character font library, font foreground color, font background color.
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT
Fon t, UWORD Color_Foreground, UWORD Color_Background) Parameters:
Xstart: The X coordinate of the left vertex of the character Ystart: The Y coordinate of the left vertex of the character Nummber: The number displayed here is stored in a 32-bit long int type, which can be displayed up to 2147483647 Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font858 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Write numbers with decimals: in the image cache, (Xstart Ystart) is the left vertex, write a string of numbers that can have decimal numbers, you can choose Ascii code visual character font library, font foreground color, font background color.
void Paint_DrawFloatNum(UWORD Xpoint, UWORD Ypoint, double Nummber, UBYTE Decimal_Point, sFONT
Font, UWORD Color_Foreground, UWORD Color_Backg round); Parameters:
Xstart: The X coordinate of the left vertex of the character Ystart: The Y coordinate of the left vertex of the character Nummber: The number displayed here is saved in double type, which is enough for common needs Decimal_Point: Display the number of digits after the decimal poin t Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font858 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Display time: In the image cache, (Xstart Ystart) is the left apex, and it will be displayed for a period of time, and you can choose the Ascii code visual character font library, font foreground color, and font background color;
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 the character Ystart: The Y coordinate of the left vertex of the character pTime: Displayed time, a time structure is defined here, as long a s the digits of hours, minutes, and seconds are passed to the parameters; Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font85
8 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color

Arduino

Note: all the demos have been tested in Arduino uno. If you need other types of Arduino, you need to determine whether the connection pins are correct.

IDE Installation
Arduino IDE installation steps

Hardware Connection
Arduino UNO Pin Connection Correspondence
LCD VCC GND DIN CLK
CS DC RST BL
The connection diagram is as follows (click to enlarge):

UNO 5V
GND D11 D13 D10 D7 D8 D9

Run Demo
Download the demo and unzip it. The Arduino demo is in ~/Arduino/…. As we use 1.9inch LCD Module, we need to open LCD_1inch9 file folder and run LCD_1inch9.ino file folder.
Open the demo and choose the development board model as Arduino UNO.

Choose the corresponding COM port.

And then click compile and download.

Demo Description File Introduction
Take Arduino UNO controlling 1.54inch LCD as the example, open ArduinoLCD_1inch54 directory.
LCD_1inch54.ino: Open it with Arduino IDE. LCD_Driver.cpp(.h): It is the driver of the LCD screen. DEV_Config.cpp(.h): It is the hardware interface definition, which encapsulates the reading and writing pin level, SPI transmission data, and pin initialization. font8.cpp, font12.cpp, font16.cpp, font20.cpp, font24.cpp, font24CN.cpp, fonts.h: fonts for characters of different sizes. image.cpp(.h): It is image data, which can convert any BMP image into a 16-bit true-color image array through Img2Lcd (can be downloaded in #Resource). The demo is divided into the underlying hardware interface, the middle-layer LCD driver, and the upper-layer application.
Underlying hardware interface
The hardware interface is defined in the two files DEV_Config.cpp (.h), and functions such as reading and writing pin levels, delays, and SPI transmission are encapsulated.
Write pin level
void DEV_Digital_Write(int pin, int value)
The first parameter is the pin, and the second is the high and low level. Write pin level
int DEV_Digital_Read(int pin)
The parameter is the pin, and the return value is the level of the read pin. Delay
DEV_Delay_ms(unsigned int delaytime)
Millisecond level delay. SPI output data
DEV_SPI_WRITE(unsigned char data)
The parameter is char type, occupying 8 bits.
Upper Application
For LCDs, it is the upper application that draws pictures, displays Chines/English characters, displays pictures, etc. Many friends have asked about some graphics processing. We provide some basic functions GUI_Paint.c(.h) here. Note: GUI is directly written in the LCD RAM due to the RAM limits of the STM32 and Arduino.
The fonts used by the GUI all depend on the font*.cpp(h) file under the same file.

New image properties: the image properties include: the name of the image cache, width, height, rotating angle, and color.
void Paint_NewImage(UWORD Width, UWORD Height, UWORD Rotate, UWORD Color); Parameters:
Width: the width of the image cache Height: the height of the image cache Rotate: the rotating angle of the image cache Color: the color of the image cache
Set the screen clearing function, usually calling the clear function of the LCD;
void Paint_SetClearFuntion(void (Clear)(UWORD)); Parameters:
Clear: A pointer to the screen clearing function, which is used to quickly clear the screen into a certain color;
Set the function of drawing pixels, usually calling the DrawPaint function of LCD;
void Paint_SetDisplayFuntion(void (
Display)(UWORD,UWORD,UWORD)); Parameters:
Display: Pointer to the function of drawing pixels, which is used to write data to the specified location of LCD internal RAM;
Select image cache: select image cache, the purpose of selection is that you can create multiple image properties, image caches can exist multiple, and you can select each image you created.
void Paint_SelectImage(UBYTE *image) Parameters:
image: The name of the image cache, which is actually a pointer to the f irst address of the image cache;
Image rotation: set the rotating angle of the chosen image, and is recommended to use it after “Paint_SelectImage()”, and you can choose to rotate 0, 90, 180, 270.
void Paint_SetRotate(UWORD Rotate) Parameters:
Rotate: image selection angle, you can choose ROTATE_0, ROTATE_90, ROTAT E_180, and ROTATE_270 corresponding to 0, 90, 180, and 270 degrees respect ively
Note: Under different selection angles, the coordinates correspond to different starting pixels. Here we take 1.14 as an example, and the four pictures are 0°, 90°, 180°, and 270° in order. for reference only:

Image mirror flip: set the mirror flip of the selected image, you can choose none mirror, horizontal mirror, vertical mirror, or image center mirror.
void Paint_SetMirroring(UBYTE mirror) Parameters:
mirror: MIRROR_NONEMIRROR_HORIZONTALMIRROR_VERTICALMIRROR_ORI GIN respectively corresponding to none mirroring, horizontal mirroring, ve rtical mirroring, image center mirroring

Set the display position and color of the point in the cache: here is the core function of the GUI for processing points position and color in cache.
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color) Parameters:
Xpoint: the X position of the point in the image cache Ypoint: the Y position of the point in the image cache Color : the color of the point display

Image cache fills color: fill the image cache with a certain color, generally for flashing the screen into blank.
void Paint_Clear(UWORD Color) Parameters:
Color: fill color

Filling color of part of the image cache window: fill a certain part of the window of the image cache with a certain color, generally used as a window whitening function, often used for time display, whitening for one second.
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yen d, UWORD Color) Parameters:
Xstart: X start coordinates of the window Ystart: Y start coordinates of the window Xend: X end coordinates of the window Yend: Y end coordinates of the window Color: Fill color

Draw points: In the image cache, draw points on (Xpoint, Ypoint), you can choose the color, point size, and point style.

void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Do

t_Pixel, DOT_STYLE Dot_Style)

Parameters:

Xpoint: X coordinate of the point

Ypoint: Y coordinate of the point

Color: fill color

Dot_Pixel: Point size, providing default 8 size points

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Dot_Style: The style of the point, the way of size expansion is to

expand with the point as the center or to expand with the point as the low

er left corner to the upper right.

typedef enum {

DOT_FILL_AROUND = 1,

DOT_FILL_RIGHTUP,

} DOT_STYLE;

Draw a line: draw a line from (Xstart, Ystart) to (Xend, Yend) in the image cache, you can choose the color, line width, and line style.

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 coordinate of the starting point of the line

Ystart: The Y coordinate of the starting point of the line

Xend: The X end point coordinate of the line

Yend: The Y end point coordinate of the line

Color: Fill color

Line_width: The width of the line, providing 8 default widths

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Line_Style: Line style, select whether the lines are connected in

a straight line or a dotted line.

typedef enum {

LINE_STYLE_SOLID = 0,

LINE_STYLE_DOTTED,

} LINE_STYLE;

Draw a rectangle: In the image cache, draw a rectangle from (Xstart, Ystart) to (Xend, Yend), you can choose the color, the width of the line, and whether to fill the inside of the rectangle.

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 X coordinate of the starting point of the rectangle

Ystart: The Y coordinate of the starting point of the rectangle

Xend: X coordinate of the rectangle’s endpoint

Yend: Y coordinate of the rectangle’s endpoint

Color: The color filled in

Line_width: The width of the four sides of the rectangle, providin

g 8 default widths

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Draw_Fill: fill, whether to fill the inside of the rectangle

typedef enum {

DRAW_FILL_EMPTY = 0,

DRAW_FILL_FULL,

} DRAW_FILL;

Draw a circle: In the image cache, with (X_Center Y_Center) as the center, draw a circle with Radius, you can choose the color, the width of the line, and whether to fill the inside of the circle.

void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD

Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)

Parameters:

X_Center: X coordinate of the center of the circle

Y_Center: Y coordinate of the center of the circle

Radius: Circle radius

Color: fill color

Line_width: The width of the arc, providing 8 default widths

typedef enum {

DOT_PIXEL_1X1 = 1, // 1 x 1

DOT_PIXEL_2X2,

// 2 X 2

DOT_PIXEL_3X3,

// 3 X 3

DOT_PIXEL_4X4,

// 4 X 4

DOT_PIXEL_5X5,

// 5 X 5

DOT_PIXEL_6X6,

// 6 X 6

DOT_PIXEL_7X7,

// 7 X 7

DOT_PIXEL_8X8,

// 8 X 8

} DOT_PIXEL;

Draw_Fill: fill, whether to fill the inside of the circle

typedef enum {

DRAW_FILL_EMPTY = 0,

DRAW_FILL_FULL,

} DRAW_FILL;

Write Ascii characters: in the image buffer, write an Ascii character at (Xstart Ystart) as the left vertex, you can choose Ascii code visual character font library, font foreground color, font background color.
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 the character Ystart: The Y coordinate of the left vertex of the character Ascii_Char: Ascii characters Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font85
8 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Write English character strings: in the image cache, at (Xstart Ystart) as the left vertex, write a string of English characters, you can choose Ascii code visual character font library, font foreground color, font background color;
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 the character Ystart: The Y coordinate of the left vertex of the font pStringstring, string is a pointer Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font858 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Write Chinese character strings: in the image cache, at (Xstart Ystart) as the left vertex, write a string of Chinese characters, you can choose GB2312 coded character font, font foreground color, font background color;
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 the character Ystart: The Y coordinate of the left vertex of the character pStringstring, string is a pointer Font: The GB2312-coded character font library provides the followi ng fonts in the Fonts folder:
font12CNascii character font 11
21, Chinese font 1621 font24CNascii character font 2441, Chinese font 3241 Color_Foreground: font color Color_Background: background color
Write numbers: In the image cache, write a string of numbers at (Xstart Ystart) as the left vertex, you can choose Ascii code visual character font library, font foreground color, font background color.
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT
Fon t, UWORD Color_Foreground, UWORD Color_Background) Parameters:
Xstart: The X coordinate of the left vertex of the character Ystart: The Y coordinate of the left vertex of the character Number: The number displayed here is stored in a 32-bit long int t ype, which can be displayed up to 2147483647 Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font858 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Write numbers with decimals: in the image cache, (Xstart Ystart) is the left vertex, write a string of numbers that can have decimal numbers, you can choose Ascii code visual character font library, font foreground color, font background color.
void Paint_DrawFloatNum(UWORD Xpoint, UWORD Ypoint, double Nummber, UBYTE Decimal_Point, sFONT
Font, UWORD Color_Foreground, UWORD Color_Backg round); Parameters:
Xstart: The X coordinate of the left vertex of the character Ystart: The Y coordinate of the left vertex of the character Number: The number displayed here is saved in double type, which i s enough for common needs Decimal_Point: Display the number of digits after the decimal poin t Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font858 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Display time: In the image cache, (Xstart Ystart) is the left apex, and it will be displayed for a period of time, and you can choose the Ascii code visual character font library, font foreground color, and font background color;
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 the character Ystart: The Y coordinate of the left vertex of the character pTimeDisplayed time, a time structure is defined here, as long a s the digits of hours, minutes, and seconds are passed to the parameters; Font: The Ascii code visual character font library provides the fo llowing fonts in the Fonts folder:
font85
8 font font12712 font font161116 font font201420 font font241724 font Color_Foreground: font color Color_Background: background color
Display images: when (Xstart Ystart) is the left vertex, display an image with a width of W_Image and a height of H_Image.
void Paint_DrawImage(const unsigned char *image, UWORD xStart, UWORD yStar t, UWORD W_Image, UWORD H_Image) Parameters:
image: image address, pointing to the image information you want to disp lay
Xstart: The X coordinate of the left vertex of the character Ystart: The Y coordinate of the left vertex of the font W_Image: image width H_Image: image height
Resource
Document
Schematic Diagram
3D Drawing
1.9inch LCD Module 3D Drawing
1.9inch LCD Module 3D preview file
Demo
LCD Module code.zip
Software
Zimo221.7z
Image2Lcd2.9.zip
Image Extraction Turtorial
FAQ
Question:What is the maximum power consumption of the 1.9-inch LCD
Module?
Answer: 3.3V 40mA

Question:What is the maximum brightness of the 1.9inch LCD Module? Answer:
3.3V 380cd/
Support
If you require technical support, please go to the page and open a ticket.

References

Read User Manual Online (PDF format)

Loading......

Download This Manual (PDF format)

Download this manual  >>

WAVESHARE User Manuals

Related Manuals