Difference between revisions of "2inch LCD Module"
Line 8: | Line 8: | ||
|website_en=[https://www.waveshare.com/2inch-lcd-module.htm Website] | |website_en=[https://www.waveshare.com/2inch-lcd-module.htm Website] | ||
}} | }} | ||
+ | <div class="tabber"> | ||
+ | <div class="tabbertab" title="Instruction"> | ||
==Instruction== | ==Instruction== | ||
This is a general LCD display Module, IPS screen, 2inch diagonal, 240×320 resolution, with embedded controller, communicating via SPI interface | This is a general LCD display Module, IPS screen, 2inch diagonal, 240×320 resolution, with embedded controller, communicating via SPI interface | ||
Line 67: | Line 69: | ||
According to the figure above, data transmitting begins at the first falling edge, 8bit data are transmitted at one clock cycle. It is SPI0. MSB. | According to the figure above, data transmitting begins at the first falling edge, 8bit data are transmitted at one clock cycle. It is SPI0. MSB. | ||
− | + | </div> | |
+ | <div class="tabbertab" title="Guides for Pi"> | ||
==Raspberry Pi examples== | ==Raspberry Pi examples== | ||
For Raspberry Pi we provide examples based on C and python | For Raspberry Pi we provide examples based on C and python | ||
Line 167: | Line 170: | ||
#Display a 100x100 image | #Display a 100x100 image | ||
#display a 240x320 image | #display a 240x320 image | ||
+ | </div> | ||
+ | <div class="tabbertab" title="Guides for STM32"> | ||
==STM32 examples== | ==STM32 examples== | ||
*Download the demo codes from Waveshare wiki, the path of STM32 codes is ~/STM32/ | *Download the demo codes from Waveshare wiki, the path of STM32 codes is ~/STM32/ | ||
Line 232: | Line 237: | ||
#Draw five circles | #Draw five circles | ||
#Display a 70x70 image | #Display a 70x70 image | ||
− | + | </div> | |
+ | <div class="tabbertab" title="Guides for Arduino"> | ||
+ | {{2inch-LCD-Module-Arduino-Guides}} | ||
+ | </div> | ||
+ | <div class="tabbertab" title="Resources"> | ||
==Resources== | ==Resources== | ||
===Document=== | ===Document=== | ||
Line 241: | Line 250: | ||
===3D Drawing=== | ===3D Drawing=== | ||
*[https://www.waveshare.com/w/upload/9/93/2inch_LCD_Module_3D_Drawing.zip 2inch LCD Module 3D drawing] | *[https://www.waveshare.com/w/upload/9/93/2inch_LCD_Module_3D_Drawing.zip 2inch LCD Module 3D drawing] | ||
+ | </div> | ||
+ | <div class="tabbertab" title="FAQ"> | ||
==FAQ== | ==FAQ== | ||
{{FAQ|'''1. '''The LCD keeps black when using it with Raspberry Pi? | {{FAQ|'''1. '''The LCD keeps black when using it with Raspberry Pi? | ||
Line 249: | Line 260: | ||
|Please install image libraries and test it again. Run command: '''sudo apt-get install python-imaging''' to install it and test again. | |Please install image libraries and test it again. Run command: '''sudo apt-get install python-imaging''' to install it and test again. | ||
}} | }} | ||
− | + | </div> | |
+ | <div class="tabbertab" title="Support"> | ||
==Supports== | ==Supports== | ||
{{Service00}} | {{Service00}} |
Revision as of 04:01, 13 March 2021
| ||
Instruction
This is a general LCD display Module, IPS screen, 2inch diagonal, 240×320 resolution, with embedded controller, communicating via SPI interface
Feature
- SPI interface, requires minimum GPIO for controlling
- Comes with development resources and manual
Specifications
- Driver: ST7789
- Interface: SPI
- Display color: RGB, 262K color
- Resolution: 240×320
- Backlight: LED
- Operating voltage: 3.3V
Interface
SYMBOL | Description |
VCC | Power (3.3V input) |
GND | Ground |
DIN | SPI data input |
CLK | SPI clock input |
CS | Chip selection, low active |
DC | Data/Command selection (high for data, low for command) |
RST | Reset, low active |
BL | Backlight |
Hardware description
ST7789V supports RGB444, RGB565 and RGB666 three formats. This LCD uses RGB565.
For most of the LCD controller, there are several interfaces for choosing, this module we use SPI interface which is fast and simple.
Communication protocol
Note: It is not like the tradition SPI protocol, it only uses MOSI to send data from master to slave for LCD display. For details please refer to Datasheet Page 105.
RESX: Reset, should be pull-down when power on, set to 1 other time.
CSX: Slave chip select. The chip is enabled only CS is set Low
D/CX: Data/Command selection; DC=0, write command; DC=1, write data
SDA: Data transmitted. (RGB data)
SCL: SPI clock
The SPI communication protocol of the data transmission uses control bits: clock phase (CPHA) and clock polarity (CPOL):
CPOL defines the level while the synchronization clock is idle. If CPOL=0, then it is LOW.
CPHA defines at whish clock’s tick the data transmission starts. CPHL=0 – at the first one, otherwise at the second one
This combination of two bits provides 4 modes of SPI data transmission. The commonly used is SPI0 mode, i.e. GPHL=0 and CPOL=0.
According to the figure above, data transmitting begins at the first falling edge, 8bit data are transmitted at one clock cycle. It is SPI0. MSB.
Raspberry Pi examples
For Raspberry Pi we provide examples based on C and python
Enable SPI
Open terminal and run commands to enable SPI interface
sudo raspi-config
Choose Interfacing Options -> SPI -> Yes
Then reboot Raspberry Pi
Libraries installation
- BCM2835
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz tar zxvf bcm2835-1.60.tar.gz cd bcm2835-1.60/ sudo ./configure sudo make sudo make check sudo make install
- WiringPi
sudo apt-get install wiringpi cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v
- Python2
sudo apt-get updata sudo apt-get install python-pip sudo pip install RPi.GPIO sudo pip install spidev sudo apt-get install python-imaging
- Python3
sudo apt-get update sudo apt-get install python3-pip sudo pip3 install RPi.GPIO sudo pip3 install spidev sudo apt-get install python3-imaging
Hardware connection
Please notice, that wires colors may vary. Use pins designations for wiring.
2inch LCD | Board number | BCM number |
VCC | 3.3V | 3.3V |
GND | GND | GND |
DIN | 19 | MOSI |
CLK | 23 | SCLK |
CS | 24 | CE0 |
DC | 22 | P25 |
RST | 13 | P27 |
BL | 12 | P18 |
Download examples
Open terminal and download examples
sudo apt-get install p7zip-full wget http://www.waveshare.net/w/upload/1/19/2inch_LCD_Module_code.7z 7z x 2inch_LCD_Module_code.7z -r -o./2inch_LCD_Module_code sudo chmod 777 -R 2inch_LCD_Module_code cd 2inch_LCD_Module_code/RaspberryPi\&JetsonNano/
Test examples
- C codes
cd c sudo make clean sudo make sudo ./main
- Python codes
cd python/examples sudo python main.py
Expected result
- The display is cleaned to white
- Display numbers and strings
- Draw a rectangle
- Draw a line
- Draw five circles
- Display a 100x100 image
- display a 240x320 image
STM32 examples
- Download the demo codes from Waveshare wiki, the path of STM32 codes is ~/STM32/
- Open the project from \XNUCLEO-F103RB\MDK-ARM\ with Keil software. Note that the codes are based on HAL libraries.
- The development board we use is WaveshareXNUCLEO-F103RB
Hardware connection
2inch LCD | XNUCLEO-F103RB |
VCC | 5V |
GND | GND |
DIN | PA7 |
CLK | PA5 |
CS | PB6 |
DC | PA8 |
RST | PA9 |
BL | PC7 |
Expected result
- The display is cleaned to white
- Display numbers and strings
- Draw a rectangle
- Draw a line
- Draw five circles
- Display a 70x70 image
Arduino
- Download examples from wiki. Unzip it. The path of Arduino examples is ~/Arduino UNO/...
- Copyt the folders in Arduino directory to 【Installation directory】/libraries/ (Generally the installation directory is C:\Program Files (x86)\Arduino\libraries)
- Open Arduino IDE software, and click File -> Examples to check if LCD_2inch codes are there.
- The development board used is Arduino UNO.
Hardware connection
2inch LCD | UNO PLUS |
VCC | 5V |
GND | GND |
DIN | D11 |
CLK | D12 |
CS | D10 |
DC | D7 |
RST | D8 |
BL | D9 |
Expected result
- The display is cleaned to white
- Display numbers and strings
- Draw a rectangle
- Draw a line
- Draw five circles
- Display a 70x70 image
The examples are tested in Arduino UNO, if you want to use other versions of the Arduino, you need to change the connection according to the actual boards.
Hardware Connection
LCD | UNO |
VCC | 5V |
GND | GND |
DIN | D11 |
CLK | D13 |
CS | D10 |
DC | D7 |
RST | D8 |
BL | D9 |
Run the example
Download the demo codes and unzip it. The Arduino project is located in ~/Arduino/…
Run the project according to the actual display type
For examples: 1.54inch LCD Module. Enter the LCD_1inch54 directory and run the LCD_1inch54.ino file
Run the project and choose Arduino UNO as Board
Select the COM Port according to your Device Manager
Compile and download it to your board
FAQ
b)Check BL pin, if BL pin has no output value, you can try to disconnect BL pin and test it again.
{{{5}}}
{{{5}}}