Difference between revisions of "Template:1.3inch LCD HAT User Manual"
Line 90: | Line 90: | ||
==FBCP Driver== | ==FBCP Driver== | ||
+ | <div class="cautionSec">PS: FBCP is currently not compatible with 64-bit Raspberry Pi system, it is recommended to use 32-bit system. </div> | ||
The Framebuffer uses a memory area to store the display content, and changes the data in the memory to change the display content. | The Framebuffer uses a memory area to store the display content, and changes the data in the memory to change the display content. | ||
Revision as of 09:31, 3 January 2023
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 SPI interface was not used by other devices, you can check in the /boot/config.txt
Install Libraries
- Install BCM2835 libraries
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz tar zxvf bcm2835-1.68.tar.gz cd bcm2835-1.68/ sudo ./configure && sudo make && sudo make check && sudo make install #For more details, please refer to http://www.airspayce.com/mikem/bcm2835/
- Install wiringPi libraries
# Open the Raspberry Pi terminal and run the following command sudo apt-get install wiringpi # For Raspberry Pi systems after May 2019 (earlier than before, you may not need to execute), you may need to upgrade: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v # Run gpio -v and version 2.52 will appear. If it does not appear, the installation is wrong #Bullseye branch system use the following command: git clone https://github.com/WiringPi/WiringPi cd WiringPi ./build gpio -v # Run gpio -v and version 2.60 will appear. If it does not appear, it means that there is an installation error
- Install Python libraries
#Python2 sudo apt-get update sudo apt-get install ttf-wqy-zenhei sudo apt-get install python-pip sudo pip install RPi.GPIO sudo pip install spidev #Python3 sudo apt-get update sudo apt-get install ttf-wqy-zenhei sudo apt-get install python3-pip sudo pip3 install RPi.GPIO sudo pip3 install spidev
Download Examples
Open Raspberry Pi terminal and run the following command
sudo apt-get install p7zip-full -y wget https://www.waveshare.com/w/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://www.waveshare.com/w/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.3inch LCD in proportion. The setting of the resolution here should be slightly larger than the LCD resolution, the 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://www.waveshare.com/w/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