Difference between revisions of "Template:Hardware/Software setting for SPI e-paper"
Line 387: | Line 387: | ||
==Running examples== | ==Running examples== | ||
− | + | ==Examples== | |
− | + | ===C=== | |
+ | [[File:RPI Guide for e-Paper.png|thumb|right]] | ||
+ | Open main.c to select the screen of the corresponding size | ||
<pre> | <pre> | ||
cd c | cd c | ||
+ | sudo nano examples/main.c | ||
+ | </pre> | ||
+ | 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/White): This version is stopped production which can be bought before 2019-11-22;<br /> | ||
+ | EPD_1in54_V2_test(): Example for 1.54inch e-paper V2(Balck/White): This is the current version that can be bought now (2020-07-29). The e-Paper has V2 sticker on the backside. <br /> | ||
+ | EPD_1in54b_test(): Example for 1.54inch e-paper B(Black/White/Red);<br /> | ||
+ | EPD_1in54b_V2_test(): Example for 1.54inch e-Paper B V2 (Black/White/Red);<br /> | ||
+ | EPD_1in54c_test(): Example for 1.54inch e-paper C(Black/White/Red); <br /> | ||
+ | |||
+ | ;2.7inch(264×176): | ||
+ | EPD_2in7_test(): Example for 2.7inch e-paper(Black/White);<br /> | ||
+ | EPD_2in7b_test(): Example for 2.7inch e-paper B(Black.White/Red);<br /> | ||
+ | EPD_2in7b_V2_test(): Example for 2.7inch e-paper B V2(Black.White/Red);<br /> | ||
+ | |||
+ | ;2.9inch(296×128): | ||
+ | EPD_2in9_test(): Example for 2.9inch e-paper(Black/White);<br /> | ||
+ | EPD_2in9_V2_test(): Example for 2.9inch e-paper V2(Black/White);<br /> | ||
+ | EPD_2in9bc_test(): Example for 2.9inch e-paper B(Balck/White/Red) and 2.9inch e-paper C(Black/White/Yellow);<br /> | ||
+ | EPD_2in9b_V3_test(): Example for 2.9inch e-paper B V3 (Balck/White/Red);<br /> | ||
+ | EPD_2in9d_test(): Example for 2.9inch e-paper D(Black/White); | ||
+ | |||
+ | ;2.13inch(2.13inch e-Paper:250×122,others:212×104): | ||
+ | EPD_2in13_test(): Example for 2.13inch e-paper V1(Black/White), this version is stopped production and it can be bought before 019-05-15;<br /> | ||
+ | EPD_2in13_V2_test(): Example for 2.13inch e-paper V2(Black/White) This is the current version with sticker V2 on the backside (2020-07-29);<br /> | ||
+ | EPD_2in13_V3_test(): Example for 2.13inch e-paper V3(Black/White) 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/White/Red)and 2.13inch e-paper C(Blackj/White/Yellow);<br /> | ||
+ | EPD_2in13b_V3_test():Example for 2.13inch e-paper B V3(Black/White/Red)<br /> | ||
+ | EPD_2in13d_test(): Example for 2.13inch e-paper D(Black/White);<br /> | ||
+ | |||
+ | ;2.66inch (152 x 296): | ||
+ | EPD_2in66_test(): Example for 2.66inch e-Paper (Black/White);<br /> | ||
+ | EPD_2in66b_test(): Example for 2.66inch e-Paper B (Black/White/Red); <br /> | ||
+ | |||
+ | ;3.7inch (280 x 480): | ||
+ | EPD_3in7_test(): Example for 3.7inch e-Paper(Black/White); <br /> | ||
+ | |||
+ | ;4.01inch (640x400): | ||
+ | EPD_4in01_test(): Example for the 4.01inch e-Paper HAT (F);<br /> | ||
+ | |||
+ | ;4.2inch(400×300): | ||
+ | EPD_4in2_test(): Example for 4.2inch e-paper(Black/White);<br /> | ||
+ | EPD_4in2bc_test(): Example for 4.2inch e-paper B(Black/White/Red);<br /> | ||
+ | EPD_4in2b_V2_test(): Example for 4.2inch e-paper B V2(Black/White/Red);<br /> | ||
+ | |||
+ | ;5.65inch (600x448): | ||
+ | EPD_5in65f_test(): Example for for 5.65inch e-Paper F (Seven-color); | ||
+ | |||
+ | ;5.83inch(600×448): | ||
+ | EPD_5in83_test(): Example for 5.83inch e-paper(Black/White);<br /> | ||
+ | EPD_5in83_V2_test(): Example for 5.83inch e-paper V2(Black/White);<br /> | ||
+ | EPD_5in83bc_test(): Example for 5.83inch e-paper B(Black/White/Red)and 5.83inch e-paper C(Black/White/Yellow);<br /> | ||
+ | EPD_5in83b_V2_test(): Example for 5.83inch e-paper B V2(Black/White/Red)<br /> | ||
+ | |||
+ | ;7.5inch(V1:640×384, V2:800×480): | ||
+ | EPD_7in5_test(): Example for 7.5inch e-paper(Black/White), this version is stopped production and it can be bought before 2019-12-07;<br /> | ||
+ | EPD_7in5bc_test(): Example for 7.5inch e-paper B(Black/White/Red)and 7.5inch e-paper C(Black/White/Yellow),7.5inch e-paper B V1 version is stop production and it can be bought before 2019-12-07;<br /> | ||
+ | EPD_7in5_V2_test(): Example for 7.5inch e-paper V2(Black/White), This is the current version with V2 sticker on the backside (2020-07-29)<br /> | ||
+ | EPD_7in5bc_V2_test():Example for 7.5inch e-paper B V2(Black/White/Red); This is the current version with V2 sticker on the backside. (2020-07-29);<br /> | ||
+ | |||
+ | ;7.5inch (HD: 880 x 528) | ||
+ | EPD_7in5_HD_test(): Example for 7.5inch e-Paper HD (Black/White); <br /> | ||
+ | EPD_7in5b_HD_test(): Example for 7.5inch e-Paper B HD (Black/White/Red); <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 clean | ||
make | make | ||
Line 396: | Line 470: | ||
</pre> | </pre> | ||
− | + | ===Python=== | |
− | + | <div class="cautionSec">PS: The system of the Bullseye branch only supports Python3. </div> | |
+ | *Enter the folder of python code | ||
<pre> | <pre> | ||
cd python/examples | cd python/examples | ||
+ | ls -al | ||
+ | </pre> | ||
+ | :[[File:E-paper_rpi_change_python12.png|500px]] | ||
+ | *Run the responding example | ||
+ | {{#switch:{{FULLPAGENAME}} | ||
+ | |4.01inch e-Paper HAT (F)= | ||
+ | <pre> | ||
+ | sudo python epd_4in01f_test.py | ||
+ | </pre> | ||
+ | or | ||
+ | <pre> | ||
+ | sudo python3 epd_4in01f_test.py | ||
+ | </pre> | ||
+ | |5.65inch e-Paper Module (F)= | ||
+ | <pre> | ||
+ | sudo python epd_5in65f_test.py | ||
+ | </pre> | ||
+ | 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/White): 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/White): 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/White/Red);<br /> | ||
+ | epd_1in54b_V2_test.py: Example for 1.54inch e-paper B V2(Black/White/Red);<br /> | ||
+ | epd_1in54c_test.py: Example for 1.54inch e-paper C(Black/White/Red);br /> | ||
+ | |||
+ | ;2.7inch(264×176): | ||
+ | epd_2in7_test.py: Example for 2.7inch e-paper(Black/White);<br /> | ||
+ | epd_2in7b_test.py: Example for 2.7inch e-paper B(Black.White/Red);<br /> | ||
+ | epd_2in7b_V2_test.py: Example for 2.7inch e-paper B V2(Black.White/Red);<br /> | ||
+ | |||
+ | ;2.9inch(296×128): | ||
+ | epd_2in9_test.py: Example for 2.9inch e-paper(Black/White);<br /> | ||
+ | epd_2in9_V2_test.py: Example for 2.9inch e-paper V2(Black/White);<br /> | ||
+ | epd_2in9bc_test.py: Example for 2.9inch e-paper B(Balck/White/Red) and 2.9inch e-paper C(Black/White/Yellow);<br /> | ||
+ | epd_2in9b_V3_test.py: Example for 2.9inch e-paper B V3(Balck/White/Red;<br /> | ||
+ | epd_2in9d_test.py: Example for 2.9inch e-paper D(Black/White); | ||
+ | |||
+ | ;2.13inch(2.13inch e-Paper:250×122,others:212×104): | ||
+ | epd_2in13_test.py: Example for 2.13inch e-paper V1(Black/White), 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/White) This is the current version with sticker V2 on the backside (2020-07-29);<br /> | ||
+ | epd_2in13bc_test.py: Example for 2.13inch e-paper B(Black/White/Red)and 2.13inch e-paper C(Black/White/Yellow);<br /> | ||
+ | epd_2in13b_V3_test.py: Example for 2.13inch e-paper B V3(Black/White/Red)<br /> | ||
+ | epd_2in13d_test.py: Example for 2.13inch e-paper D(Black/White);<br /> | ||
+ | |||
+ | ;2.66inch (152 x 296): | ||
+ | epd_2in66_test.py: Example for 2.66inch e-Paper (Black/White); <br /> | ||
+ | epd_2in66b_test.py: Example for 2.66inch e-Paoer (Black/White/Red);<br /> | ||
+ | |||
+ | ;3.7inch (280 x 480): | ||
+ | epd_3in7_test.py: Example for 3.7inch e-Paper (Black/White); <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/White);<br /> | ||
+ | epd_4in2bc_test.py: Example for 4.2inch e-paper B(Black/White/Red);<br /> | ||
+ | epd_4in2b_V2_test.py: Example for 4.2inch e-paper B V2(Black/White/Red);<br /> | ||
+ | |||
+ | ;5.65inch (600x448): | ||
+ | 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/White);<br /> | ||
+ | epd_5in83_V2_test.py: Example for 5.83inch e-paper V2(Black/White);<br /> | ||
+ | epd_5in83bc_test.py: Example for 5.83inch e-paper B(Black/White/Red)and 5.83inch e-paper C(Black/White/Yellow);<br /> | ||
+ | epd_5in83b_V2_test.py: Example for 5.83inch e-paper B V2(Black/White/Red)<br /> | ||
+ | |||
+ | ;7.5inch(V1:640×384, V2:800×480): | ||
+ | epd_7in5_test.py: Example for 7.5inch e-paper(Black/White), 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/White), 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/White/Red)and 7.5inch e-paper C(Black/White/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/White/Red); This is the current version with V2 sticker on the backside. (2020-07-29);<br /> | ||
+ | |||
+ | ;7.5inch (HD 880 x 528): | ||
+ | epd_7in5_HD_test.py: Example for 7.5inch e-Paper HD (Black/White); <br /> | ||
+ | epd_7in5b_HD_test.py: Example for 7.5inch e-Paper B HD (Black/White/Red); <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 | # python2 | ||
− | sudo | + | sudo python2.7 epd_1in54_V2_test.py |
# python3 | # python3 | ||
− | sudo python3 | + | sudo python3 epd_1in54_V2_test.py |
</pre> | </pre> | ||
Revision as of 10:13, 21 June 2022
We provide examples for four popular platforms: Arduino UNO, Jetson Nano, Raspberry Pi, and STM32. You can refer to the corresponding part according to the platform you use(This is a common template will be used by all types of the e-Paper, please refer to the corresponding type you have)
Arduino
Hardware connection
The demo codes provided are tested on Arduino UNO. If you want to use another Arduino board, you may need to change the connection and port the codes by yourself.
The RAM of Arduino UNO is too small to realize drawing function of e-Paper. In this case, for most of the e-Paper, we only make the image display function and save the image to flash.
We recommend you to use [E-Paper Shield] if you use Arduino UNO. The seven-color e-Paper is not compatible with the e-Paper shield, please note it.
e-Paper | Arduino UNO | Mega2560 |
Vcc | 5V | 5V |
GND | GND | GND |
DIN | D11 | D51 |
CLK | D13 | D52 |
CS | D10 | D10 |
DC | D9 | D9 |
RST | D8 | D8 |
BUSY | D7 | D7 |
Install Arduino IDE
Run the Program
Download the program on the product encyclopedia interface, and then unzip it. Arduino programs are located at ~/Arduino/…
Please select the corresponding program to open according to the ink screen model
Supporting types
- 1.02inch(128×80):
epd_1in02y: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: Example for 1.54inch e-paper V1(Balck/White): This version is stopped production which can be bought before 2019-11-22;
epd_1in54_V2: Example for 1.54inch e-paper V2(Balck/White): This is the current version which can be bought now (2020-07-29). The e-Paper has V2 sticker on the backside.
epd_1in54b: Example for 1.54inch e-paper B(Black/White/Red);
epd_1in54b_V2: Example for 1.54inch e-paper B V2(Black/White/Red);
epd_1in54c: Example for 1.54inch e-paper C(Black/White/Red);br />
- 2.7inch(264×176):
epd_2in7: Example for 2.7inch e-paper(Black/White);
epd_2in7b: Example for 2.7inch e-paper B(Black.White/Red);
epd_2in7b_V2: Example for 2.7inch e-paper B V2(Black.White/Red);
- 2.9inch(296×128):
epd_2in9: Example for 2.9inch e-paper(Black/White);
epd_2in9_V2: Example for 2.9inch e-paper V2(Black/White);
epd_2in9bc: Example for 2.9inch e-paper B(Balck/White/Red) and 2.9inch e-paper C(Black/White/Yellow);
epd_2in9b_V3: Example for 2.9inch e-paper B V3(Balck/White/Red;
epd_2in9d: Example for 2.9inch e-paper D(Black/White);
- 2.13inch(2.13inch e-Paper:250×122,others:212×104):
epd_2in13: Example for 2.13inch e-paper V1(Black/White), this version is stopped production and it can be bought before 019-05-15;
epd_2in13_V2y: Example for 2.13inch e-paper V2(Black/White) This is the current version with sticker V2 on the backside (2020-07-29);
epd_2in13bc: Example for 2.13inch e-paper B(Black/White/Red)and 2.13inch e-paper C(Black/White/Yellow);
epd_2in13b_V3: Example for 2.13inch e-paper B V3(Black/White/Red)
epd_2in13d: Example for 2.13inch e-paper D(Black/White);
- 2.66inch (152 x 296)
epd_2in66: Example for 2.66inch e-Paper (Black/White);
epd_2in66b: Example for 2.66inch e-Paoer (Black/White/Red);
- 3.7inch (280 x 480)
epd_3in7: Example for 3.7inch e-Paper (Black/White);
- 4.01inch (640x400)
epd_4in01f: Example for 4.01inch e-Paper (Seven-color);
- 4.2inch(400×300)
epd_4in2: Example for 4.2inch e-paper(Black/White);
epd_4in2bc: Example for 4.2inch e-paper B(Black/White/Red);
epd_4in2b_V2: Example for 4.2inch e-paper B V2(Black/White/Red);
- 5.65inch (600x448)
epd_5in65f: Example for 5.65inch e-Paper F (Seven-color);
- 5.83inch(600×448):
epd_5in83: Example for 5.83inch e-paper(Black/White);
epd_5in83_V2: Example for 5.83inch e-paper V2(Black/White);
epd_5in83bc: Example for 5.83inch e-paper B(Black/White/Red)and 5.83inch e-paper C(Black/White/Yellow);
epd_5in83b_V2: Example for 5.83inch e-paper B V2(Black/White/Red)
- 7.5inch(V1:640×384, V2:800×480):
epd_7in5: Example for 7.5inch e-paper(Black/White), this version is stopped production and it can be bought before 2019-12-07;
epd_7in5_V2: Example for 7.5inch e-paper V2(Black/White), This is the current version with V2 sticker on the backside (2020-07-29)
epd_7in5bc: Example for 7.5inch e-paper B(Black/White/Red)and 7.5inch e-paper C(Black/White/Yellow),7.5inch e-paper B V1 version is stopped production and it can be bought before 2019-12-07;
epd_7in5b_V2: Example for 7.5inch e-paper B V2(Black/White/Red); This is the current version with V2 sticker on the backside. (2020-07-29);
- 7.5inch (HD 880 x 528)
epd_7in5_HD: Example for 7.5inch e-Paper HD (Black/White);
epd_7in5b_HD: Example for 7.5inch e-Paper B HD (Black/White/Red);
*Note: The above time is for reference only, please refer to the screen logo for the specific version
For example, 1.54inch e-Paper Module. Open the epd1in54 folder and run the epd1in54.ino file.
Open the program, select the development board model Arduino UNO
Select the corresponding COM port
Then click compile and download
Since the flash of arduino UNO is very small, several large-size screens use MEGA2560 for better results:<
Code Description
Files
Take the 1.54-inch ink screen controlled by Arduino UNO as an example, open the epd1in54 directory:
in which:
epd1in54.ino: open with Arduino IDE;
epd1in54.cpp(.h): is the driver of the ink screen;
epdif.cpp(.h): is the hardware interface definition, which encapsulates the read and write pin levels, SPI data transmission, and pin initialization;
font8.cpp, font12.cpp, font16.cpp, font20.cpp, font24.cpp, fonts.h: are the models of characters of different sizes;
imagedata.cpp(.h): is the image data, which can convert the 2-bit depth BMP image into an array through Img2Lcd (downloadable in the development data).
The program is divided into the bottom hardware interface, the middle layer ink screen driver, and the upper layer application;
Bottom Hardware Interface
hardware interfaces are defined in epdif.cpp(.h) file
- Write GPIO
void DigitalWrite(int pin, int value)
The first parameter is GPIO, and second parameter is level
- Read GPIO
int DigitalRead(int pin)
The parameter is GPIO, and return value is level
- Delay
DelayMs(unsigned int delaytime)
Delay time, unit is ms
- SPI transmit data
SpiTransfer(unsigned char data)
Type of parameter is char
- Hardware initailze
int IfInit(void)
The initialize function of SPI, input/ouptu are packaged here。
Middle EPD driver
- Instantiate e-Paper class
The Arduino codes are based on C++, should instantiate e-Paper class is necessary.
Epd epd;
- Initialize e-Paper, it should be used to initialize e-Paper or wakeup e-Paper from sleep mode.
- 2.13inch e-Paper,2.9inch e-Paper
epd.Init(lut_full_update); //Fully update epd.Init(lut_partial_update); //Partial update
- 4.2inch e-Paper
epd.Init();
- Clear, clear the e-Paper to white
epd.clear();
In some of project, the operation is divided to two part, they work in the same way
epd.ClearFrameMemory(0xFF); epd.DisplayFrame();//Display it
- Transmit one frame of image and display
void Display(const unsigned char* frame_buffer); void DisplayFrame(const unsigned char* frame_buffer_black, const unsigned char* frame_buffer_red); //Three color e-Paper
- Sleep
epd.Sleep();
Set the e-Paper enter sleep mode. The consumption of the e-Paper will be reduced. However, you still need to update the display periodically to avoid a ghost problem.
Application functions
The drawing functions are defined in this part.
The coordination of the image buffer:
The functions are defined in epdpaint.h file
- Initailze image buffer
Paint(unsigned char* image, int width, int height);
The first parameter is image buffer, the second one is the width of the picture, and the third one is the height.
Paint paint(image, 0, 0); // width should be the multiple of 8
The second and third parameters are set to 0, you can re-configure them with functions below:
- Set the width, height, rotate degree.
int GetWidth(void); //Get the width void SetWidth(int width);//Set the width int GetHeight(void);//Get the height void SetHeight(int height);//Set the height int GetRotate(void);//Get the degree void SetRotate(int rotate);//Set the rotate degree
- Get the image data
unsigned char* GetImage(void);
- Draw circle
void DrawPixel(int x, int y, int colored);
Coordination(x,y)
- Draw characater
void DrawCharAt(int x, int y, char ascii_char, sFONT* font, int colored);
Set(x,y)as the start point, draw characters ascii_char, set the fonts as font, color is colored.
- Draw string
void DrawStringAt(int x, int y, const char* text, sFONT* font, int colored);
Set(x,y)as the start point, draw the string text, font is font,color is colored
- Draw line
void DrawLine(int x0, int y0, int x1, int y1, int colored);
Use (x0,y0)as start point, (x1,y1) as end point;
- Draw cross line
void DrawHorizontalLine(int x, int y, int width, int colored);
Set(x0,y0)as start points,draw a line, the widht is width, and color is colored</ br>
- Draw a vertical line
void DrawVerticalLine(int x, int y, int height, int colored);
Use(x0,y0) as start point, draw a vertical line, width is height and color is colored./ br>
- Draw a empty rectangle
void DrawRectangle(int x0, int y0, int x1, int y1, int colored);
User(x0,y0) as start point,(x1,y1)is end point, draw a rectangel, color of edges are colored.
- Draw a full rectangle
void DrawFilledRectangle(int x0, int y0, int x1, int y1, int colored);
Use(x0,y0)as start point, (x1,y1) is end point, draw a rectange, filled it with color: colored
- Draw an empty circle
void DrawCircle(int x, int y, int radius, int colored);
Use (x,y)as center,draw a empty circle with radius, color is colored
- Draw a full circle
void DrawFilledCircle(int x, int y, int radius, int colored);
Use (x,y)as center, draw a circle, radius is radius, filled with color: colored
Raspberry Pi
Hardware connection
If the board you get is the HAT version like 2.13inch e-Paper HAT, you can directly attach it on the 40PIN GPIO of Raspberry Pi. Or you can wire it to Raspberry Pi with 8PIN cable.
e-Paper | Raspberry Pi | |
BCM2835 | Board | |
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 |
Enable SPI interface
- Open the terminal, and use the command to enter the configuration page.
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable the SPI interface
sudo reboot
Make sure that the SPI is not occupied by other devices, you can check in the middle of the /boot/config .txt.
- Check /boot/config.txt, and you can see 'dtparam=spi=on' was written in.
- 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.
Libraries Installation
- Install BCM2835 libraries
#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 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 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
Note: if you install on Raspian Lite, the git package is not istalled by default.
- Install git
sudo apt-get install git -y
Download examples
Open the Raspberry Pi terminal and execute:
Method 1: Download from our official website
sudo apt-get install p7zip-full wget https://www.waveshare.net/w/upload/3/39/E-Paper_code.7z 7z x E-Paper_code.7z -O./e-Paper cd e-Paper/RaspberryPi_JetsonNano/
Method 2: Use the github repository
git clone https://github.com/waveshare/e-Paper cd e-Paper/RaspberryPi_JetsonNano/
Running examples
Examples
C
Open main.c to select the screen of the corresponding size
cd c sudo nano examples/main.c
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)
Supporting types:
- 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/White): This version is stopped production which can be bought before 2019-11-22;
EPD_1in54_V2_test(): Example for 1.54inch e-paper V2(Balck/White): This is the current version that can be bought now (2020-07-29). The e-Paper has V2 sticker on the backside.
EPD_1in54b_test(): Example for 1.54inch e-paper B(Black/White/Red);
EPD_1in54b_V2_test(): Example for 1.54inch e-Paper B V2 (Black/White/Red);
EPD_1in54c_test(): Example for 1.54inch e-paper C(Black/White/Red);
- 2.7inch(264×176):
EPD_2in7_test(): Example for 2.7inch e-paper(Black/White);
EPD_2in7b_test(): Example for 2.7inch e-paper B(Black.White/Red);
EPD_2in7b_V2_test(): Example for 2.7inch e-paper B V2(Black.White/Red);
- 2.9inch(296×128):
EPD_2in9_test(): Example for 2.9inch e-paper(Black/White);
EPD_2in9_V2_test(): Example for 2.9inch e-paper V2(Black/White);
EPD_2in9bc_test(): Example for 2.9inch e-paper B(Balck/White/Red) and 2.9inch e-paper C(Black/White/Yellow);
EPD_2in9b_V3_test(): Example for 2.9inch e-paper B V3 (Balck/White/Red);
EPD_2in9d_test(): Example for 2.9inch e-paper D(Black/White);
- 2.13inch(2.13inch e-Paper:250×122,others:212×104):
EPD_2in13_test(): Example for 2.13inch e-paper V1(Black/White), this version is stopped production and it can be bought before 019-05-15;
EPD_2in13_V2_test(): Example for 2.13inch e-paper V2(Black/White) This is the current version with sticker V2 on the backside (2020-07-29);
EPD_2in13_V3_test(): Example for 2.13inch e-paper V3(Black/White) This is the current version with sticker V3 on the backside (2020-07-29);
EPD_2in13bc_test():Example for 2.13inch e-paper B(Black/White/Red)and 2.13inch e-paper C(Blackj/White/Yellow);
EPD_2in13b_V3_test():Example for 2.13inch e-paper B V3(Black/White/Red)
EPD_2in13d_test(): Example for 2.13inch e-paper D(Black/White);
- 2.66inch (152 x 296)
EPD_2in66_test(): Example for 2.66inch e-Paper (Black/White);
EPD_2in66b_test(): Example for 2.66inch e-Paper B (Black/White/Red);
- 3.7inch (280 x 480)
EPD_3in7_test(): Example for 3.7inch e-Paper(Black/White);
- 4.01inch (640x400)
EPD_4in01_test(): Example for the 4.01inch e-Paper HAT (F);
- 4.2inch(400×300)
EPD_4in2_test(): Example for 4.2inch e-paper(Black/White);
EPD_4in2bc_test(): Example for 4.2inch e-paper B(Black/White/Red);
EPD_4in2b_V2_test(): Example for 4.2inch e-paper B V2(Black/White/Red);
- 5.65inch (600x448)
EPD_5in65f_test(): Example for for 5.65inch e-Paper F (Seven-color);
- 5.83inch(600×448):
EPD_5in83_test(): Example for 5.83inch e-paper(Black/White);
EPD_5in83_V2_test(): Example for 5.83inch e-paper V2(Black/White);
EPD_5in83bc_test(): Example for 5.83inch e-paper B(Black/White/Red)and 5.83inch e-paper C(Black/White/Yellow);
EPD_5in83b_V2_test(): Example for 5.83inch e-paper B V2(Black/White/Red)
- 7.5inch(V1:640×384, V2:800×480):
EPD_7in5_test(): Example for 7.5inch e-paper(Black/White), this version is stopped production and it can be bought before 2019-12-07;
EPD_7in5bc_test(): Example for 7.5inch e-paper B(Black/White/Red)and 7.5inch e-paper C(Black/White/Yellow),7.5inch e-paper B V1 version is stop production and it can be bought before 2019-12-07;
EPD_7in5_V2_test(): Example for 7.5inch e-paper V2(Black/White), This is the current version with V2 sticker on the backside (2020-07-29)
EPD_7in5bc_V2_test():Example for 7.5inch e-paper B V2(Black/White/Red); This is the current version with V2 sticker on the backside. (2020-07-29);
- 7.5inch (HD
- 880 x 528)
EPD_7in5_HD_test(): Example for 7.5inch e-Paper HD (Black/White);
EPD_7in5b_HD_test(): Example for 7.5inch e-Paper B HD (Black/White/Red);
*Note: The above time is for reference only, please refer to the screen logo for the specific version
- Recompile, the compilation process may take a few seconds
Return to the c directory and run the following command make clean make sudo ./epd
Python
- Enter the folder of python code
cd python/examples ls -al
- Run the responding example
sudo python epd_xxx_test.py sudo python3 epd_xxx_test.py
Supporting types:
- 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/White): This version is stopped production which can be bought before 2019-11-22;
epd_1in54_V2_test.py: Example for 1.54inch e-paper V2(Balck/White): This is the current version which can be bought now (2020-07-29). The e-Paper has V2 sticker on the backside.
epd_1in54b_test.py: Example for 1.54inch e-paper B(Black/White/Red);
epd_1in54b_V2_test.py: Example for 1.54inch e-paper B V2(Black/White/Red);
epd_1in54c_test.py: Example for 1.54inch e-paper C(Black/White/Red);br />
- 2.7inch(264×176):
epd_2in7_test.py: Example for 2.7inch e-paper(Black/White);
epd_2in7b_test.py: Example for 2.7inch e-paper B(Black.White/Red);
epd_2in7b_V2_test.py: Example for 2.7inch e-paper B V2(Black.White/Red);
- 2.9inch(296×128):
epd_2in9_test.py: Example for 2.9inch e-paper(Black/White);
epd_2in9_V2_test.py: Example for 2.9inch e-paper V2(Black/White);
epd_2in9bc_test.py: Example for 2.9inch e-paper B(Balck/White/Red) and 2.9inch e-paper C(Black/White/Yellow);
epd_2in9b_V3_test.py: Example for 2.9inch e-paper B V3(Balck/White/Red;
epd_2in9d_test.py: Example for 2.9inch e-paper D(Black/White);
- 2.13inch(2.13inch e-Paper:250×122,others:212×104):
epd_2in13_test.py: Example for 2.13inch e-paper V1(Black/White), this version is stopped production and it can be bought before 019-05-15;
epd_2in13_V2_test.py: Example for 2.13inch e-paper V2(Black/White) This is the current version with sticker V2 on the backside (2020-07-29);
epd_2in13bc_test.py: Example for 2.13inch e-paper B(Black/White/Red)and 2.13inch e-paper C(Black/White/Yellow);
epd_2in13b_V3_test.py: Example for 2.13inch e-paper B V3(Black/White/Red)
epd_2in13d_test.py: Example for 2.13inch e-paper D(Black/White);
- 2.66inch (152 x 296)
epd_2in66_test.py: Example for 2.66inch e-Paper (Black/White);
epd_2in66b_test.py: Example for 2.66inch e-Paoer (Black/White/Red);
- 3.7inch (280 x 480)
epd_3in7_test.py: Example for 3.7inch e-Paper (Black/White);
- 4.01inch (640x400)
epd_4in01f_test.py: Example for 4.01inch e-Paper (Seven-color);
- 4.2inch(400×300)
epd_4in2_test.py: Example for 4.2inch e-paper(Black/White);
epd_4in2bc_test.py: Example for 4.2inch e-paper B(Black/White/Red);
epd_4in2b_V2_test.py: Example for 4.2inch e-paper B V2(Black/White/Red);
- 5.65inch (600x448)
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/White);
epd_5in83_V2_test.py: Example for 5.83inch e-paper V2(Black/White);
epd_5in83bc_test.py: Example for 5.83inch e-paper B(Black/White/Red)and 5.83inch e-paper C(Black/White/Yellow);
epd_5in83b_V2_test.py: Example for 5.83inch e-paper B V2(Black/White/Red)
- 7.5inch(V1:640×384, V2:800×480):
epd_7in5_test.py: Example for 7.5inch e-paper(Black/White), this version is stopped production and it can be bought before 2019-12-07;
epd_7in5_V2_test.py: Example for 7.5inch e-paper V2(Black/White), This is the current version with V2 sticker on the backside (2020-07-29)
epd_7in5bc_test.py: Example for 7.5inch e-paper B(Black/White/Red)and 7.5inch e-paper C(Black/White/Yellow),7.5inch e-paper B V1 version is stopped production and it can be bought before 2019-12-07;
epd_7in5b_V2_test.py: Example for 7.5inch e-paper B V2(Black/White/Red); This is the current version with V2 sticker on the backside. (2020-07-29);
- 7.5inch (HD 880 x 528)
epd_7in5_HD_test.py: Example for 7.5inch e-Paper HD (Black/White);
epd_7in5b_HD_test.py: Example for 7.5inch e-Paper B HD (Black/White/Red);
Note: The above time is for reference only, please refer to the screen logo for the specific version
Just run the program corresponding to the screen, the program supports python2/3, take 1.54 V2 as an example
# python2 sudo python2.7 epd_1in54_V2_test.py # python3 sudo python3 epd_1in54_V2_test.py
Jetson Nano Developer Kit
The example for Jetson Nano use software SPI, speed of sfotware SPI is a little slow
Hardware connection
Jetson Nano's 40PIN GPIO is compatible with Raspberry PI, and API of Jetson.GPIo is same as RPi.GPIO, therefore, the pin numbers of Jetson nano are same as Raspberry Pi's
e-Paper | Jetson Nano Developer Kit | |
BCM2835 | Board | |
VCC | 3.3V | 3.3V |
GND | GND | GND |
DIN | 10(SPI0_MOSI) | 19 |
CLK | 11(SPI0_SCK | 23 |
CS | 8(SPI0_CS0) | 24 |
DC | 25 | 22 |
RST | 17 | 11 |
BUSY | 24 | 18 |
Software setting
- Open terminal, and install GPIO libraries :
sudo apt-get update sudo apt-get install python3-pip sudo pip3 install Jetson.GPIO sudo groupadd -f -r gpio sudo usermod -a -G gpio your_user_name sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules && sudo udevadm trigger
Note: your_user_name is the user name of your Jetson, for example:waveshare
- Install I2C libraries
sudo apt-get install python-smbus
- Install PIL libraries
sudo apt-get install python3-pil sudo apt-get install python3-numpy
Download examples
Open terminal and execute commands:
sudo git clone https://github.com/waveshare/e-Paper cd e-Paper/RaspberryPi\&JetsonNano/
Running examples
- C codes
Find main.c file, Open it and uncommend the e-Paper which you use, compile and run it
cd c make clear make sudo ./epd
- python
Run examples, xxx is the name of e-Paper. For example, if you want to run examples of 1.54inch e-Paper Module, xxx should be epd_1in54
cd python/examples # python2 sudo python xxx.py # python3 sudo python3 xxx.py
STM32
Hardware connection
The examples we provide are based on Wavshare Open103Z, the connecting method provide is based on STM32F13ZET6 as well. For other board, please port it by yourself.
e-Paper | STM32F103ZET6 |
Vcc | 3.3V |
GND | GND |
DIN | PA7 |
CLK | PA5 |
CS | PA3 |
DC | PA2 |
RST | PA1 |
BUSY | PA3 |
Running examples
Enter the directly of STM32 examples, open project by Keil5 software. Set Board and programmer, then compile and download it to board