Difference between revisions of "1.3inch LCD HAT"
m (Text replacement - "{{#urlget:amazon|default}}=display" to "{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display") |
(→FAQ) |
||
(25 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | <div class="wiki-pages jet-green-color"> | ||
{{Infobox item|colorscheme=green | {{Infobox item|colorscheme=green | ||
− | |img=[[File:1.3inch-LCD-HAT-1.jpg|300px|{{Amazon_nolink|default={{#urlget:amazon|default}}|url=link=https://www.waveshare.com/1.3inch-lcd-hat.htm}} | + | |img=[[File:1.3inch-LCD-HAT-1.jpg|300px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/1.3inch-lcd-hat.htm?amazon}}]] |
|caption=1.3inch IPS LCD HAT, SPI interfaces | |caption=1.3inch IPS LCD HAT, SPI interfaces | ||
|category=[[:Category:OLEDs / LCDs|OLEDs / LCDs]], | |category=[[:Category:OLEDs / LCDs|OLEDs / LCDs]], | ||
Line 6: | Line 7: | ||
|{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display | |{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display | ||
|website_cn=[http://www.waveshare.net/shop/1.3inch-LCD-HAT.htm 官方中文站点] | |website_cn=[http://www.waveshare.net/shop/1.3inch-LCD-HAT.htm 官方中文站点] | ||
− | |website_en=[https://www.waveshare.com/1.3inch-lcd-hat.htm Waveshare Website] | + | |website_en=[https://www.waveshare.com/1.3inch-lcd-hat.htm?amazon Waveshare Website] |
|interface21 = SPI | |interface21 = SPI | ||
|related= | |related= | ||
{{Product List|OLEDs / LCDs/OLED}} | {{Product List|OLEDs / LCDs/OLED}} | ||
}} | }} | ||
− | + | ||
− | |||
== Introduction == | == Introduction == | ||
Line 20: | Line 20: | ||
*LCD type: IPS | *LCD type: IPS | ||
*Controller: ST7789VM | *Controller: ST7789VM | ||
− | *Resolution: 240(H)RGB x 240(V) | + | *Resolution: 240 (H) RGB x 240 (V) |
*Display size: 23.4(H)x 23.4(V)mm | *Display size: 23.4(H)x 23.4(V)mm | ||
*Pixel size: 0.0975(H)x 0.0975(V)mm | *Pixel size: 0.0975(H)x 0.0975(V)mm | ||
Line 27: | Line 27: | ||
===Pinout=== | ===Pinout=== | ||
{|border=1; style="width:700px;text-align:center" align="center"; | {|border=1; style="width:700px;text-align:center" align="center"; | ||
− | |-style="background:# | + | |-style="background:#228B22; color:white;" align="center" |
|PIN||Raspberry Pi Interface (BCM)||Description | |PIN||Raspberry Pi Interface (BCM)||Description | ||
|- | |- | ||
Line 61: | Line 61: | ||
===LCD and the controller=== | ===LCD and the controller=== | ||
The ST7789VW is a single-chip controller/driver for 262K-color, graphic type TFT-LCD. It consists of 240 | The ST7789VW is a single-chip controller/driver for 262K-color, graphic type TFT-LCD. It consists of 240 | ||
− | source line and 320 gate line driving circuits. The resolution of this LCD is 240(H)RGB x 240(V), it supports horizontal mode and vertical mode, and it doesn't use all the RAM of controller.<br /> | + | source line and 320 gate line driving circuits. The resolution of this LCD is 240 (H) RGB x 240(V), it supports horizontal mode and vertical mode, and it doesn't use all the RAM of the controller.<br /> |
This LCD accepts 8-bits/9-bits/16-bits/18-bits parallel interface, that are RGB444, RGB565, RGB666. The color format used in demo codes is RGB565.<br /> | This LCD accepts 8-bits/9-bits/16-bits/18-bits parallel interface, that are RGB444, RGB565, RGB666. The color format used in demo codes is RGB565.<br /> | ||
− | This LCD use 4- | + | This LCD use a 4-line SPI interface for reducing GPIO and fast speed.LCD<br /> |
===Working Protocol=== | ===Working Protocol=== | ||
Line 77: | Line 77: | ||
CPHA determines whether data is collected at the first clock edge or at the second clock edge of serial synchronous clock; when CPHL = 0, data is collected at the first clock edge.<br /> | CPHA determines whether data is collected at the first clock edge or at the second clock edge of serial synchronous clock; when CPHL = 0, data is collected at the first clock edge.<br /> | ||
There are 4 SPI communication modes. SPI0 is commonly used, in which CPHL = 0, CPOL = 0.<br /> | There are 4 SPI communication modes. SPI0 is commonly used, in which CPHL = 0, CPOL = 0.<br /> | ||
− | + | ||
<div class="tabbertab" title="Guides for Pi"> | <div class="tabbertab" title="Guides for Pi"> | ||
{{1.3inch LCD HAT User Manual}} | {{1.3inch LCD HAT User Manual}} | ||
− | |||
− | |||
+ | |||
+ | ==Others== | ||
+ | For connecting to the game machine, you can refer to the following links:<br/> | ||
+ | https://www.sudomod.com/forum/viewtopic.php?f=11&t=5371&start=10<br/> | ||
+ | https://pi0cket.com/guides/tiny-software-for-tinypi/#more-99 | ||
+ | =Resource= | ||
==Document== | ==Document== | ||
− | + | *[https://files.waveshare.com/upload/6/6b/1.3inch_lcd_hat_user_manual_en.pdf User Manual] | |
− | *[ | + | *[https://files.waveshare.com/upload/a/a6/1.3inch-LCD-HAT-Schematic.pdf Schematic] |
− | *[ | ||
*[https://wavesharejfs.blogspot.com/2018/03/raspberry-pi-driv-144inch-lcd-hat-with.html Display Desktop of Pi Study Manual] | *[https://wavesharejfs.blogspot.com/2018/03/raspberry-pi-driv-144inch-lcd-hat-with.html Display Desktop of Pi Study Manual] | ||
− | + | ==Demo== | |
− | *[ | + | *[https://files.waveshare.com/upload/b/bd/1.3inch_LCD_HAT_code.7z Demo code] |
− | *[ | + | *[https://files.waveshare.com/upload/d/d3/Mouse.7z Analog mouse] |
− | + | ==Relate Resources== | |
*[https://github.com/PiSugar/pisugar-case-pihat-cap Pisugar case for 1.3inch LCD HAT] | *[https://github.com/PiSugar/pisugar-case-pihat-cap Pisugar case for 1.3inch LCD HAT] | ||
+ | ==Software== | ||
+ | *[https://files.waveshare.com/upload/7/78/LcmZimo.zip lcd] | ||
+ | *[https://files.waveshare.com/upload/b/bd/Image2Lcd2.9.zip Image2Lcd] | ||
− | == | + | ==Datashee == |
− | *[ | + | *[https://files.waveshare.com/upload/a/ae/ST7789_Datasheet.pdf ST7789VM] |
− | </ | + | =FAQ= |
− | + | {{FAQ|Setting fbtft does not recognize fb1, or the screen does not display? | |
− | + | |[[File:LCD HAT-FAQ.PNG]]<BR/> | |
− | + | Note: these two statements start with OPTIONS. | |
+ | }} | ||
+ | {{FAQ|Why is the program-controlled after setting fbtft, and the error is reported that there is no SPI device | ||
+ | |These are two control methods. After setting to fbtft control, the SPI is occupied by the system, and the screen can no longer be controlled by operating the IO. You must block the /etc/module and change. | ||
+ | flexfb | ||
+ | fbtft_device | ||
+ | to | ||
+ | #flexfb | ||
+ | #fbtft_device | ||
+ | Then restart the raspberry pi | ||
+ | }} | ||
{{FAQ|How to play a video? | {{FAQ|How to play a video? | ||
− | |To play a video, you must first set fbtft, and set fbtft to display the desktop through f, and then run the play video command to display | + | |To play a video, you must first set fbtft, and set fbtft to display the desktop through f, and then run the play video command to display. |
}} | }} | ||
+ | {{FAQ|When executing fbcp file, vc_dispmanx_display_open failed!? | ||
+ | |Just comment out the kms driver.<BR/> | ||
+ | [[File:1.3inch LCD HAT FAQ.jpg]] | ||
+ | ||}} | ||
+ | {{FAQ|How does it connect to a 30-pin esp32 module?<br/>[[File:1.3INCH FAQ.jpg]] | ||
+ | | | ||
+ | Wiring Connection LCD and EPS32 board: | ||
+ | LCD -> ESP32 | ||
+ | DIN -> 23 | ||
+ | CLK -> 18 | ||
+ | CS -> 5 | ||
+ | DC -> 4 | ||
+ | RST -> 0 | ||
+ | ||}} | ||
− | + | =Support= | |
− | + | {{Servicebox1}} | |
− | |||
− | {{ | ||
− | |||
</div> | </div> |
Latest revision as of 06:40, 8 April 2024
| ||
Introduction
Specification
- Operating voltage: 3.3V
- Interface: SPI
- LCD type: IPS
- Controller: ST7789VM
- Resolution: 240 (H) RGB x 240 (V)
- Display size: 23.4(H)x 23.4(V)mm
- Pixel size: 0.0975(H)x 0.0975(V)mm
- Dimension: 65 x 30.2(mm)
Pinout
PIN | Raspberry Pi Interface (BCM) | Description |
KEY1 | P21 | KEY1GPIO |
KEY2 | P20 | KEY2GPIO |
KEY3 | P16 | KEY3GPIO |
Joystick UP | P6 | Upward direction of the Joystick |
Joystick Down | P19 | Downward direction of the Joystick |
Joystick Left | P5 | Left direction of the Joystick |
Joystick Right | P26 | Right direction of the Joystick |
Joystick Press | P13 | Press the Joystick |
SCLK | P11/SCLK | SPI clock line |
MOSI | P10/MOS | SPI data line |
CS | P8/CE0 | Chip selection |
DC | P25 | Data/Command control |
RST | P27 | Reset |
BL | P24 | Backlight |
LCD and the controller
The ST7789VW is a single-chip controller/driver for 262K-color, graphic type TFT-LCD. It consists of 240
source line and 320 gate line driving circuits. The resolution of this LCD is 240 (H) RGB x 240(V), it supports horizontal mode and vertical mode, and it doesn't use all the RAM of the controller.
This LCD accepts 8-bits/9-bits/16-bits/18-bits parallel interface, that are RGB444, RGB565, RGB666. The color format used in demo codes is RGB565.
This LCD use a 4-line SPI interface for reducing GPIO and fast speed.LCD
Working Protocol
Note: Different from the traditional SPI protocol, the data line from the slave to the master is hidden since the device only has display requirement.
RESX Is the reset pin, it should be low when powering the module and be higher at other times;;
CSX is slave chip select, when CS is low, the chip is enabled.
D/CX is data/command control pin, when DC = 0, write command, when DC = 1, write data
SDA is the data pin for transmitting RGB data, it works as the MOSI pin of SPI interface;
SCL worka s the SCLK pins of SPI interface.
SPI communication has data transfer timing, which is combined by CPHA and CPOL.
CPOL determines the level of the serial synchronous clock at idle state. When CPOL = 0, the level is Low. However, CPOL has little effect to the transmission.
CPHA determines whether data is collected at the first clock edge or at the second clock edge of serial synchronous clock; when CPHL = 0, data is collected at the first clock edge.
There are 4 SPI communication modes. SPI0 is commonly used, in which CPHL = 0, CPOL = 0.
Working with Raspberry pi
We provide C and python examples
Enable SPI interface
- Open terminal, use command to enter the configuration page
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable SPI interface
sudo reboot
Please make sure that the SPI interface was not used by other devices, you can check in the /boot/config.txt
Install Library
If you use the bookworm system, you can only use lgpio library, bcm2835 and wiringPi can't be installed and used.
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, you can refer to the official website at: http://www.airspayce.com/mikem/bcm2835/
WiringPi
#Open the Raspberry Pi terminal and run the following command cd sudo apt-get install wiringpi #For Raspberry Pi systems after May 2019 (earlier than that can be executed without), 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 doesn't it means there was an installation error # Bullseye branch system using the following command: git clone https://github.com/WiringPi/WiringPi cd WiringPi . /build gpio -v # Run gpio -v and version 2.70 will appear, if it doesn't it means there was an installation error
lgpio
#Open the Raspberry Pi terminal and run the following command wget https://github.com/joan2937/lg/archive/master.zip unzip master.zip cd lg-master sudo make install # You can refer to the official website for more: https://github.com/gpiozero/lg
Python
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 spidev
Download Examples
Open the Raspberry Pi terminal and run the following command:
sudo apt-get install p7zip-full -y wget https://files.waveshare.com/upload/b/bd/1.3inch_LCD_HAT_code.7z 7z x 1.3inch_LCD_HAT_code.7z -r -o./1.3inch_LCD_HAT_code sudo chmod 777 -R 1.3inch_LCD_HAT_code cd 1.3inch_LCD_HAT_code
Run the demo
- C
cd c make clean make sudo ./main
- For Raspberry Pi 4B and system version after raspbian_lite-2019-06-20, please set as following for normal input:
sudo nano /boot/config.txt
And then add the following line at the end of the config.txt.
gpio=6,19,5,26,13,21,20,16=pu
- python
cd python sudo python main.py sudo python key_demo.py
FBCP Driver
The Framebuffer uses a memory area to store the display content, and changes the data in the memory to change the display content.
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 refresh rate of up to 60fps.
Compile and Run
cd ~ sudo apt-get install cmake -y sudo apt-get install p7zip-full -y wget https://files.waveshare.com/upload/f/f9/Waveshare_fbcp.7z 7z x Waveshare_fbcp.7z -o./waveshare_fbcp cd waveshare_fbcp mkdir build cd build
If you are using 1.44inch_LCD_HAT:
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH44_LCD_HAT=ON -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..
If you are using 1.3inch_LCD_HAT:
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH3_LCD_HAT=ON -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..
Then
make -j sudo ./fbcp
Auto-start when Power on
sudo cp ~/waveshare_fbcp/build/fbcp /usr/local/bin/fbcp sudo nano /etc/rc.local
And then add fbcp& before exit 0, as the picture below.
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=300 300 60 1 0 0 0 hdmi_group=2 hdmi_mode=87 display_rotate=0
【Note】If you are using Raspberry Pi 4B, you need to comment out the following lines on the [pi4] part. The modification is as below:
[pi4] # Enable DRM VC4 V3D driver on top of the dispmanx display stack #dtoverlay=vc4-fkms-v3d #max_framebuffers=2
And then reboot the system:
sudo reboot
The final display effect is scaled and displayed on the 1.3-inch LCD in proportion. The setting of the resolution here should be slightly larger than the LCD resolution, too high resolution will cause the font display to be blurred.
After rebooting the system, the Raspberry Pi OS user interface will be displayed.
Analog Mouse
There are a joystick and three buttons on the panel of the module, which we can use to control the mouse of the Raspberry Pi
- Install the library, then download and run the demo
#python2 sudo apt-get install python-xlib sudo pip install PyMouse wget https://files.waveshare.com/upload/d/d3/Mouse.7z 7z x Mouse.7z sudo python mouse.py #python3 sudo apt-get install python3-xlib sudo pip3 install PyMouse sudo pip3 install unix sudo pip3 install PyUserInput wget http://www.waveshare.net/w/upload/d/d3/Mouse.7z 7z x Mouse.7z sudo python3 mouse.py
- 【Note】The mouse.py needs to run under the graphical interface, which will not run under the SSH login. You can skip this step directly, the Pi will run the demo automatically by booting up.
- If you are using the Raspberry PI 4B and the version of your image is after raspbian_lite-2019-06-20, you need to set as below:
sudo nano /boot/config.txt
And then add the following line at the end of the config.txt.
gpio=6,19,5,26,13,21,20,16=pu
Use the joystick to move up, down, left, and right, you can see that the mouse is moving.
- Set the auto-start when power on
cd .config/ mkdir autostart cd autostart/ sudo nano local.desktop
And then add the following lines at the end of the local.desktop
#python2 [Desktop Entry] Type=Application Exec=python /home/pi/mouse.py #python3 [Desktop Entry] Type=Application Exec=python3 /home/pi/mouse.py
Reboot the system, you can use the buttons to control the mouse.
sudo reboot
Others
For connecting to the game machine, you can refer to the following links:
https://www.sudomod.com/forum/viewtopic.php?f=11&t=5371&start=10
https://pi0cket.com/guides/tiny-software-for-tinypi/#more-99
Resource
Document
Demo
Relate Resources
Software
Datashee
FAQ
flexfb fbtft_device
to
#flexfb #fbtft_device
Then restart the raspberry pi
{{{5}}}
{{{5}}}
Wiring Connection LCD and EPS32 board: LCD -> ESP32 DIN -> 23 CLK -> 18 CS -> 5 DC -> 4 RST -> 0
{{{5}}}
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 AM GMT+8 (Monday to Friday)