Difference between revisions of "E-paper for STM32 Use"

From ingcool
Jump to: navigation, search
(创建页面,内容为“='''STM32'''= ==硬件连接== 我们提供的例程是基于STM32F103ZET6的,提供的连接方式也是对应的STM32F103ZET6的引脚,如果有需要移植程…”)
 
 
Line 1: Line 1:
 
='''STM32'''=
 
='''STM32'''=
==硬件连接==
+
==Hardware connection==
我们提供的例程是基于STM32F103ZET6的,提供的连接方式也是对应的STM32F103ZET6的引脚,如果有需要移植程序,请按实际引脚连接
+
The demo codes we provide are based on STM32F103ZET6, the connection table is also based on STM32F103ZET6, if you want to use other chip, you need to port the codes yourself and change the connection according to actual situation.
 
{|border=1; style="width:700px;" align="center"
 
{|border=1; style="width:700px;" align="center"
|+STM32F103ZET连接引脚对应关系
+
|+Connect to STM32F103ZET
 
|-style="background:#2E8B57; color:white;" align="center"
 
|-style="background:#2E8B57; color:white;" align="center"
 
|e-Paper||STM32
 
|e-Paper||STM32
Line 24: Line 24:
 
|}
 
|}
  
==软件说明==
+
==Softawre settings==
例程是基于HAL库进行开发的。
+
The codes are based on HAL library.
下载程序,找到STM32程序文件目录,打开STM32\STM32-F103ZET6\MDK-ARM目录下的epd-demo.uvprojx,即可看到程序。<br />
+
Download the codes and the project files are saved under the STM32\STM32-F103ZET6\MDK-ARM directory.<br />
 
[[file:e-paper_stm32_code1.png|500px]]<br />
 
[[file:e-paper_stm32_code1.png|500px]]<br />
  
打开main.c,可以看到所有的测试程序,把对应的屏幕的测试程序前面的注释去掉,重新编译下载即可。<br />
+
Modify main.c, define the line according to the e-paper type and re-compile project and download.<br />
 
[[file:e-paper_stm32_code2.png|500px]]<br />
 
[[file:e-paper_stm32_code2.png|500px]]<br />
  
==程序说明==
+
==Codes description==
===底层硬件接口===
+
===Bottom hardware interface===
我们进行了底层的封装,由于硬件平台不一样,内部的实现是不一样的,如果需要了解内部实现可以去对应的目录中查看<br />
+
We package the bottom for different hardware platforms.<br />
在DEV_Config.c(.h)可以看到很多定义,在目录:\STM32\STM32-F103ZET6\User\Config<br />
+
You can check the DEV_Config.c(.h) file which is located in \STM32\STM32-F103ZET6\User\Config<br />
*数据类型:
+
*Data type:
 
  #define UBYTE  uint8_t
 
  #define UBYTE  uint8_t
 
  #define UWORD  uint16_t
 
  #define UWORD  uint16_t
 
  #define UDOUBLE uint32_t
 
  #define UDOUBLE uint32_t
*模块初始化与退出的处理:
+
*Module initialized and exit:
 
  void DEV_Module_Init(void);
 
  void DEV_Module_Init(void);
 
  void DEV_Module_Exit(void);
 
  void DEV_Module_Exit(void);
注意:
+
 
1.这里是处理使用墨水屏前与使用完之后一些GPIO的处理。
+
Note:
2.对于PCB带有Rev2.1的,DEV_Module_Exit()之后整个模块会进入低功耗,经过测试这个功耗基本为0;
+
1.The functions are used to set GPIP before and after driving e-Paper.</ br>
*GPIO读写:
+
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);</ br>
 +
*GPIO Read/Write:
 
  void DEV_Digital_Write(UWORD Pin, UBYTE Value);
 
  void DEV_Digital_Write(UWORD Pin, UBYTE Value);
 
  UBYTE DEV_Digital_Read(UWORD Pin);
 
  UBYTE DEV_Digital_Read(UWORD Pin);
*SPI写数据
+
*SPI Write data
 
  void DEV_SPI_WriteByte(UBYTE Value);
 
  void DEV_SPI_WriteByte(UBYTE Value);
 
+
===Middle EPD driver===
===中间层墨水屏驱动===
+
The epd driver are saved in: STM32\STM32-F103ZET6\User\e-Paper<br />
e-paper驱动代码文件,在目录:\STM32\STM32-F103ZET6\User\e-Paper<br />
+
Open .h file, functions are declarated here<br />
 
+
*Initialization: It should be used to initialize e-Paper or wakeup e-Paper from sleep mode.
打开.h可以看到如下的函数<br />
 
*墨水屏初始化,再屏幕开始工作时和退出睡眠模式之后调用
 
 
  '''//2.13inch e-Paper、2.9inch e-Paper
 
  '''//2.13inch e-Paper、2.9inch e-Paper
  void EPD_xxx_Init(UBYTE Mode); // Mode = 0 全局刷新初始化、Mode = 1 局部刷新初始化
+
  void EPD_xxx_Init(UBYTE Mode); //ode = 0 Initialize full refresh; Mode = 1 Initilize partial refresh
  '''//其他型号
+
  '''//Other type
 
  void EPD_xxx_Init(void);
 
  void EPD_xxx_Init(void);
其中xxx表示,墨水屏型号。如是是2.13,全屏初始化那么是EPD_2IN13_V2_Init(0),局部刷新初始化EPD_2IN13_V2_Init(1);
+
xxx is the type of e-paper
  
*清屏,把墨水屏刷成白色
+
*Clear display: This function is used to clear the e-paper to white
 
  void EPD_xxx_Clear(void);  
 
  void EPD_xxx_Clear(void);  
其中xxx表示,墨水屏型号。如是是2.13,那么是EPD_2IN9_V2_Clear();<br />
+
xxx is the type of e-Paper. <br />
  
*传输一帧的图片数据并打开显示
+
*Transmit a frame of image and display
  '''//黑白双色墨水屏
+
  '''//Black/White e-Paper
 
  void EPD_xxx_Display(UBYTE *Image);
 
  void EPD_xxx_Display(UBYTE *Image);
  
  '''//2.13inch e-paper 由于控制芯片升级,对于局部刷新,需要调用EPD_xxx_DisplayPartBaseImage显示静态的背景图片,也就是以这个图片为基础进行局部刷新,然后调用动态的EPD_xxx_DisplayPart()
+
  '''Because controllers of2.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_2IN13_V2_DisplayPart(UBYTE *Image);
 
  void EPD_2IN13_V2_DisplayPart(UBYTE *Image);
 
  void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image);
 
  void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image);
  
*进入睡眠模式
+
*Enter sleep mode
 
  void EPD_xxx_Sleep(void);
 
  void EPD_xxx_Sleep(void);
注意进入了睡眠模式,只有两个方式能够重新工作:第一种硬件复位,第二种重新调用初始化函数<br />
+
Note, You should hardware reset or use initialize function to wake up e-Paper from sleep mode<br />
其中xxx表示,墨水屏型号。如是是2.13D,那么是EPD_2IN13D_Sleep();如果是7.5B,那就是EPD_7IN5BC_Sleep(),因为7.5B与7.5C公用驱动代码,只是显示的颜色不一样<br />
+
xxx is the type of e-Paper<br />
  
===上层应用===
+
===Application function===
对于屏幕而言,如果需要进行画图、显示中英文字符、显示图片等怎么办,这些都是上层应用做的。这有很多小伙伴有问到一些图形的处理,我们这里提供了一些基本的功能
+
Basic drawing functions are provided here. You can find they in:\STM32\STM32-F103ZET6\User\GUI\GUI_Paint.c(.h)<br />
在如下的目录中可以找到GUI,在目录:\STM32\STM32-F103ZET6\User\GUI\GUI_Paint.c(.h)<br />
 
  
在如下目录下是GUI依赖的字符字体,在目录:\STM32\STM32-F103ZET6\User\Fonts<br />
+
The fonts are saved in the directory:\STM32\STM32-F103ZET6\User\Fonts<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)
参数:
+
Parameter:
  image : 图像缓存的名称,实际上是一个指向图像缓存首地址的指针;
+
  image: The buffer of the image, this is a 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)
参数:
+
Parameter:
  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)
参数:
+
Parameter:
  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)
参数:
+
Parameter:
  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)
参数:
+
Parameter:
  Xpoint: 点在图像缓存中X位置
+
  Xpoint: X-axes in the buffer;
  Ypoint: 点在图像缓存中Y位置
+
  Ypoint: Y-axes in buffer;
  Color : 点显示的颜色
+
  Color: color
 
</pre>
 
</pre>
  
*图像缓存填充颜色:把图像缓存填充为某颜色,一般作为屏幕刷白的作用
+
*Clear: This function is used to clear the screen to certain color.
 
<pre>
 
<pre>
 
void Paint_Clear(UWORD Color)
 
void Paint_Clear(UWORD Color)
参数:
+
Parameter:
  Color: 填充的颜色
+
  Color:  
 
</pre>
 
</pre>
  
*图像缓存部分窗口填充颜色:把图像缓存的某部分窗口填充为某颜色,一般作为窗口刷白的作用,常用于时间的显示,刷白上一秒
+
*Clear windows: this function is used to clear a window. It is generally used for time display.
 
<pre>
 
<pre>
 
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
 
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
参数:
+
Parameter:
  Xstart: 窗口的X起点坐标
+
  Xstart: Start coordinate of X-axes of the window;
  Ystart: 窗口的Y起点坐标
+
  Ystart: Start coordinate of Y-axes of the window;
  Xend: 窗口的X终点坐标
+
  Xend: End coordinate of X-axes of the window;
  Yend: 窗口的Y终点坐标
+
  Yend: End coordinate of Y-axes of the window;
  Color: 填充的颜色
+
  Color:
 
</pre>
 
</pre>
  
*画点:在图像缓存中,在(Xpoint, Ypoint)上画点,可以选择颜色,点的大小,点的风格
+
*Draw point: Draw a point on the position (Xpoint, Ypoint)in buffer
 
<pre>
 
<pre>
 
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
 
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
参数:
+
Parameter:
  Xpoint: 点的X坐标
+
  Xpoint: X coordinate of point;
  Ypoint: 点的Y坐标
+
  Ypoint: Y coordinate of point;
  Color: 填充的颜色
+
  Color: color of point;
  Dot_Pixel: 点的大小,提供默认的8种大小点
+
  Dot_Pixel: the size of point, there are 8 sizes available;
 
  typedef enum {
 
  typedef enum {
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
Line 159: Line 157:
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  } DOT_PIXEL;
 
  } DOT_PIXEL;
  Dot_Style: 点的风格,大小扩充方式是以点为中心扩大还是以点为左下角往右上扩大
+
  Dot_Style: style of point.
 
  typedef enum {
 
  typedef enum {
 
    DOT_FILL_AROUND  = 1,
 
    DOT_FILL_AROUND  = 1,
Line 166: Line 164:
 
</pre>
 
</pre>
 
   
 
   
*画线:在图像缓存中,从 (Xstart, Ystart) (Xend, Yend) 画线,可以选择颜色,线的宽度,线的风格
+
*Draw line: draw a line for (Xstart, Ystart) to (Xend, Yend)
 
<pre>
 
<pre>
 
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
 
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
参数:
+
Parameter:
  Xstart: 线的X起点坐标
+
  Xstart: Start coordinate of X-axes of line;
  Ystart: 线的Y起点坐标
+
  Ystart: Start coordinate of Y-axes of line;
  Xend: 线的X终点坐标
+
  Xend: End coordinate of X-axes of line;
  Yend: 线的Y终点坐标
+
  Yend: End coordinate of Y-axes of line
  Color: 填充的颜色
+
  Color:
  Line_width: 线的宽度,提供默认的8种宽度
+
  Line_width: the width of line, 8 sizes are avalilable;
 
  typedef enum {
 
  typedef enum {
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
Line 186: Line 184:
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  } DOT_PIXEL;
 
  } DOT_PIXEL;
  Line_Style: 线的风格,选择线是以直线连接还是以虚线的方式连接
+
  Line_Style: Style of the line;
 
  typedef enum {
 
  typedef enum {
 
  LINE_STYLE_SOLID = 0,
 
  LINE_STYLE_SOLID = 0,
Line 193: Line 191:
 
</pre>
 
</pre>
  
*画矩形:在图像缓存中,从 (Xstart, Ystart) (Xend, Yend) 画一个矩形,可以选择颜色,线的宽度,是否填充矩形内部
+
*Draw rectangle: Draw a rectangle from (Xstart, Ystart) to (Xend, Yend).
 
<pre>
 
<pre>
 
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
 
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
参数:
+
Parameter:
  Xstart: 矩形的X起点坐标
+
  Xstart: Start coordinate of X-axes of rectangle
  Ystart: 矩形的Y起点坐标
+
  Ystart: Start coordinate of Y-axes of rectangle
  Xend: 矩形的X终点坐标
+
  Xend: End coordinate of X-end of rectangle
  Yend: 矩形的Y终点坐标
+
  Yend: End coordinate of Y-end of rectangle
  Color: 填充的颜色
+
  Color: color of rectangle
  Line_width: 矩形四边的宽度,提供默认的8种宽度
+
  Line_width: The width of edges, 8 sides are available;
 
  typedef enum {
 
  typedef enum {
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
Line 213: Line 211:
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  } DOT_PIXEL;
 
  } DOT_PIXEL;
  Draw_Fill: 填充,是否填充矩形的内部
+
  Draw_Fill: set the rectangle full or empty.
 
  typedef enum {
 
  typedef enum {
 
  DRAW_FILL_EMPTY = 0,
 
  DRAW_FILL_EMPTY = 0,
Line 220: Line 218:
 
</pre>
 
</pre>
  
*画圆:在图像缓存中,以 (X_Center Y_Center) 为圆心,画一个半径为Radius的圆,可以选择颜色,线的宽度,是否填充圆内部
+
*Draw circle:Draw a circle, use (X_Center Y_Center) as center;
 
<pre>
 
<pre>
 
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
 
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坐标
+
  X_Center: X coordinate of center
  Y_Center: 圆心的Y坐标
+
  Y_Center: Y coordinate of center
  Radius:圆的半径
+
  Radius:Radius of circle
  Color: 填充的颜色
+
  Color: color of circle
  Line_width: 圆弧的宽度,提供默认的8种宽度
+
  Line_width: width of circle, 8 sizes are avalilable
 
  typedef enum {
 
  typedef enum {
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
 
  DOT_PIXEL_1X1  = 1, // 1 x 1
Line 239: Line 237:
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  DOT_PIXEL_8X8  , // 8 X 8
 
  } DOT_PIXEL;
 
  } DOT_PIXEL;
  Draw_Fill: 填充,是否填充圆的内部
+
  Draw_Fill: style of circle
 
  typedef enum {
 
  typedef enum {
 
  DRAW_FILL_EMPTY = 0,
 
  DRAW_FILL_EMPTY = 0,
Line 246: Line 244:
 
</pre>
 
</pre>
  
*写Ascii字符:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一个Ascii字符,可以选择Ascii码可视字符字库、字体前景色、字体背景色
+
*Draw character (ASCII): Set(Xstart Ystart) as letf-top point, draw a ASCII character.
 
<pre>
 
<pre>
 
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
 
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
参数:
+
Parameter:
  Xstart: 字符的左顶点X坐标
+
  Xstart: X coordinate of left-top pixel of character;
  Ystart: 字体的左顶点Y坐标
+
  Ystart: Y coordinate of left-top pixel of character;
  Ascii_Char:Ascii字符
+
  Ascii_Char:Ascii character;
  Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
+
  Font: 5 fonts are available;
  font8:5*8的字体
+
  font8:5*8
  font12:7*12的字体
+
  font12:7*12
  font16:11*16的字体
+
  font16:11*16
  font20:14*20的字体
+
  font20:14*20
  font24:17*24的字体
+
  font24:17*24
  Color_Foreground: 字体颜色
+
  Color_Foreground: color of character;
  Color_Background: 背景颜色
+
  Color_Background: color of background;
 
</pre>
 
</pre>
  
*写英文字符串:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一串英文字符,可以选择Ascii码可视字符字库、字体前景色、字体背景色
+
*Draw String: Set point (Xstart Ystart) as the left-top pixel, draw a string.
 
<pre>
 
<pre>
 
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
 
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
参数:
+
Parameter:
  Xstart: 字符的左顶点X坐标
+
  Xstart: X coordinate of left-top pixel of characters;
  Ystart: 字体的左顶点Y坐标
+
  Ystart: Y coordinate of left-top pixel of characters;
  pString:字符串,字符串是一个指针
+
  pString:Pointer of string
  Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
+
  Font: 5 fonts are available:
  font8:5*8的字体
+
  font8:5*8
  font12:7*12的字体
+
  font12:7*12
  font16:11*16的字体
+
  font16:11*16
  font20:14*20的字体
+
  font20:14*20
  font24:17*24的字体
+
  font24:17*24
  Color_Foreground: 字体颜色
+
  Color_Foreground: color of string
  Color_Background: 背景颜色
+
  Color_Background: color of background
 
</pre>
 
</pre>
  
*写中文字符串:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一串中文字符,可以选择GB2312编码字符字库、字体前景色、字体背景色;
+
*Draw Chinese charactgers: this function is used to draw Chinese fonts based ON GB2312 fonts.
 
<pre>
 
<pre>
 
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
 
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
参数:
+
Parameter:
  Xstart: 字符的左顶点X坐标
+
  Xstart: Coordinate of left-top pixel of characters;
  Ystart: 字体的左顶点Y坐标
+
  Ystart: Coordinate of left-top pixel of characters;
  pString:字符串,字符串是一个指针
+
  pString:Pointer of string
  Font: GB2312编码字符字库,在Fonts文件夹中提供了以下字体:
+
  Font: GB2312 fonts
  font12CN:ascii字符字体11*21,中文字体16*21
+
  font12CN:11*21(ascii),16*21 (Chinese)
  font24CN:ascii字符字体24*41,中文字体32*41
+
  font24CN:24*41(ascii),32*41 (Chinese)
  Color_Foreground: 字体颜色
+
  Color_Foreground: color of string
  Color_Background: 背景颜色
+
  Color_Background: color of background
 
</pre>
 
</pre>
  
*写数字:在图像缓存中,在 (Xstart Ystart) 为左顶点,写一串数字,可以选择Ascii码可视字符字库、字体前景色、字体背景色
+
*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 Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
 
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
参数:
+
Parameter:
  Xstart: 字符的左顶点X坐标
+
  Xstart: X coordinate of left-top pixel;
  Ystart: 字体的左顶点Y坐标
+
  Ystart: Y coordicate of left-to pixel;
  Nummber:显示的数字,这里使用的是32位长的int型保存,可以最大显示到2147483647
+
  Nummber:the numbers displayed. the numbers are saved in int format, the maximum is 2147483647;
  Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
+
  Font: 5 fonts are available:
  font8:5*8的字体
+
  font8:5*8
  font12:7*12的字体
+
  font12:7*12
  font16:11*16的字体
+
  font16:11*16
  font20:14*20的字体
+
  font20:14*20
  font24:17*24的字体
+
  font24:17*24
  Color_Foreground: 字体颜色
+
  Color_Foreground: color of font;
  Color_Background: 背景颜色
+
  Color_Background: color of background;
 
</pre>
 
</pre>
  
*显示时间:在图像缓存中,在 (Xstart Ystart) 为左顶点,显示一段时间,可以选择Ascii码可视字符字库、字体前景色、字体背景色;这里是方便测试局部刷新而写的,因为局部刷新需要的时间为0.3S,整体显示少于1S加上数据的传输,可以做到1S刷新一次
+
*Display time:Display time, (Xstart, Ystart) is the left-top pixel. This function is used for e-Paper which supports partial refresh
 
<pre>
 
<pre>
 
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Background, UWORD Color_Foreground)
 
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Background, UWORD Color_Foreground)
参数:
+
Parameter:
  Xstart: 字符的左顶点X坐标
+
  Xstart: X coordinate of left-top pixel of character;
  Ystart: 字体的左顶点Y坐标
+
  Ystart: Y coordinate of left-top pixel of character;
  pTime:显示的时间,这里定义好了一个时间的结构体,只要把时分秒各位数传给参数;
+
  pTime:Pointer of time displayed;
  Font: Ascii码可视字符字库,在Fonts文件夹中提供了以下字体:
+
  Font: 5 fonts are available;
  font8:5*8的字体
+
  font8:5*8
  font12:7*12的字体
+
  font12:7*12
  font16:11*16的字体
+
  font16:11*16
  font20:14*20的字体
+
  font20:14*20
  font24:17*24的字体
+
  font24:17*24
  Color_Foreground: 字体颜色
+
  Color_Foreground: color of fonts
  Color_Background: 背景颜色
+
  Color_Background: color of background
 
</pre>
 
</pre>
  
*写图片:把一个位图写入图像缓存中
+
*Draw image:send image data of bmp file to buffer
 
<pre>
 
<pre>
 
void Paint_DrawBitMap(const unsigned char* image_buffer)
 
void Paint_DrawBitMap(const unsigned char* image_buffer)
参数:
+
Parameter:
  image_buffer: 图像数据的缓存中的首地址
+
  image_buffer: adrress of image data in buffer
 
</pre>
 
</pre>

Latest revision as of 14:56, 8 June 2020

STM32

Hardware connection

The demo codes we provide are based on STM32F103ZET6, the connection table is also based on STM32F103ZET6, if you want to use other chip, you need to port the codes yourself and change the connection according to actual situation.

Connect to STM32F103ZET
e-Paper STM32
Vcc 3.3V
GND GND
DIN PA7
CLK PA5
CS PA4
DC PA2
RST PA1
BUSY PA3

Softawre settings

The codes are based on HAL library. Download the codes and the project files are saved under the STM32\STM32-F103ZET6\MDK-ARM directory.
E-paper stm32 code1.png

Modify main.c, define the line according to the e-paper type and re-compile project and download.
E-paper stm32 code2.png

Codes description

Bottom hardware interface

We package the bottom for different hardware platforms.
You can check the DEV_Config.c(.h) file which is located in \STM32\STM32-F103ZET6\User\Config

  • Data type:
#define UBYTE   uint8_t
#define UWORD   uint16_t
#define UDOUBLE uint32_t
  • Module initialized and exit:
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.</ br> 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);</ br>

  • 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);

Middle EPD driver

The epd driver are saved in: STM32\STM32-F103ZET6\User\e-Paper
Open .h file, functions are declarated here

  • Initialization: It should be used to initialize e-Paper or wakeup e-Paper from sleep mode.
//2.13inch e-Paper、2.9inch e-Paper
void EPD_xxx_Init(UBYTE Mode); //ode = 0 Initialize full refresh; Mode = 1 Initilize partial refresh 
//Other type
void EPD_xxx_Init(void);

xxx is the type of e-paper

  • 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.

  • Transmit a frame of image and display
//Black/White e-Paper
void EPD_xxx_Display(UBYTE *Image);
Because controllers of2.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_2IN13_V2_DisplayPart(UBYTE *Image);
void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image);
  • 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 the type of e-Paper

Application function

Basic drawing functions are provided here. You can find they in:\STM32\STM32-F103ZET6\User\GUI\GUI_Paint.c(.h)

The fonts are saved in the directory:\STM32\STM32-F103ZET6\User\Fonts

  • 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)
Parameter:
 	image: The buffer of the image, this is a 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)
Parameter:
 	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)
Parameter:
 	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)
Parameter:
 	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)
Parameter:
 	Xpoint: X-axes in the buffer;
 	Ypoint: Y-axes in buffer;
 	Color: color
  • Clear: This function is used to clear the screen to certain color.
void Paint_Clear(UWORD Color)
Parameter:
 	Color: 
  • Clear windows: this function is used to clear a window. It is generally used for time display.
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
Parameter:
 	Xstart: Start coordinate of X-axes of the window;
 	Ystart: Start coordinate of Y-axes of the window;
 	Xend: End coordinate of X-axes of the window;
 	Yend: End coordinate of Y-axes of the window;
 	Color:
  • Draw point: Draw a point on the position (Xpoint, Ypoint)in buffer
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
Parameter:
 	Xpoint: X coordinate of point;
 	Ypoint: Y coordinate of point;
 	Color: color of point;
 	Dot_Pixel: the size of point, there are 8 sizes available;
 	 	 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: style of point. 
 	 	typedef enum {
 	 	   DOT_FILL_AROUND  = 1,		
 	 	   DOT_FILL_RIGHTUP,
 	 	} DOT_STYLE;
  • Draw line: draw a line for (Xstart, Ystart) to (Xend, Yend)
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
Parameter:
 	Xstart: Start coordinate of X-axes of line;
 	Ystart: Start coordinate of Y-axes of line;
 	Xend: End coordinate of X-axes of line;
 	Yend: End coordinate of Y-axes of line
 	Color:
 	Line_width: the width of line, 8 sizes are avalilable;
 	 	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: Style of the line;
 	 	typedef enum {
 	 	 	 LINE_STYLE_SOLID = 0,
 	 	 	 LINE_STYLE_DOTTED,
 	 	} LINE_STYLE;
  • Draw rectangle: Draw a rectangle from (Xstart, Ystart) to (Xend, Yend).
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
Parameter:
 	Xstart: Start coordinate of X-axes of rectangle
 	Ystart: Start coordinate of Y-axes of rectangle
 	Xend: End coordinate of X-end of rectangle
 	Yend: End coordinate of Y-end of rectangle
 	Color: color of rectangle
 	Line_width: The width of edges, 8 sides are available;
 	 	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: set the rectangle full or empty.
 	 	typedef enum {
 	 	 	 DRAW_FILL_EMPTY = 0,
 	 	 	 DRAW_FILL_FULL,
 	 	} DRAW_FILL;
  • Draw circle:Draw a circle, use (X_Center Y_Center) as center;
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 center
 	Y_Center: Y coordinate of center
 	Radius:Radius of circle
 	Color: color of circle
 	Line_width: width of circle, 8 sizes are avalilable
 	 	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: style of circle
 	 	typedef enum {
 	 	 	 DRAW_FILL_EMPTY = 0,
 	 	 	 DRAW_FILL_FULL,
 	 	} DRAW_FILL;
  • Draw character (ASCII): Set(Xstart Ystart) as letf-top point, draw a ASCII character.
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
Parameter:
 	Xstart: X coordinate of left-top pixel of character;
 	Ystart: Y coordinate of left-top pixel of character;
 	Ascii_Char:Ascii character;
 	Font: 5 fonts are available;
 	 	font8:5*8
 	 	font12:7*12
 	 	font16:11*16
 	 	font20:14*20
 	 	font24:17*24
 	Color_Foreground: color of character;
 	Color_Background: color of background;
  • Draw String: Set point (Xstart Ystart) as the left-top pixel, draw a string.
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
Parameter:
 	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 background
  • Draw Chinese charactgers: this function is used to draw Chinese fonts based ON GB2312 fonts.
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
Parameter:
 	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 background
  • Draw number: Draw a string of numbers, (Xstart, Ystart) is the left-top pixel.
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
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: color of font;
 	Color_Background: color of background;
  • Display time:Display time, (Xstart, Ystart) is the left-top pixel. This function is used for e-Paper which supports partial refresh
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Background, UWORD Color_Foreground)
Parameter:
 	Xstart: X coordinate of left-top pixel of character;
 	Ystart: Y coordinate of left-top pixel of character;
 	pTime:Pointer of time displayed;
 	Font: 5 fonts are available;
 	 	font8:5*8
 	 	font12:7*12
 	 	font16:11*16
 	 	font20:14*20
 	 	font24:17*24
 	Color_Foreground: color of fonts
 	Color_Background: color of background
  • Draw image:send image data of bmp file to buffer
void Paint_DrawBitMap(const unsigned char* image_buffer)
Parameter:
 	image_buffer: adrress of image data in buffer