Difference between revisions of "Template:Raspberry Pi Guides for SPI e-Paper"

From Waveshare Wiki
Jump to: navigation, search
m (Text replacement - "https://www.waveshare.com/w/upload/" to "https://files.waveshare.com/upload/")
 
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
=Users Guides of Raspberry Pi=
+
 
 +
=Working With Raspberry Pi=
 +
Provide BCM2835, WiringPi, file IO, RPI (Python) library demos.
 
==Hardware connection==
 
==Hardware connection==
If the e-Paper you have is the HAT version which has 40pin GPIO, you can directly attach the e-Paper HAT on Raspberry Pi, otherwise, you can connect your e-Paper to Raspberry Pi by 8pins cable provided.
+
When connecting the Raspberry Pi, if the driver board has a 40pin header, you can directly plug it into the 40PIN header of the Raspberry Pi, and pay attention to the pins. If you choose to connect with an 8PIN cable, please refer to the pin correspondence table below<br />
:To connect the e-Paper, you can following the table below:
+
For the 1.02inch e-paper Module, the pin header is used, and the wiring needs to be connected according to the following table<br />
{|border=1; style="width:600px;" align="center"
+
{|border=1; style="width:100%; max-width:700px;" align="center"
|+Connect to Raspberry Pi
+
|+ Correspondence between connecting pins of Raspberry Pi
|- style="background:#228B22; color:white" align="center"
+
|- style="background:green; color:white" align="center"
 
|rowspan="2"|e-Paper
 
|rowspan="2"|e-Paper
 
| colspan="2" | Raspberry Pi
 
| colspan="2" | Raspberry Pi
|- style="background:#228B22; color:white" align="center"
+
|- style="background:green; color:white" align="center"
|BCM2835||Board
+
|BCM2835 encoding
 +
|Board physical pin number
 
|- align="center"
 
|- align="center"
 
|VCC||3.3V||3.3V
 
|VCC||3.3V||3.3V
Line 27: Line 30:
 
|BUSY||24||18
 
|BUSY||24||18
 
|}
 
|}
Take the 7.5inch HD e-Paper (B) connected to the e-paper Driver HAT as an example, just plug it directly into the Raspberry Pi:<br/>
 
[[File:7.5inchrasp.png]]<br/>
 
  
==Enable SPI interface==
+
Take the 7.5inch HD e-Paper (B) connected to the e-paper Driver HAT as an example, just plug it directly into the Raspberry Pi:<br />
 +
[[file:7.5inch_e-Paper(B)800-480_1.jpg|700px]]
  
: The communication interface of e-Paper is SPI, to use it, we should firstly enable the SPI interface.
+
==Enable SPI Interface==
: Open terminal of Raspberry Pi, and open the configuration by the following command:
+
*Open the Raspberry Pi terminal and enter the following command in the config interface:
sudo raspi-config
+
<pre>
:Choose Interfacing Options -> SPI -> Yes
+
sudo raspi-config
: Restart Raspberry Pi
+
Choose Interfacing Options -> SPI -> Yes Enable SPI interface
 +
</pre>
 +
[[File:RPI open spi.png|500px]]<br/>
 +
Then reboot your Raspberry Pi:<br/>
 
  sudo reboot
 
  sudo reboot
[[File:RPI open spi.png]]<br/>
+
*Check /boot/config.txt, and you can see 'dtparam=spi=on' was written in.
 
+
[[File:Raspberry Pi Guides for 4.37 e-Paper.jpg]]
==Install libraries==
+
*To make sure SPI is not occupied, it is recommended to close other drivers' coverage. You can use ls /dev/spi* to check whether SPI is occupied. If the terminal outputs /dev/spidev0.1 and /dev/spidev0.1, SPI is not occupied.
<div class="cautionSec">Note: If you use the Bullseye image, please use "apt" instead of "apt-get" to install libraries, the Bullseye image could only support "ptyhon3".</div>
+
[[File:Raspberry Pi Guides for 4.37 e-Paper02.jpg]]
</font>
+
==Install Library==
<br />
+
===Install BCM2835===
Open the terminal of Raspberry Pi and run the following commands to install corresponding libraries:
 
*Install BCM2835 libraries:
 
 
<pre>
 
<pre>
 
#Open the Raspberry Pi terminal and run the following command
 
#Open the Raspberry Pi terminal and run the following command
Line 54: Line 57:
 
# For more information, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/
 
# For more information, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/
 
</pre>
 
</pre>
*Install WiringPi libraries:
+
*Install WiringPi  
#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
 
</pre>
 
*Install Python2 libraries:
 
 
<pre>
 
<pre>
sudo apt-get update
+
#Open the Raspberry Pi terminal and run the following command:
sudo apt-get install python-pip
+
sudo apt-get install wiringpi
sudo apt-get install python-pil
+
#For Raspberry Pi systems after May 2019 (Earlier than the previous can not be implemented), an upgrade may be required to:
sudo apt-get install python-numpy
+
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo pip install RPi.GPIO
+
sudo dpkg -i wiringpi-latest.deb
sudo pip install spidev
+
gpio -v
</pre>
+
#Running gpio -v will bring up version 2.52, if it doesn't, it means there was an installation error.
*Install Python3 libraries:
+
 
<pre>
+
#The Bullseye branch system uses the following command:
sudo apt-get update
+
git clone https://github.com/WiringPi/WiringPi
sudo apt-get install python3-pip
+
cd WiringPi
sudo apt-get install python3-pil
+
./build
sudo apt-get install python3-numpy
+
gpio -v
sudo pip3 install RPi.GPIO
+
# Run gpio -v and version 2.60 will appear, if it does not appear, it means there is an installation error
sudo pip3 install spidev
 
 
</pre>
 
</pre>
 
+
*Download program (already downloaded can be skipped):
==Download demo codes==
 
Open the Raspberry Pi terminal and execute:<br/>
 
Method 1: Download from Waveshare:
 
 
<pre>
 
<pre>
 
sudo apt-get install p7zip-full
 
sudo apt-get install p7zip-full
wget  https://www.waveshare.com/w/upload/3/39/E-Paper_code.7z
+
wget  https://files.waveshare.com/upload/3/39/E-Paper_code.7z
 
7z x E-Paper_code.7z -O./e-Paper
 
7z x E-Paper_code.7z -O./e-Paper
 
cd e-Paper/RaspberryPi_JetsonNano/
 
cd e-Paper/RaspberryPi_JetsonNano/
 
</pre>
 
</pre>
Method 2: Use GitHub  
+
*Downloading the program via GitHub (alternate method, you can skip it if you've already downloaded it).<br/>
 +
Access to GitHub is not very smooth at the moment, so we recommend downloading from our website using the method above.
 
<pre>
 
<pre>
git clone https://github.com/waveshare/e-Paper
+
git clone https://github.com/waveshare/e-Paper.git
 
cd e-Paper/RaspberryPi_JetsonNano/
 
cd e-Paper/RaspberryPi_JetsonNano/
 
</pre>
 
</pre>
 
+
Compile the program (Note: -j4 is compiled using 4 threads, the number can be modified; EPD=epd1in02d is to specify a macro definition, epd1in02d corresponds to the test program in the main function).
==Examples==
 
===C===
 
[[File:RPI Guide for e-Paper02.png|thumb|right]]
 
Open main. c to select the screen of the corresponding size.
 
 
<pre>
 
<pre>
 +
# At this point in the e-Paper/RaspberryPi_JetsonNano
 
cd c
 
cd c
sudo nano examples/main.c
+
sudo make clean
</pre>
+
sudo make -j4 EPD=epd1in02d
If you are using 2.7inch e-paper, then remove the // in front of the EPD_2IN7_test() function, then press Ctrl+c, press the Y key and Enter to save and exit, as shown in the figure: (The picture may not be updated. Timely, subject to the specific demo).<br/>
 
Supporting types:<br/>
 
;1.02inch(128 × 80):
 
EPD_1in02d_test():Example for 1.02inch e-Paper/1.02inch e-Paper Module
 
 
 
;1.54inch(1.54inch e-paper c:152 × 152,others:200 × 200):
 
EPD_1in54_test(): Example for 1.54inch e-paper V1(Balck/<font color="#DCDCDC">White</font>): This version was discontinued.<br />
 
EPD_1in54_V2_test(): Example for 1.54inch e-paper V2(Balck/<font color="#DCDCDC">White</font>): Purchase date later than November 2019 is the V2 version, the current shipping version has the V2 logo on the back.<br />
 
EPD_1in54b_test(): Example for 1.54inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). It is currently out of production.<br />
 
EPD_1in54b_V2_test(): Example for 1.54inch e-Paper B V2 (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date later than November 2019 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
EPD_1in54c_test(): Example for 1.54inch e-paper C(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>); <br />
 
 
 
;1.64inch(168 × 168):
 
EPD_1in64g_test(): Example for 1.64inch e-paper G (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>)<br/>
 
 
 
;2.7inch(264 × 176):
 
EPD_2in7_test(): Example for 2.7inch e-paper(Black/<font color="#DCDCDC">White</font>);<br />
 
EPD_2in7b_test(): Example for 2.7inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>);<br />
 
EPD_2in7b_V2_test(): Example for 2.7inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than February 2021 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
 
 
;2.9inch (296 × 128):
 
EPD_2in9_test(): Example for 2.9inch e-paper (Black/<font color="#DCDCDC">White</font>), this version was discontinued.<br />
 
EPD_2in9_V2_test(): Example for 2.9inch e-paper V2(Black/<font color="#DCDCDC">White</font>); The purchase date is later than December 2020 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
EPD_2in9bc_test(): Example for 2.9inch e-paper B(Balck/<font color="#DCDCDC">White</font>/Red) and 2.9inch e-paper C(Black/<font color="#DCDCDC">White</font>/<font color="#FFD700">Yellow</font>);<br />
 
EPD_2in9b_V3_test(): Example for 2.9inch e-paper B V3 (Balck/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>); Purchase date later than July 2020 is the V3 version, the current shipping version has the V3 logo on the back;<br />
 
EPD_2in9d_test(): Example for 2.9inch e-paper D(Black/<font color="#DCDCDC">White</font>);
 
 
 
;2.13inch(2.13inch e-Paper:250 × 122,others:212 × 104):
 
EPD_2in13_test(): Example for 2.13inch e-paper V1(Black/<font color="#DCDCDC">White</font>), this version was discontinued.<br />
 
EPD_2in13_V2_test(): Example for 2.13inch e-paper V2(Black/<font color="#DCDCDC">White</font>). The purchase date is later than May 2019, the V2 version is currently discontinued, and the V2 logo is affixed on the back;<br />
 
EPD_2in13_V3_test(): Example for 2.13inch e-paper V3(Black/<font color="#DCDCDC">White</font>) This is the current version with sticker V3 on the backside (2020-07-29);<br />
 
EPD_2in13bc_test():Example for 2.13inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)and 2.13inch e-paper C(Blackj/<font color="#DCDCDC">White</font>/Yellow);<br />
 
EPD_2in13b_V3_test():Example for 2.13inch e-paper B V3(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)Purchase date later than April 2020 is the V3 version, the current shipping version has the V3 logo on the back;<br/>
 
EPD_2in13d_test(): Example for 2.13inch e-paper D(Black/<font color="#DCDCDC">White</font>);<br />
 
 
 
;2.66inch (152 × 296):
 
EPD_2in66_test(): Example for 2.66inch e-Paper (Black/<font color="#DCDCDC">White</font>);<br />
 
EPD_2in66b_test(): Example for 2.66inch e-Paper B (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>); <br />
 
 
 
;3inch (400 × 168):
 
EPD_3in0g_test(): Example for 3inch e-Paper G(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>); <br />
 
 
 
;3.52inch (360 × 240):
 
EPD_3in52_test(): Example for 3.52inch e-Paper (Black/<font color="#DCDCDC">White</font>); <br />
 
 
 
;3.7inch (280 × 480):
 
EPD_3in7_test(): Example for 3.7inch e-Paper(Black/<font color="#DCDCDC">White</font>); <br />
 
 
 
;4.01inch (640 × 400):
 
EPD_4in01_test(): Example for the 4.01inch e-Paper HAT (F) (Black/<font color="#DCDCDC">White</font>/<font color="#008000">Green</font>/<font color="#0000FF">Blue</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>/<font color="#FFCC00">Orange</font>);<br />
 
 
 
;4.2inch(400 × 300):
 
EPD_4in2_test(): Example for 4.2inch e-paper(Black/<font color="#DCDCDC">White</font>);<br />
 
EPD_4in2bc_test(): Example for 4.2inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>);<br />
 
EPD_4in2b_V2_test(): Example for 4.2inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than November 2020, it is the V2 version, and the current shipping version has the V2 logo on the back;<br />
 
 
 
;5.65inch (600 × 558):
 
EPD_5in65f_test(): Example for for 5.65inch e-Paper F (Black/<font color="#DCDCDC">White</font>/<font color="#008000">Green</font>/<font color="#0000FF">Blue</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>/<font color="#FFCC00">Orange</font>);
 
 
 
;5.83inch(600 × 448):
 
EPD_5in83_test(): Example for 5.83inch e-paper(Black/<font color="#DCDCDC">White</font>), It is currently out of production.<br />
 
EPD_5in83_V2_test(): Example for 5.83inch e-paper V2(Black/<font color="#DCDCDC">White</font>), The purchase date is later than December 2020 is the V2 version, the current shipping version, with the V2 logo on the back.<br />
 
EPD_5in83bc_test(): Example for 5.83inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)and 5.83inch e-paper C(Black/<font color="#DCDCDC">White</font>/<font color="#FFD700">Yellow</font>);<br />
 
EPD_5in83b_V2_test(): Example for 5.83inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than August 2020 for the V2 version, the current shipping version, with the V2 logo on the back.<br />
 
 
 
;7.3inch (800 × 480):
 
epd_7in3g_test.py: Example for 7inch3 e-paper G (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>).
 
 
 
;7.5inch(V1:640 × 384, V2:800 × 480):
 
EPD_7in5_test(): Example for 7.5inch e-paper(Black/<font color="#DCDCDC">White</font>). The purchase date is earlier than 2019-12-07 as the V1 version, which is currently discontinued.<br />
 
EPD_7in5bc_test(): For example for 7.5inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)and 7.5inch e-paper C(Black/<font color="#DCDCDC">White</font>/<font color="#FFD700">Yellow</font>), The purchase date later than 2019-12-07 is the V2 version, and the current shipping version has the V2 logo on the back;<br />
 
EPD_7in5_V2_test(): Example for 7.5inch e-paper V2(Black/<font color="#DCDCDC">White</font>). The purchase date of 7.5inch e-paper B is earlier than 2019-12-07, which is the V1 version, which is currently discontinued, and 7.5inch e-paper C is normally available.<br/>
 
 
 
EPD_7in5bc_V2_test(): Example for 7.5inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>); The purchase date is later than 2019-12-07 is the V2 version, with the V2 logo on the back; the purchase date is later than March 2021 is the V3 version, the current 7.5inch e-paper B shipping version, with the V3 logo on the back, the same use this program;<br />
 
 
 
;7.5inch (880 × 528)
 
EPD_7in5_HD_test(): Example for 7.5inch e-Paper HD (Black/<font color="#DCDCDC">White</font>); <br />
 
EPD_7in5b_HD_test(): Example for 7.5inch e-Paper B HD (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>); <br />
 
 
 
<font backgound=white; color=#DD1223>*Note: The above time is for reference only, please refer to the screen logo for the specific version.</font><br/>
 
*Recompile, the compilation process may take a few seconds<br/>
 
<pre>
 
Return to the c directory and run the following command
 
make clean
 
make
 
sudo ./epd
 
 
</pre>
 
</pre>
 
+
*Run the demo:
===Python===
+
sudo ./epd
<div class="cautionSec">PS: The system of the Bullseye branch only supports Python3. </div>
+
===Run Python Library===
*Enter the folder of python code.
+
*Install Python Library:
 
<pre>
 
<pre>
cd python/examples
+
sudo apt-get update
ls -al
+
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
 
</pre>
 
</pre>
:[[File:E-paper_rpi_change_python012.png|500px]]
+
*Install the function library (Python2)
*Run the responding example.
 
{{#switch:{{FULLPAGENAME}}
 
|4.01inch e-Paper HAT (F)=
 
 
<pre>
 
<pre>
sudo python epd_4in01f_test.py
+
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
 
</pre>
 
</pre>
or
+
*Download the program: (already downloaded can be skipped):
 
<pre>
 
<pre>
sudo python3 epd_4in01f_test.py
+
sudo apt-get install p7zip-full
 +
wget  https://files.waveshare.com/upload/3/39/E-Paper_code.7z
 +
7z x E-Paper_code.7z -O./e-Paper
 +
cd e-Paper/RaspberryPi_JetsonNano/
 
</pre>
 
</pre>
|5.65inch e-Paper Module (F)=
+
*Downloading the program via GitHub (alternate method, you can skip it if you've already downloaded it).<br/>
 +
Access to GitHub is not very smooth at the moment, so we recommend downloading from our website using the method above.
 
<pre>
 
<pre>
sudo python epd_5in65f_test.py
+
git clone https://github.com/waveshare/e-Paper.git
</pre>
+
cd e-Paper/RaspberryPi_JetsonNano/
or
 
<pre>
 
sudo python3 epd_5in65f_test.py
 
</pre>
 
|#Default=
 
<pre>
 
sudo python epd_xxx_test.py
 
sudo python3 epd_xxx_test.py
 
</pre>
 
}}
 
Supporting types:<br/>
 
;1.02inch(128×80):
 
epd_1in02_test.py:Example for 1.02inch e-Paper/1.02inch e-Paper Module
 
 
 
;1.54inch(1.54inch e-paper c:152×152,others:200×200):
 
epd_1in54_test.py: Example for 1.54inch e-paper V1(Balck/<font color="#DCDCDC">White</font>): This version is stopped production which can be bought before 2019-11-22;<br />
 
epd_1in54_V2_test.py: Example for 1.54inch e-paper V2(Balck/<font color="#DCDCDC">White</font>): This is the current version which can be bought now (2020-07-29). The e-Paper has V2 sticker on the backside. <br />
 
epd_1in54b_test.py: Example for 1.54inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). It is currently out of production.<br />
 
epd_1in54b_V2_test.py: Example for 1.54inch e-paper B V2 (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than April 2020 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
epd_1in54c_test.py: Example for 1.54inch e-paper C(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>).<br />
 
 
 
;1.64inch(168 × 168):
 
epd_1in64g_test.py: Example for 1.64inch e-paper G (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>)<br/>
 
 
 
;2.7inch(264×176):
 
epd_2in7_test.py: Example for 2.7inch e-paper(Black/<font color="#DCDCDC">White</font>);<br />
 
epd_2in7b_test.py: Example for 2.7inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>);<br />
 
epd_2in7b_V2_test.py: Example for 2.7inch e-paper B V2 (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than February 2021 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
 
 
;2.9inch(296×128):
 
epd_2in9_test.py: Example for 2.9inch e-paper(Black/<font color="#DCDCDC">White</font>); It is currently out of production.<br />
 
epd_2in9_V2_test.py: Example for 2.9inch e-paper V2(Black/<font color="#DCDCDC">White</font>); The purchase date is later than December 2020 is the V2 version, the current shipping version, with the V2 logo on the back.<br />
 
epd_2in9bc_test.py: Example for 2.9inch e-paper B(Balck/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>) and 2.9inch e-paper C(Black/White/Yellow);<br />
 
epd_2in9b_V3_test.py: Example for 2.9inch e-paper B V3(Balck/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>; The purchase date later than July 2020 is the V3 version, the current shipping version has the V3 logo on the back;<br />
 
epd_2in9d_test.py: Example for 2.9inch e-paper D(Black/<font color="#DCDCDC">White</font>);
 
 
 
;2.13inch(2.13inch e-Paper:250×122,others:212×104):
 
epd_2in13_test.py: Example for 2.13inch e-paper V1(Black/<font color="#DCDCDC">White</font>), this version is stopped production and it can be bought before 019-05-15;<br />
 
epd_2in13_V2_test.py: Example for 2.13inch e-paper V2(Black/<font color="#DCDCDC">White</font>) This is the current version with sticker V2 on the backside (2020-07-29);<br />
 
epd_2in13_V3_test.py: Example for 2.13inch e-paper V3(Black/<font color="#DCDCDC">White</font>), The purchase date later than February 2022 is the V3 version, the current shipping version, with the V3 logo on the back.<br/>
 
epd_2in13bc_test.py: Example for 2.13inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)and 2.13inch e-paper C(Black/White/Yellow);<br />
 
epd_2in13b_V3_test.py: Example for 2.13inch e-paper B V3(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)<br />
 
epd_2in13d_test.py: Example for 2.13inch e-paper D(Black/<font color="#DCDCDC">White</font>);<br />
 
 
 
;2.66inch (152 x 296):
 
epd_2in66_test.py: Example for 2.66inch e-Paper (Black/<font color="#DCDCDC">White</font>); <br />
 
epd_2in66b_test.py: Example for 2.66inch e-Paoer (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>);<br />
 
 
 
;3inch (400 × 168):
 
EPD_3in0g_test.py: Example for 3inch e-Paper G(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>); <br />
 
 
 
;3.52inch (360 × 240):
 
EPD_3in52_test.py: Example for 3.52inch e-Paper (Black/<font color="#DCDCDC">White</font>); <br />
 
 
 
;3.7inch (280 x 480):
 
epd_3in7_test.py: Example for 3.7inch e-Paper (Black/<font color="#DCDCDC">White</font>); <br />
 
 
 
;4.01inch (640x400):
 
epd_4in01f_test.py: Example for 4.01inch e-Paper (Seven-color);<br />
 
 
 
;4.2inch(400×300):
 
epd_4in2_test.py: Example for 4.2inch e-paper(Black/<font color="#DCDCDC">White</font>);<br />
 
epd_4in2bc_test.py: Example for 4.2inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>);<br />
 
epd_4in2b_V2_test.py: Example for 4.2inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than November 2020, it is the V2 version, and the current shipping version has the V2 logo on the back;<br />
 
 
 
;5.65inch (600x558):
 
epd_5in65f_test.py: Example for 5.65inch e-Paper F (Seven-color);
 
 
 
;5.83inch(600×448):
 
epd_5in83_test.py: Example for 5.83inch e-paper(Black/<font color="#DCDCDC">White</font>). It is currently out of production.<br />
 
epd_5in83_V2_test.py: Example for 5.83inch e-paper V2(Black/<font color="#DCDCDC">White</font>); The purchase date is later than December 2020 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
epd_5in83bc_test.py: Example for 5.83inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)and 5.83inch e-paper C(Black/<font color="#DCDCDC">White</font>/<font color="#FFD700">Yellow</font>);<br />
 
epd_5in83b_V2_test.py: Example for 5.83inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date is later than August 2020 is the V2 version, the current shipping version has the V2 logo on the back;<br />
 
 
 
;7.3inch (400 × 168):
 
epd_7in3g_test.py: Example for 7inch3 e-paper G (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>/<font color="#FFD700">Yellow</font>).
 
 
 
;7.5inch(V1:640×384, V2:800×480):
 
epd_7in5_test.py: Example for 7.5inch e-paper(Black/<font color="#DCDCDC">White</font>), this version is stopped production and it can be bought before 2019-12-07;<br />
 
epd_7in5_V2_test.py: Example for 7.5inch e-paper V2(Black/<font color="#DCDCDC">White</font>), This is the current version with V2 sticker on the backside (2020-07-29)<br />
 
epd_7in5bc_test.py: Example for 7.5inch e-paper B(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>)and 7.5inch e-paper C(Black/<font color="#DCDCDC">White</font>/Yellow), 7.5inch e-paper B V1 version is stopped production and it can be bought before 2019-12-07;<br />
 
epd_7in5b_V2_test.py: Example for 7.5inch e-paper B V2(Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>). The purchase date later than 2019-12-07 is the V2 version, with the V2 logo on the back; the purchase date later than March 2021 is the V3 version, the current 7.5inch e-paper B shipping version, with the V3 logo on the back, the same use this program.<br />
 
 
 
;7.5inch (HD 880 x 528):
 
epd_7in5_HD_test.py: Example for 7.5inch e-Paper HD (Black/<font color="#DCDCDC">White</font>); <br />
 
epd_7in5b_HD_test.py: Example for 7.5inch e-Paper B HD (Black/<font color="#DCDCDC">White</font>/<font color="#FF0000">Red</font>); <br />
 
 
 
<font backgound=white; color=#DD1223>Note: The above time is for reference only, please refer to the screen logo for the specific version.</font><br/>
 
Just run the program corresponding to the screen, the program supports python2/3, take 1.54 V2 as an example.<br/>
 
<pre>
 
# python2
 
sudo python2.7 epd_1in54_V2_test.py
 
# python3
 
sudo python3 epd_1in54_V2_test.py
 
</pre>
 
 
 
==Codes Description(API)==
 
The libraries for Raspberry Pi and Jetson Nano are same. Examples contain three parts, hardware interface, EPD driver and the GUI functions.
 
===C===
 
====<big>Hardware interface</big>====
 
[[File:E-paper Driver HAT RPI Makefile.png|400px|thumb|right]]
 
We have carried out the underlying package. As the hardware platform is different, the internal is various. If you need to know the internal, you can go to the corresponding directory.<br/>
 
You can see many definitions in DEV_Config.c(.h), in the directory: RaspberryPi_JetsonNano\c\lib\Config.<br/>
 
C language uses two ways to drive: BCM2835 library, and WiringPi library. The BCM2835 library is used by default. If you need to use the WiringPi library to drive, you can open RaspberryPi_JetsonNano\c\Makefile and modify lines 13-14.<br/>
 
*Data type
 
<pre>
 
#define UBYTE  uint8_t
 
#define UWORD  uint16_t
 
#define UDOUBLE uint32_t
 
</pre>
 
*Init and Exit
 
<pre>
 
void DEV_Module_Init(void);
 
void DEV_Module_Exit(void);
 
</pre>
 
Note: The Init() and Exit() functions are used to configure GPIOs. EPD enters sleep mode after Exit() function is used, and the consumption of e-Paper should be 0 in sleep mode if the PCB is Rev2.1 version.
 
*GPIO Read/Write
 
<pre>
 
void DEV_Digital_Write(UWORD Pin, UBYTE Value);
 
UBYTE DEV_Digital_Read(UWORD Pin);
 
</pre>
 
*SPI transmits data.
 
<pre>
 
void DEV_SPI_WriteByte(UBYTE Value);
 
</pre>
 
 
 
====<big>EPD Driver</big>====
 
: The driver file is saved under RaspberryPi&JetsonNano\c\lib\e-Paper.
 
:[[File:E-paper_Driver_HAT_RPI_epd.png]]
 
Open .h to see the following functions<br/>
 
*EPD initialization: please use it when the EPD starts to work or exits the sleep mode.
 
<pre>
 
//1.54inch e-Paper, 1.54inch e-Paper V2, 2.13inch e-Paper, 2.13inch e-Paper V2, 2.13inch e-Paper (D), 2.9inch e-Paper, 2.9inch e-Paper (D )
 
void EPD_xxx_Init(UBYTE Mode); // Mode = 0 full refresh initialization, Mode = 1 partial refresh initialization
 
//other models
 
void EPD_xxx_Init(void);
 
</pre>
 
Where xxx represents the model. If it is 2.13D, the full screen initialization is EPD_2IN13D_Init(0), the partial refresh initialization EPD_2IN13D_Init(1); if it is 1.54 V2, then EPD_1IN54_V2_Init(); if it is 7.5B, it is EPD_7IN5BC_Init(). Although the display colors are different, the driver code of 7.5B and 7.5C is the same.<br/>
 
*Clear the screen, and refresh the ink screen to white.
 
void EPD_xxx_Clear(void);
 
Where xxx represents the ink screen model. If it is 2.13D, then it is EPD_2IN9D_Clear(); if it is 7.5B, it is EPD_7IN5_Clear(). Although the display colors are different, the driver code of 7.5B and 7.5C is the same.<br/>
 
*Transfer a frame of picture data and open the display.
 
<pre>
 
//Black and white two-color ink screen
 
void EPD_xxx_Display(UBYTE *Image);
 
//Black and white red or black and white yellow ink screen
 
void EPD_xxx_Display(const UBYTE *blackimage, const UBYTE *ryimage);
 
</pre>
 
Note that the following are special cases:<br/>
 
<pre>
 
//For 2.13inch e-paper (D), 2.9inch e-paper (D) two flexible screens, partial refresh
 
void EPD_2IN13D_DisplayPart(UBYTE *Image);
 
void EPD_2IN9D_DisplayPart(UBYTE *Image);
 
</pre>
 
//For 1.54inch e-paper V2 and 2.13inch e-paper V2, due to the upgrade of the control chip, for a partial refresh, it is necessary to call EPD_xxx_DisplayPartBaseImage to display the static background image, that is, to perform partial refresh based on this image, and then call the dynamic EPD_xxx_DisplayPart ()
 
<pre>
 
void EPD_1IN54_V2_DisplayPartBaseImage(UBYTE *Image);
 
void EPD_1IN54_V2_DisplayPart(UBYTE *Image);
 
void EPD_2IN13_V2_DisplayPart(UBYTE *Image);
 
void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image);
 
</pre>
 
*Enter sleep mode
 
<pre>
 
void EPD_xxx_Sleep(void);
 
</pre>
 
<font backgound=white; color=#DD1223>Note that after entering sleep mode, there are only two ways to work again: the first is a hardware reset, and the second is to call the initialization function again.</font><br/>
 
Where xxx represents the ink screen model. If it is 2.13D, then it is EPD_2IN13D_Sleep(); if it is 7.5B, it is EPD_7IN5BC_Sleep(). Although the display colors are different, the driver code of 7.5B and 7.5C is the same.<br/>
 
 
 
====<big>GUI functions</big>====
 
GUI files can be found in RaspberryPi & JetsonNano\c\lib\GUI\GUI_Paint.c(.h) directory.
 
:[[File:E-paper_Driver_HAT_GUI.png]]
 
The fonts can be found in the RaspberryPi & JetsonNano\c\lib\Fonts directory.
 
:[[File:E-paper_Driver_HAT_Fonts.png]]
 
 
 
; Create an image buffer
 
<pre>
 
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
 
</pre>
 
*Image: the Image buffer
 
*Width: width of the image
 
*Height: Height of the image
 
*Rotate: Rotate angle
 
*Color: Color of the image
 
 
 
; Select image buffer
 
<pre>
 
void Paint_SelectImage(UBYTE *image)
 
</pre>
 
* The image buffer is a pointer of the image buffer's first address.
 
 
 
; Rotate image
 
:This function should be used after Paint_SelectImage().
 
<pre>
 
void Paint_SetRotate(UWORD Rotate)
 
</pre>
 
*Rotate: The angle rotated. It should be ROTATE_0, ROTATE_90, ROTATE_180, ROTATE_270.
 
*Note: For different orientations, the position of the first pixel is different, here we take 1.54inch as an example.
 
[[File:SPI-epaper-C-0.png|150px]][[File:SPI-epaper-C-90.png|150px]][[File:SPI-epaper-C-180.png|150px]][[File:SPI-epaper-C-270.png|150px]]
 
; Mirroring
 
<pre>
 
void Paint_SetMirroring(UBYTE mirror)
 
</pre>
 
*mirror: The type of mirroring. (MIRROR_NONE, MIRROR_HORIZONTAL、MIRROR_VERTICAL、MIRROR_ORIGIN)
 
 
 
; Set Pixel
 
: This function is used to set the position and types of the pixel
 
<pre>
 
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
 
</pre>
 
*Xpoint: The x-axis coordination of pixel
 
*Ypoint: The y-axis coordination of pixel
 
*Color: The color of the pixel
 
 
 
; Clear
 
: This function is used to clear the e-Paper
 
<pre>
 
void Paint_Clear(UWORD Color)
 
</pre>
 
*Color: The color of the display
 
 
 
; Clear window
 
: This function is used to clear a partial area
 
<pre>
 
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
 
</pre>
 
*Xstart: The x-axis coordination of the start point
 
*Ystart: The y-axis coordination of the start point
 
*Xend: The x-axis coordination of the end point
 
*Yend: The y-axis coordination of the end point
 
*Color: The color of the windows
 
 
 
; Draw point
 
This function is used to draw points.
 
<pre>
 
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
 
</pre>
 
*Xpoint: The x-axis coordination of point
 
*Ypoint: The y-axis coordination of point
 
*Dot_Pixel: The size of the point
 
<pre>
 
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;
 
</pre>
 
*Dot_Style: The style of the point
 
<pre>
 
typedef enum {
 
  DOT_FILL_AROUND  = 1,
 
  DOT_FILL_RIGHTUP,
 
} DOT_STYLE;
 
</pre>
 
 
 
; Draw Line
 
<pre>
 
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
 
</pre>
 
This function is used to draw a line
 
*Xstart: The start x-axis coordination of the line
 
*Ystart: The start y-axis coordination of the line
 
*Xend: The end x-axis coordination of the line
 
*Yend: The end y-axis coordination of the line
 
*Line_width: The width of the line
 
<pre>
 
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;
 
</pre>
 
*Line_style: The style of the line
 
<pre>
 
typedef enum {
 
LINE_STYLE_SOLID = 0,
 
LINE_STYLE_DOTTED,
 
} LINE_STYLE;
 
</pre>
 
 
 
; Draw rectangle
 
Draw a rectangle from (Xstart, Ystart) to (Xend, Yend).
 
<pre>
 
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
 
</pre>
 
*Xstart: Start coordinate of X-axes of the rectangle
 
*Ystart: Start coordinate of Y-axes of the rectangle
 
*Xend: End coordinate of X-end of the rectangle
 
*Yend: End coordinate of Y-end of the rectangle
 
*Color: the color of the rectangle
 
*Line_width: The width of edges, 8 sides are available;
 
<pre>
 
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;
 
 
 
 
</pre>
 
*Draw_Fill: set the rectangle as full or empty.
 
<pre>
 
typedef enum {
 
DRAW_FILL_EMPTY = 0,
 
DRAW_FILL_FULL,
 
} DRAW_FILL;
 
</pre>
 
; Draw a circle: In the image cache, with (X_Center Y_Center) as the center, draw a circle with a Radius, you can choose the color, the width of the line, and whether to fill the inside of the circle.<br/>
 
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 coordinate of the center of the circle
 
  Y_Center: Y coordinate of the center of the circle
 
  Radius: the radius of the circle
 
  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;
 
 
 
; Draw character (ASCII)
 
Set(Xstart Ystart) as the left-top point, and draw an ASCII character.
 
<pre>
 
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
 
</pre>
 
Parameter:
 
*Xstart: X coordinate of the left-top pixel of character;
 
*Ystart: Y coordinate of the left-top pixel of character;
 
*Ascii_Char:Ascii character;
 
*Font: 5 fonts are available;
 
*:font12:7*12
 
*:font16:11*16
 
*:font20:14*20
 
*:font24:17*24
 
*Color_Foreground: the color of character;
 
*Color_Background: the color of background;
 
 
 
; Draw String
 
Set point (Xstart Ystart) as the left-top pixel, and draw a string.
 
<pre>
 
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
 
</pre>
 
Parameters:
 
*Xstart: X coordinate of left-top pixel of characters;
 
*Ystart: Y coordinate of left-top pixel of characters;
 
*pString:Pointer of string
 
*Font: 5 fonts are available:
 
*:font8:5*8
 
*:font12:7*12
 
*:font16:11*16
 
*:font20:14*20
 
*:font24:17*24
 
*Color_Foreground: color of string
 
*Color_Background: color of the background
 
 
 
; Draw Chinese characters
 
this function is used to draw Chinese fonts based ON GB2312 fonts.
 
<pre>
 
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
 
 
</pre>
 
</pre>
Parameters:
+
*Run the program:
*Xstart: Coordinate of left-top pixel of characters;
 
*Ystart: Coordinate of left-top pixel of characters;
 
*pString:Pointer of string;
 
*Font: GB2312 fonts:
 
*:font12CN:11*21(ascii),16*21 (Chinese)
 
*:font24CN:24*41(ascii),32*41 (Chinese)
 
*Color_Foreground: color of string
 
*Color_Background: color of the background
 
 
 
; Draw number
 
Draw a string of numbers, (Xstart, Ystart) is the left-top pixel.
 
 
<pre>
 
<pre>
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Number, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
+
# Make sure in the e-Paper/RaspberryPi_JetsonNano/
 +
cd python/examples/
 +
python3 epd_1in02_test.py
 
</pre>
 
</pre>
Parameter:
 
*Xstart: X coordinate of left-top pixel;
 
*Ystart: Y coordicate of left-to pixel;
 
*Nummber: the numbers displayed. the numbers are saved in int format, the maximum is 2147483647;
 
*Font: 5 fonts are available:
 
*:font8:5*8
 
*:font12:7*12
 
*:font16:11*16
 
*:font20:14*20
 
*:font24:17*24
 
*Color_Foreground: the color of the font;
 
*Color_Background: the color of the background;
 
 
; Draw image
 
Send image data of BMP file to buffer
 
<pre>
 
void Paint_DrawBitMap(const unsigned char* image_buffer)
 
</pre>
 
Parameters:
 
*image_buffer: address of image data in the buffer.
 
 
; Read the local BMP picture and write it to buffer.
 
Linux platforms like Jetson Nano and Raspberry Pi support directly operating BMP pictures.
 
Raspberry Pi & Jetson Nano:RaspberryPi&JetsonNano\c\lib\GUI\GUI_BMPfile.c(.h).
 
<pre>
 
UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart)
 
</pre>
 
Parameters:
 
*path: The path of BMP pictures
 
*Xstart: X coordination of left-top of picture, default 0;
 
*Ystart: Y coordination of left-top of picture, default 0;
 
 
====<big>Testing Code</big>====
 
[[File:Test code.png|400px|thumb|right]]
 
The first three chapters introduce the classic Linux three-layer code structure, here is a little explanation of the user test code.<br/>
 
For Raspberry Pi and Jetson Nano, in the directory: RaspberryPi_JetsonNano\c\examples, for all test codes, multiple shields can be made in main.c in this directory;<br/>
 
If you need to run the 7.5inch e-paper test program, you need to remove the 42-line shield.<br/>
 
//EPD_5in65f_test();
 
to
 
EPD_5in65f_test();
 
 
Then compile it again and run.
 
<pre>
 
make clean
 
make
 
sudo ./epd
 
</pre>
 
 
===Python===
 
[[File:Epd.png|400px|thumb|right]]
 
For Jetson Nano\Raspberry Pi, based on python2.7 and python3.<br/>
 
For python, its calls are not as complicated as C.<br/>
 
Raspberry Pi and Jetson Nano: RaspberryPi_JetsonNano\python\lib\<br/>
 
===='''<big>Bottom Interface</big>'''====
 
The epdconfig.py file package the underlying interface.<br/>
 
*Initialize module and exit handle:
 
<pre>
 
def module_init()
 
def module_exit()
 
</pre>
 
Note:<br />
 
1. The functions are used to set GPIP before and after driving e-Paper.<br />
 
2. If the board you have is printed with Rev2.1, the module enters low-ultra mode after Module_Exit(). (as we test, the current is about 0 in this mode);<br />
 
 
*GPIO Read/Write:
 
<pre>
 
def  digital_write(pin, value)
 
def  digital_read(pin)
 
</pre>
 
 
*SPI Write data:
 
<pre>
 
def spi_writebyte(data)
 
</pre>
 
 
===='''<big>Driver Interface</big>'''====
 
epdxxx.py (xxx means size, if it is 2.13inch e-paper, it is epd2in13.py, and so on)
 
*Initialize e-paper: this function should be used at the beginning. It can also be used to wake up e-Paper from Sleep mode.
 
<pre>
 
#For 2.13inch e-Paper、2.9inch e-Paper
 
def init(self, update) #  Choose lut_full_update or lut_partial_update
 
# Other types
 
def init(self)
 
</pre>
 
 
*Clear e-paper: This function is used to clear e-Paper to white;
 
<pre>
 
def Clear(self)
 
def Clear(self, color) # Some types of e-Paper should use this function to clear screen
 
</pre>
 
 
*Convert image to arrays
 
<pre>
 
def getbuffer(self, image)
 
</pre>
 
 
*Transmit one frame of image data and display
 
<pre>
 
#For two-color e-paper
 
def display(self, image)
 
 
#Because that controllers of 2.13inch e-paper are updated, when partial refresh, they should first use displayPartBaseImage() to display static background, then use displayPart() to dynamaticlly display.
 
def displayPartBaseImage(self, image)
 
def displayPart(self, image)
 
</pre>
 
 
*Enter sleep mode
 
<pre>
 
def sleep(self)
 
</pre>
 
 
===='''<big>Testing Function</big>'''====
 
epd_xxx_test.py (xxx means dimension)python examples are saved in the directory:<br />
 
Raspberry Pi and Jetson Nano:RaspberryPi&JetsonNano\python\examples\ <br />
 
[[File:testing function.png]]<br/>
 
 
If the python installed in your OS is python2, you should run examples like the below:<br />
 
sudo python epd_2in13_V2_test.py
 
If it is python3, the commands should be:
 
sudo python3 epd_2in13-V2_test.py
 
 
===='''<big>Orientation</big>'''====
 
To rotate the display, you can use transpose function like blackimage = blackimage.transpose(Image.ROTATE_270):
 
<pre>
 
blackimage = blackimage.transpose(Image.ROTATE_270)
 
redimage = redimage.transpose(Image.ROTATE_270)
 
#Support ROTATE_90, ROTATE_180, ROTATE_270
 
</pre>
 
The rotation effect, taking 1.54B as an example, is 0°, 90°, 180°, 270° in sequence<br/>
 
[[File:orientation.png]]<br/>
 
 
===='''<big>GUI</big>'''====
 
Python has a powerful [http://effbot.org/imagingbook PIL library], which can be used directly to drawing figures. Here we use it for drawing. <br />
 
 
*Install the library firstly.
 
sudo apt-get install python3-pil
 
Import the library.
 
from PIL import Image,ImageDraw,ImageFont
 
Image: library; ImageDraw: drawing function; ImageFont: fonts
 
 
*Set image buffer for drawing.
 
image = Image.new('1', (epd.width, epd.height), 255)  # 255: clear the frame
 
The first parameter is the depth of color, 1 means 2 grayscale. The second parameter is a tuple of image size. The third parameter is the color of the image, 0 is black and 255 is white.
 
 
*Create an image object.
 
draw = ImageDraw.Draw(image)
 
 
*Draw rectangle
 
draw.rectangle((0, 10, 200, 34), fill = 0)
 
The first parameter is a tuple of coordination. 0, 10 is the top-left point of the rectangle, and 200, 34) is the right-bottom point. fille = 0 set the fill color to black.
 
 
*Draw line
 
draw.line((16, 60, 56, 60), fill = 0)
 
The first parameter is a type of coordination, 16, 60 is the beginning point, and 200, 34 is the endpoint. fill=0 set the line to black.
 
 
*Draw circle
 
<pre>
 
draw.arc((90, 60, 150, 120), 0, 360, fill = 0)
 
</pre>
 
This function is used to draw a encircle of a square. The first parameter is a tuple of coordination of the square.  the degree of the circle is 0 to 360 °, fille=0 set the circle to black.<br />
 
If the figure is not square according to the coordination, you will get an ellipse.<br />
 
 
Besides the arc function, you can also use the chord function for drawing a solid circle.<br />
 
<pre>
 
draw.chord((90, 130, 150, 190), 0, 360, fill = 0)
 
</pre>
 
The first parameter is the coordination of the enclosing rectangle. The second and third parameters are the beginning and end degrees of the circle. The fourth parameter is the fill color of the circle.<br />
 
 
*Character
 
You can directly import the ImageFont model for drawing characters:<br />
 
<pre>
 
font = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)
 
</pre>
 
You can use the fonts of Windows or other fonts which is in ttc format.<br />
 
 
To draw English character, you can directly use the fonts; for Chinese characters, you need to add a symbol u:<br />
 
<pre>
 
draw.text((8, 12), 'hello world', font = font, fill = 255)
 
draw.text((8, 36), u'微雪电子', font = font, fill = 0)
 
</pre>
 
The first parameter is a tuple of coordination of character, the second parameter is the font and las one is set the color.<br />
 
 
*Read local picture
 
<pre>
 
image = Image.open(os.path.join(picdir, 'lin54.bmp'))
 
</pre>
 
The parameter is the path of picture.
 
 
*Other functions.
 
For more information about the PIL library, you can search online.
 

Latest revision as of 06:40, 2 September 2023

Working With Raspberry Pi

Provide BCM2835, WiringPi, file IO, RPI (Python) library demos.

Hardware connection

When connecting the Raspberry Pi, if the driver board has a 40pin header, you can directly plug it into the 40PIN header of the Raspberry Pi, and pay attention to the pins. If you choose to connect with an 8PIN cable, please refer to the pin correspondence table below
For the 1.02inch e-paper Module, the pin header is used, and the wiring needs to be connected according to the following table

Correspondence between connecting pins of Raspberry Pi
e-Paper Raspberry Pi
BCM2835 encoding Board physical pin number
VCC 3.3V 3.3V
GND GND GND
DIN MOSI 19
CLK SCLK 23
CS CE0 24
DC 25 22
RST 17 11
BUSY 24 18

Take the 7.5inch HD e-Paper (B) connected to the e-paper Driver HAT as an example, just plug it directly into the Raspberry Pi:
7.5inch e-Paper(B)800-480 1.jpg

Enable SPI Interface

  • Open the Raspberry Pi terminal and enter the following command in the config interface:
sudo raspi-config
Choose Interfacing Options -> SPI -> Yes Enable SPI interface

RPI open spi.png
Then reboot your Raspberry Pi:

sudo reboot
  • Check /boot/config.txt, and you can see 'dtparam=spi=on' was written in.

Raspberry Pi Guides for 4.37 e-Paper.jpg

  • To make sure SPI is not occupied, it is recommended to close other drivers' coverage. You can use ls /dev/spi* to check whether SPI is occupied. If the terminal outputs /dev/spidev0.1 and /dev/spidev0.1, SPI is not occupied.

Raspberry Pi Guides for 4.37 e-Paper02.jpg

Install Library

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.airspayce.com/mikem/bcm2835/
  • Install WiringPi
#Open the Raspberry Pi terminal and run the following command:
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (Earlier than the previous can not be implemented), an upgrade may be required to:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
#Running gpio -v will bring up version 2.52, if it doesn't, it means there was an installation error.

#The Bullseye branch system uses 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 there is an installation error
  • Download program (already downloaded can be skipped):
sudo apt-get install p7zip-full
wget  https://files.waveshare.com/upload/3/39/E-Paper_code.7z
7z x E-Paper_code.7z -O./e-Paper
cd e-Paper/RaspberryPi_JetsonNano/
  • Downloading the program via GitHub (alternate method, you can skip it if you've already downloaded it).

Access to GitHub is not very smooth at the moment, so we recommend downloading from our website using the method above.

git clone https://github.com/waveshare/e-Paper.git
cd e-Paper/RaspberryPi_JetsonNano/

Compile the program (Note: -j4 is compiled using 4 threads, the number can be modified; EPD=epd1in02d is to specify a macro definition, epd1in02d corresponds to the test program in the main function).

# At this point in the e-Paper/RaspberryPi_JetsonNano 
cd c
sudo make clean
sudo make -j4 EPD=epd1in02d
  • Run the demo:
sudo ./epd

Run Python Library

  • Install Python Library:
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
  • Install the function library (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
  • Download the program: (already downloaded can be skipped):
sudo apt-get install p7zip-full
wget  https://files.waveshare.com/upload/3/39/E-Paper_code.7z
7z x E-Paper_code.7z -O./e-Paper
cd e-Paper/RaspberryPi_JetsonNano/
  • Downloading the program via GitHub (alternate method, you can skip it if you've already downloaded it).

Access to GitHub is not very smooth at the moment, so we recommend downloading from our website using the method above.

git clone https://github.com/waveshare/e-Paper.git
cd e-Paper/RaspberryPi_JetsonNano/
  • Run the program:
# Make sure in the e-Paper/RaspberryPi_JetsonNano/ 
cd python/examples/
python3 epd_1in02_test.py