Difference between revisions of "Template:E-Paper Codes Description"

From Waveshare Wiki
Jump to: navigation, search
Line 110: Line 110:
 
Basic drawing functions are provided here.   
 
Basic drawing functions are provided here.   
 
You can find then in:<br />
 
You can find then in:<br />
对于Raspberry Pi和Jetson Nano,在目录:RaspberryPi&JetsonNano\c\lib\GUI\GUI_Paint.c(.h)<br />
+
Raspbian Pi & Jetson Nano: RaspberryPi&JetsonNano\c\lib\GUI\GUI_Paint.c(.h)<br />
对于STM32,在目录:STM32\STM32-F103ZET6\User\GUI\GUI_Paint.c(.h)<br />
+
STM32: STM32\STM32-F103ZET6\User\GUI\GUI_Paint.c(.h)<br />
 
[[file:e-paper_Driver_HAT_GUI.png|700px]]<br />
 
[[file:e-paper_Driver_HAT_GUI.png|700px]]<br />
在如下目录下是GUI依赖的字符字体:<br />
+
The fonts are saved in the directory:<br />
对于Raspberry Pi和Jetson Nano,在目录:RaspberryPi&JetsonNano\c\lib\Fonts<br />
+
Raspberry Pi & Jetson Nano: RaspberryPi&JetsonNano\c\lib\Fonts<br />
对于STM32,在目录:STM32\STM32-F103ZET6\User\Fonts<br />
+
STM32: STM32\STM32-F103ZET6\User\Fonts<br />
 
[[file:e-paper_Driver_HAT_Fonts.png|700px]]<br />
 
[[file:e-paper_Driver_HAT_Fonts.png|700px]]<br />
*新建图像属性:新建一个图像属性,这个属性包括图像缓存的名称、宽度、高度、翻转角度、颜色
+
*Create a new image buffer: This function is used to create a new image with width, height, Rotate degree and its color.
 
<pre>
 
<pre>
 
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
 
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
参数:
+
Paratemeters:
  image : 图像缓存的名称,实际上是一个指向图像缓存首地址的指针;
+
  image : The buffer of image, this is an pointer of buffer address;
  Width : 图像缓存的宽度;
+
  Width : width of the image;
  Height: 图像缓存的高度;
+
  Height: height of the image;
  Rotate:图像的翻转的角度
+
  Rotate:Rotate degree;
  Color :图像的初始颜色;
+
  Color :Initial color of the image;
 
</pre>
 
</pre>
  
*选择图像缓存:选择图像缓存,选择的目的是你可以创建多个图像属性,图像缓存可以存在多个,你可以选择你所创建的每一张图像
+
*Select image buffer: this function is used to select the image buffer. You can create multiple image buffer with last function, then select the buffer for every image.
 
<pre>void Paint_SelectImage(UBYTE *image)
 
<pre>void Paint_SelectImage(UBYTE *image)
 
参数:
 
参数:
  image: 图像缓存的名称,实际上是一个指向图像缓存首地址的指针;
+
  image: The name of image buffer, it is a pointer of buffer address;
 
</pre>
 
</pre>
  
*图像旋转:设置选择好的图像的旋转角度,最好使用在Paint_SelectImage()后,可以选择旋转0、90、180、270
+
*Set display orientation: This function is used to set the rotate degree, it is generally be used after Paint_SelectImage(). You can set the rotate degree to 0、90、180、270 degree.
 
<pre>void Paint_SetRotate(UWORD Rotate)
 
<pre>void Paint_SetRotate(UWORD Rotate)
参数:
+
Parameters:
  Rotate: 图像选择角度,可以选择ROTATE_0、ROTATE_90、ROTATE_180、ROTATE_270分别对应0、90、180、270度
+
  Rotate: Rotate degree, you can choose ROTATE_0、ROTATE_90、ROTATE_180、ROTATE_270 which stands for 0、90、180、270 degree repetitively.
 
</pre>
 
</pre>
*图像镜像翻转:设置选择好的图像的镜像翻转,可以选择不镜像、关于水平镜像、关于垂直镜像、关于图像中心镜像。
+
*Image mirroring: This function is used to mirror image.
 
<pre>void Paint_SetMirroring(UBYTE mirror)
 
<pre>void Paint_SetMirroring(UBYTE mirror)
参数:
+
Paramters:
  mirror: 图像的镜像方式,可以选择MIRROR_NONE、MIRROR_HORIZONTAL、MIRROR_VERTICAL、MIRROR_ORIGIN分别对应不镜像、关于水平镜像、关于垂直镜像、关于图像中心镜像
+
  mirror: You can set it to MIRROR_NONE、MIRROR_HORIZONTAL、MIRROR_VERTICAL、MIRROR_ORIGIN
 
</pre>
 
</pre>
*设置点在缓存中显示位置和颜色:这里是GUI最核心的一个函数、处理点在缓存中显示位置和颜色;
+
*Set pixel: this function is used to set the position and color of pixels in the buffer. This is the basic function of GUI.
 
<pre>
 
<pre>
 
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
 
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
 
参数:
 
参数:
  Xpoint: 点在图像缓存中X位置
+
  Xpoint: X-axes in buffer;
  Ypoint: 点在图像缓存中Y位置
+
  Ypoint: Y-axes in buffer;
  Color : 点显示的颜色
+
  Color : color
 
</pre>
 
</pre>
  

Revision as of 08:39, 9 September 2019

About the codes

We provide examples for four popular hardware platforms: Arduino UNO, Jetson UNO, Raspberry Pi, and STM32. (This is common Template for all e-Paper, some of the description/function may not be used by the e-Paper you have)
Every project is divided into hardware interface, EPD driver and the application function;
The programming languages are C\C++\python:

  • Arduino UNO:C++
  • Jetson Nano:C and python
  • Raspberry Pi:C and python
  • STM32:C

Note:
The EPD driver of C codes of Jetson Nano, Raspberry Pi and STM32 are compatible. Except the hardware interface, the codes are same;

C (Used for Jetson Nano、Raspberry Pi、STM32)

Hardware interface

Because of multiple hardware platforms, we packge the bottom, for details of how it realizes, you go to related directory for certain codes

In file DEV_Config.c(.h):
For Raspberry Pi, the files are located in: RaspberryPi&JetsonNano\c\lib\Config

Here we use two libraries: bcm2835 and wiringPi
WiringPi library is used by default, if you want to use bcm2835 libraries, you just need to modify RaspberryPi&JetsonNano\c\Makefile file, change the lines 13 and 14 as below::
E-paper Driver HAT RPI Makefile.png

For Jetson Nano, the files are located in RaspberryPi&JetsonNano\c\lib\Config
For STM32, the files are located in STM32\STM32-F103ZET6\User\Config

  • Data type:
#define UBYTE   uint8_t
#define UWORD   uint16_t
#define UDOUBLE uint32_t
  • Module Init and Exit handle:
void DEV_Module_Init(void);
void DEV_Module_Exit(void);

Note:

1.The functions are used to set GPIP before and after driving e-Paper.

2.If the board you have is printed with Rev2.1, module enter low-ultra mode after DEV_Module_Exit(). (as we test, the current is about 0 in this mode);

  • GPIO Read/Write:
void DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE DEV_Digital_Read(UWORD Pin);
  • SPI Write data
void DEV_SPI_WriteByte(UBYTE Value);
EPD driver

For Raspberry Pi and Jetson Nano, epd driver are saved in:RaspberryPi&JetsonNano\c\lib\e-Paper
For STM32, the epd driver are saved in: STM32\STM32-F103ZET6\User\e-Paper
E-paper Driver HAT RPI epd.png
Open .h file, functions are declarated here

  • Initialization: It should be used to initialize e-Paper or wakeup e-Paper from sleep mode.
//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 Initialize full refresh; Mode = 1 Initilize partial refresh 
//Other types
void EPD_xxx_Init(void);

xxx is the type of e-paper, for example, if the e-paper you have is 2inch e-Paper (D), then it should be EPD_2IN13D_Init(0) or EPD_2IN13D_Init(1); If it is 7.5inch e-Paper (B), the function should be EPD_7IN5BC_Init(). B type and C type of 7.5inch e-Paper use the same codes.

  • Clear display: This function is used to clear the e-paper to white
void EPD_xxx_Clear(void);

xxx is the type of e-Paper. For example, if the e-Paper you have is 4.2inch e-Paper, it should be EPD-4IN2_Clear()

  • Transmit a frame of image and display
//Black/White e-Paper
void EPD_xxx_Display(UBYTE *Image);
//Three colors e-Paper
void EPD_xxx_Display(const UBYTE *blackimage, const UBYTE *ryimage);


There are some exceptions:

//To partial refresh 2.13inch e-paper (D)、2.9inch e-paper (D), you should use
 void EPD_2IN13D_DisplayPart(UBYTE *Image);
 void EPD_2IN9D_DisplayPart(UBYTE *Image);


//Because controllers of 1.54inch e-Paper V2 and 2.13inch e-Paper V2 were updated, you need to use EPD_xxx_DisplayPartBaseImage to display static image and ten use EPD_xxx_displayPart() to dymatic display when partial refreshing.
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);


//Because STM32103ZET5 has no enough RAM for image, therefore 7.5B、7.5C、5.83B、5.83C can only display half of the screen:'''
void EPD_7IN5BC_DisplayHalfScreen(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_5IN83BC_DisplayHalfScreen(const UBYTE *blackimage, const UBYTE *ryimage);

xxx is the type of e-Paper

  • Enter sleep mode
void EPD_xxx_Sleep(void);

Note, You should hardware reset or use initialize function to wake up e-Paper from sleep mode
xxx is type of e-Paper

Application function

Basic drawing functions are provided here. You can find then in:
Raspbian Pi & Jetson Nano: RaspberryPi&JetsonNano\c\lib\GUI\GUI_Paint.c(.h)
STM32: STM32\STM32-F103ZET6\User\GUI\GUI_Paint.c(.h)
E-paper Driver HAT GUI.png
The fonts are saved in the directory:
Raspberry Pi & Jetson Nano: RaspberryPi&JetsonNano\c\lib\Fonts
STM32: STM32\STM32-F103ZET6\User\Fonts
E-paper Driver HAT Fonts.png

  • Create a new image buffer: This function is used to create a new image with width, height, Rotate degree and its color.
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
Paratemeters:
 	image : The buffer of image, this is an pointer of buffer address;
 	Width : width of the image;
 	Height: height of the image;
 	Rotate:Rotate degree;
 	Color :Initial color of the image;
  • Select image buffer: this function is used to select the image buffer. You can create multiple image buffer with last function, then select the buffer for every image.
void Paint_SelectImage(UBYTE *image)
参数:
 	image: The name of image buffer, it is a pointer of buffer address;
  • Set display orientation: This function is used to set the rotate degree, it is generally be used after Paint_SelectImage(). You can set the rotate degree to 0、90、180、270 degree.
void Paint_SetRotate(UWORD Rotate)
Parameters:
 	Rotate: Rotate degree, you can choose ROTATE_0、ROTATE_90、ROTATE_180、ROTATE_270 which stands for 0、90、180、270 degree repetitively.
  • Image mirroring: This function is used to mirror image.
void Paint_SetMirroring(UBYTE mirror)
Paramters:
 	mirror: You can set it to MIRROR_NONE、MIRROR_HORIZONTAL、MIRROR_VERTICAL、MIRROR_ORIGIN
  • Set pixel: this function is used to set the position and color of pixels in the buffer. This is the basic function of GUI.
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
参数:
 	Xpoint: X-axes in buffer;
 	Ypoint: Y-axes in buffer;
 	Color : color
  • 图像缓存填充颜色:把图像缓存填充为某颜色,一般作为屏幕刷白的作用
void Paint_Clear(UWORD Color)
参数:
 	Color: 填充的颜色
  • 图像缓存部分窗口填充颜色:把图像缓存的某部分窗口填充为某颜色,一般作为窗口刷白的作用,常用于时间的显示,刷白上一秒
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
参数:
 	Xstart: 窗口的X起点坐标
 	Ystart: 窗口的Y起点坐标
 	Xend: 窗口的X终点坐标
 	Yend: 窗口的Y终点坐标
 	Color: 填充的颜色
  • 画点:在图像缓存中,在(Xpoint, Ypoint)上画点,可以选择颜色,点的大小,点的风格
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
参数:
 	Xpoint: 点的X坐标
 	Ypoint: 点的Y坐标
 	Color: 填充的颜色
 	Dot_Pixel: 点的大小,提供默认的8种大小点
 	 	 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;
 	Dot_Style: 点的风格,大小扩充方式是以点为中心扩大还是以点为左下角往右上扩大
 	 	typedef enum {
 	 	   DOT_FILL_AROUND  = 1,		
 	 	   DOT_FILL_RIGHTUP,
 	 	} DOT_STYLE;
  • 画线:在图像缓存中,从 (Xstart, Ystart) 到 (Xend, Yend) 画线,可以选择颜色,线的宽度,线的风格
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
参数:
 	Xstart: 线的X起点坐标
 	Ystart: 线的Y起点坐标
 	Xend: 线的X终点坐标
 	Yend: 线的Y终点坐标
 	Color: 填充的颜色
 	Line_width: 线的宽度,提供默认的8种宽度
 	 	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;
 	 Line_Style: 线的风格,选择线是以直线连接还是以虚线的方式连接
 	 	typedef enum {
 	 	 	 LINE_STYLE_SOLID = 0,
 	 	 	 LINE_STYLE_DOTTED,
 	 	} LINE_STYLE;
  • 画矩形:在图像缓存中,从 (Xstart, Ystart) 到 (Xend, Yend) 画一个矩形,可以选择颜色,线的宽度,是否填充矩形内部
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
参数:
 	Xstart: 矩形的X起点坐标
 	Ystart: 矩形的Y起点坐标
 	Xend: 矩形的X终点坐标
 	Yend: 矩形的Y终点坐标
 	Color: 填充的颜色
 	Line_width: 矩形四边的宽度,提供默认的8种宽度
 	 	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: 填充,是否填充矩形的内部
 	 	typedef enum {
 	 	 	 DRAW_FILL_EMPTY = 0,
 	 	 	 DRAW_FILL_FULL,
 	 	} DRAW_FILL;
  • 画圆:在图像缓存中,以 (X_Center Y_Center) 为圆心,画一个半径为Radius的圆,可以选择颜色,线的宽度,是否填充圆内部
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
参数:
 	X_Center: 圆心的X坐标
 	Y_Center: 圆心的Y坐标
 	Radius:圆的半径
 	Color: 填充的颜色
 	Line_width: 圆弧的宽度,提供默认的8种宽度
 	 	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: 填充,是否填充圆的内部
 	 	typedef enum {
 	 	 	 DRAW_FILL_EMPTY = 0,
 	 	 	 DRAW_FILL_FULL,
 	 	} DRAW_FILL;
  • 写Ascii字符:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一个Ascii字符,可以选择Ascii码可视字符字库、字体前景色、字体背景色
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
参数:
 	Xstart: 字符的左顶点X坐标
 	Ystart: 字体的左顶点Y坐标
 	Ascii_Char:Ascii字符
 	Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
 	 	font8:5*8的字体
 	 	font12:7*12的字体
 	 	font16:11*16的字体
 	 	font20:14*20的字体
 	 	font24:17*24的字体
 	Color_Foreground: 字体颜色
 	Color_Background: 背景颜色
  • 写英文字符串:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一串英文字符,可以选择Ascii码可视字符字库、字体前景色、字体背景色
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
参数:
 	Xstart: 字符的左顶点X坐标
 	Ystart: 字体的左顶点Y坐标
 	pString:字符串,字符串是一个指针
 	Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
 	 	font8:5*8的字体
 	 	font12:7*12的字体
 	 	font16:11*16的字体
 	 	font20:14*20的字体
 	 	font24:17*24的字体
 	Color_Foreground: 字体颜色
 	Color_Background: 背景颜色
  • 写中文字符串:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一串中文字符,可以选择GB2312编码字符字库、字体前景色、字体背景色;
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
参数:
 	Xstart: 字符的左顶点X坐标
 	Ystart: 字体的左顶点Y坐标
 	pString:字符串,字符串是一个指针
 	Font: GB2312编码字符字库,在Fonts文件夹中提供了以下字体:
 	 	font12CN:ascii字符字体11*21,中文字体16*21
 	 	font24CN:ascii字符字体24*41,中文字体32*41
 	Color_Foreground: 字体颜色
 	Color_Background: 背景颜色
  • 写数字:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一串数字,可以选择Ascii码可视字符字库、字体前景色、字体背景色
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
参数:
 	Xstart: 字符的左顶点X坐标
 	Ystart: 字体的左顶点Y坐标
 	Nummber:显示的数字,这里使用的是32位长的int型保存,可以最大显示到2147483647
 	Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
 	 	font8:5*8的字体
 	 	font12:7*12的字体
 	 	font16:11*16的字体
 	 	font20:14*20的字体
 	 	font24:17*24的字体
 	Color_Foreground: 字体颜色
 	Color_Background: 背景颜色
  • 显示时间:在图像缓存中,在 (Xstart Ystart) 为左顶点,显示一段时间,可以选择Ascii码可视字符字库、字体前景色、字体背景色;这里是方便测试局部刷新而写的,因为局部刷新需要的时间为0.3S,整体显示少于1S加上数据的传输,可以做到1S刷新一次
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Background, UWORD Color_Foreground)
参数:
 	Xstart: 字符的左顶点X坐标
 	Ystart: 字体的左顶点Y坐标
 	pTime:显示的时间,这里定义好了一个时间的结构体,只要把时分秒各位数传给参数;
 	Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
 	 	font8:5*8的字体
 	 	font12:7*12的字体
 	 	font16:11*16的字体
 	 	font20:14*20的字体
 	 	font24:17*24的字体
 	Color_Foreground: 字体颜色
 	Color_Background: 背景颜色
  • 写图片:把一个位图写入图像缓存中
void Paint_DrawBitMap(const unsigned char* image_buffer)
参数:
 	image_buffer: 图像数据的缓存中的首地址
  • 读取本地的bmp图片并写到缓存中

对于Jetson Nano, Raspberry Pi这些Linux操作系统的,可以读写图片
对于Raspberry Pi和Jetson Nano,在目录:RaspberryPi&JetsonNano\c\lib\GUI\GUI_BMPfile.c(.h)

UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart)
参数:
	path:BMP图片的相对路径
 	Xstart: 图片的左顶点X坐标,一般默认传0
 	Ystart: 图片的左顶点Y坐标,一般默认传0

用户测试代码

前三个章节介绍了经典的linux三层代码结构,这里稍微讲解一下用户测试代码
对于Raspberry Pi和Jetson Nano,在目录:RaspberryPi&JetsonNano\c\examples,为全部的测试代码,在本目录下的main.c中可以多个屏蔽;
E-Paper Shield c test.png
如果需要运行7.5inch e-paper测试程序,你需要把42行的屏蔽去掉

// EPD_7in5_test();

改成

EPD_7in5_test();

在linux命令模式下重新执行如下:

make clean
make
sudo ./epd

对于STM32,在目录:STM32\STM32-F103ZET6\User\Examples,为全部的测试代码,可以打开工程后在mai.c中本目录下的main.c中可以多个屏蔽;
打开工程:STM32\STM32-F103ZET6\MDK-ARM\epd-demo.uvprojx
E-paper Driver stm32 main.png
如果需要运行7.5inch e-paper测试程序,你需要把96行的屏蔽去掉

// EPD_7in5_test();

改成

EPD_7in5_test();

在Keil中重新编译并选择下载器下载

Python(适用于Jetson Nano\Raspberry Pi)

适用于python2.7和python3
对于python而言他的调用没有C复杂
Raspberry Pi和Jetson Nano:RaspberryPi&JetsonNano\python\lib\
E-paper Driver python lib.png

epdconfig.py

  • 模块初始化与退出的处理:
def module_init()
def module_exit()
 注意:
 1.这里是处理使用墨水屏前与使用完之后一些GPIO的处理。
 2.对于PCB带有Rev2.1的,module_exit()之后整个模块会进入低功耗,经过测试这个功耗基本为0;
  • GPIO读写:
def  digital_write(pin, value)
def  digital_read(pin)
  • SPI写数据
def spi_writebyte(data)

epdxxx.py(xxx表示尺寸,若是2.13inch e-paper,则为epd2in13.py,依此类推)

  • 墨水屏初始化,再屏幕开始工作时和退出睡眠模式之后调用
对于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)
def init(self, update) # 选择lut_full_update或lut_partial_update
其他型号
def init(self)
  • 清屏,把墨水屏刷成白色
def Clear(self)
def Clear(self, color) # 对于某几个屏幕需要调用这个
  • 把图片转换成数组
def getbuffer(self, image)
  • 传输一帧的图片数据并打开显示
黑白双色墨水屏
def display(self, image)
黑白红或黑白黄墨水屏
def display(self, blackimage, redimage)

需要注意以下的几个是特例:<br />
对于2.13inch e-paper (D)、2.9inch e-paper (D)两款柔性屏幕,局部刷新
def DisplayPartial(self, image)

对于1.54inch e-paper V2、2.13inch e-paper V2由于控制芯片升级,对于局部刷新,需要调用displayPartBaseImage()显示静态的背景图片,也就是以这个图片为基础进行局部刷新,然后调用动态的displayPart()
def displayPartBaseImage(self, image)
def displayPart(self, image)
  • 进入睡眠模式
def sleep(self)

epd_xxx_test.py(xxx表示尺寸,若是2.13inch e-paper,则为epd_2in13_test.py,依此类推)

python在如下目录:
Raspberry Pi和Jetson Nano:RaspberryPi&JetsonNano\python\examples\
E-paper Driver python examples.png
如果你的python版本是python2,且需要运行7.5inch e-paper测试程序,在linux命令模式下重新执行如下:

sudo python epd_7in5_test.py

如果你的python版本是python3,且需要运行7.5inch e-paper测试程序,在linux命令模式下重新执行如下:

sudo python3 epd_7in5_test.py

Arduino

对于Arduino,由于Arduino UNO的内存不够,部分例程写了怎么写字符,但是不推荐这样使用,这样复杂化了Arduino的操作,如果需要用e-paper Sheild驱动