add 1.02EPD + 7.5(a,b,c) V2 + 2.7(4 gray)

This commit is contained in:
hnwangkg-ezio 2019-10-11 11:56:28 +08:00
commit 702def06bc
416 changed files with 53398 additions and 7019 deletions

View file

@ -38,11 +38,12 @@ void DEV_SPI_WriteByte(UBYTE value)
HAL_SPI_Transmit(&hspi1, &value, 1, 1000);
}
void DEV_Module_Init(void)
int DEV_Module_Init(void)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_Digital_Write(EPD_RST_PIN, 1);
return 0;
}
void DEV_Module_Exit(void)

View file

@ -81,6 +81,6 @@
void DEV_SPI_WriteByte(UBYTE value);
void DEV_Module_Init(void);
int DEV_Module_Init(void);
void DEV_Module_Exit(void);
#endif

View file

@ -0,0 +1,173 @@
/*****************************************************************************
* | File : EPD_1IN02_test.c
* | Author : Waveshare team
* | Function : 1.02inch e-paper test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2019-09-29
* | Info :
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_Test.h"
#include "EPD_1in02d.h"
#include <string.h>
int EPD_1in02d_test(void)
{
printf("EPD_1IN02_test Demo\r\n");
if(DEV_Module_Init()!=0){
return -1;
}
printf("e-Paper Init and Clear...\r\n");
EPD_1IN02_Init();
EPD_1IN02_Clear();
DEV_Delay_ms(500);
//Create a new image cache
UBYTE *BlackImage,*old_Image;
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
UWORD Imagesize = ((EPD_1IN02_WIDTH % 8 == 0)? (EPD_1IN02_WIDTH / 8 ): (EPD_1IN02_WIDTH / 8 + 1)) * EPD_1IN02_HEIGHT;
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
if((old_Image = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory2...\r\n");
return -1;
}
printf("Paint_NewImage\r\n");
Paint_NewImage(BlackImage, EPD_1IN02_WIDTH, EPD_1IN02_HEIGHT, 270, WHITE);
Paint_NewImage(old_Image, EPD_1IN02_WIDTH, EPD_1IN02_HEIGHT, 270, WHITE);
Paint_SelectImage(old_Image);
Paint_Clear(WHITE);
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
#if 0 //show image for array
printf("show image for array\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
Paint_DrawBitMap(gImage_1in02d);
EPD_1IN02_Display(BlackImage);
DEV_Delay_ms(2000);
#endif
#if 1
// Drawing on the image
//1.Select Image
printf("SelectImage:BlackImage\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
// 2.Drawing on the image
printf("Drawing:BlackImage\r\n");
Paint_DrawPoint(10, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(10, 15, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(10, 25, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawLine(30, 10, 80, 70, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawLine(80, 10, 30, 70, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawRectangle(30, 10, 90, 70, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawCircle(60, 40, 25, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
printf("EPD_1IN02_Display\r\n");
EPD_1IN02_Display(BlackImage);
DEV_Delay_ms(2000);
Paint_Clear(WHITE);
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
printf("EPD_1IN02_Display\r\n");
EPD_1IN02_Display(BlackImage);
DEV_Delay_ms(2000);
Paint_Clear(WHITE);
Paint_DrawString_CN(0, 10,"ÄãºÃabcÊ÷Ý®ÅÉ", &Font12CN, BLACK, WHITE);
Paint_DrawString_CN(0, 30,"΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
printf("EPD_1IN02_Display\r\n");
EPD_1IN02_Display(BlackImage);
DEV_Delay_ms(2000);
Paint_Clear(WHITE);
EPD_1IN02_Display(BlackImage);
DEV_Delay_ms(2000);
#endif
#if 1 //Partial refresh, example shows time
printf("Partial refresh\r\n");
Paint_Clear(WHITE);
EPD_1IN02_Display(BlackImage);
EPD_1IN02_Part_Init();
Paint_SelectImage(BlackImage);
PAINT_TIME sPaint_time;
sPaint_time.Hour = 12;
sPaint_time.Min = 34;
sPaint_time.Sec = 56;
UBYTE num = 20;
for (;;) {
sPaint_time.Sec = sPaint_time.Sec + 1;
if (sPaint_time.Sec == 60) {
sPaint_time.Min = sPaint_time.Min + 1;
sPaint_time.Sec = 0;
if (sPaint_time.Min == 60) {
sPaint_time.Hour = sPaint_time.Hour + 1;
sPaint_time.Min = 0;
if (sPaint_time.Hour == 24) {
sPaint_time.Hour = 0;
sPaint_time.Min = 0;
sPaint_time.Sec = 0;
}
}
}
Paint_ClearWindows(20, 20, 20 + Font20.Width * 7, 20 + Font20.Height, WHITE);
Paint_DrawTime(20, 20, &sPaint_time, &Font20, WHITE, BLACK);
num = num - 1;
if(num == 0) {
break;
}
EPD_1IN02_DisplayPartial(old_Image, BlackImage);
memcpy(old_Image, BlackImage, Imagesize);
// DEV_Delay_ms(100);//Analog clock 1s
}
#endif
printf("Clear...\r\n");
EPD_1IN02_Init();
EPD_1IN02_Clear();
printf("Goto Sleep...\r\n");
EPD_1IN02_Sleep();
free(BlackImage);
BlackImage = NULL;
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();
return 0;
}

View file

@ -35,10 +35,6 @@ int EPD_1in54_V2_test(void)
printf("EPD_1in54_V2_test Demo\r\n");
DEV_Module_Init();
for(;;){
// EPD_1IN54_V2_Init();
// EPD_1IN54_V2_Clear();
printf("e-Paper Init and Clear...\r\n");
EPD_1IN54_V2_Init();
EPD_1IN54_V2_Clear();
@ -146,7 +142,7 @@ for(;;){
EPD_1IN54_V2_Sleep();
free(BlackImage);
BlackImage = NULL;
}
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();

View file

@ -90,6 +90,49 @@ int EPD_2in7_test(void)
EPD_2IN7_Display(BlackImage);
DEV_Delay_ms(2000);
#endif
free(BlackImage);
#if 1 // show image for array
printf("show Gray------------------------\r\n");
Imagesize = ((EPD_2IN7_WIDTH % 4 == 0)? (EPD_2IN7_WIDTH / 4 ): (EPD_2IN7_WIDTH / 4 + 1)) * EPD_2IN7_HEIGHT;
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
printf("4 grayscale display\r\n");
EPD_2IN7_Init_4Gray();
Paint_NewImage(BlackImage, EPD_2IN7_WIDTH, EPD_2IN7_HEIGHT, 270, WHITE);
Paint_SetScale(4);
Paint_Clear(WHITE);
Paint_DrawPoint(10, 80, GRAY4, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(10, 90, GRAY4, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(10, 100, GRAY4, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawLine(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawLine(70, 70, 20, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawRectangle(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawRectangle(80, 70, 130, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawCircle(45, 95, 20, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawCircle(105, 95, 20, GRAY2, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawLine(85, 95, 125, 95, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawLine(105, 75, 105, 115, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawString_EN(10, 0, "waveshare", &Font16, GRAY4, GRAY1);
Paint_DrawString_EN(10, 20, "hello world", &Font12, GRAY3, GRAY1);
Paint_DrawNum(10, 33, 123456789, &Font12, GRAY4, GRAY2);
Paint_DrawNum(10, 50, 987654321, &Font16, GRAY1, GRAY4);
Paint_DrawString_CN(150, 0,"ÄãºÃabc", &Font12CN, GRAY4, GRAY1);
Paint_DrawString_CN(150, 20,"ÄãºÃabc", &Font12CN, GRAY3, GRAY2);
Paint_DrawString_CN(150, 40,"ÄãºÃabc", &Font12CN, GRAY2, GRAY3);
Paint_DrawString_CN(150, 60,"ÄãºÃabc", &Font12CN, GRAY1, GRAY4);
Paint_DrawString_CN(10, 130, "΢ѩµç×Ó", &Font24CN, GRAY1, GRAY4);
EPD_2IN7_4GrayDisplay(BlackImage);
DEV_Delay_ms(3000);
EPD_2IN7_4GrayDisplay(gImage_2in7_4Gray);
DEV_Delay_ms(3000);
EPD_2IN7_Clear();
#endif
printf("Clear...\r\n");
EPD_2IN7_Clear();

View file

@ -0,0 +1,115 @@
/*****************************************************************************
* | File : EPD_7in5_test.c
* | Author : Waveshare team
* | Function : 7.5inch e-paper test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2019-06-13
* | Info :
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_Test.h"
#include "EPD_7in5_V2.h"
int EPD_7in5_V2_test(void)
{
printf("EPD_7IN5_V2_test Demo\r\n");
if(DEV_Module_Init()!=0){
return -1;
}
printf("e-Paper Init and Clear...\r\n");
EPD_7IN5_V2_Init();
EPD_7IN5_V2_Clear();
DEV_Delay_ms(500);
//Create a new image cache
UBYTE *BlackImage;
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
UWORD Imagesize = ((EPD_7IN5_V2_WIDTH % 8 == 0)? (EPD_7IN5_V2_WIDTH / 8 ): (EPD_7IN5_V2_WIDTH / 8 + 1)) * EPD_7IN5_V2_HEIGHT;
if((BlackImage = (UBYTE *)malloc(Imagesize/2)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
printf("Paint_NewImage\r\n");
Paint_NewImage(BlackImage, EPD_7IN5_V2_WIDTH, EPD_7IN5_V2_HEIGHT/2, 0, WHITE);
#if 1 // show image for array
printf("show image for array\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
Paint_DrawBitMap(gImage_7in5_V2);
EPD_7IN5_V2_WritePicture(BlackImage, 0);
//The entire image size is EPD_7IN5_V2_WIDTH*EPD_7IN5_V2_HEIGHT/8
//Since the memory problem is transmitted halfway, now the other half is transmitted, so the offset address is required.
Paint_DrawBitMap(gImage_7in5_V2 + EPD_7IN5_V2_WIDTH*EPD_7IN5_V2_HEIGHT/8/2);
EPD_7IN5_V2_WritePicture(BlackImage, 1);
DEV_Delay_ms(2000);
#endif
#if 1 // Drawing on the image
//1.Select Image
printf("SelectImage:BlackImage\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
// 2.Drawing on the image
printf("Drawing:BlackImage\r\n");
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
Paint_DrawString_CN(130, 0, " ÄãºÃabc", &Font12CN, BLACK, WHITE);
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
EPD_7IN5_V2_WritePicture(BlackImage, 0);
Paint_Clear(WHITE);
EPD_7IN5_V2_WritePicture(BlackImage, 1);
printf("EPD_Display\r\n");
DEV_Delay_ms(2000);
#endif
printf("Clear...\r\n");
EPD_7IN5_V2_Clear();
printf("Goto Sleep...\r\n");
EPD_7IN5_V2_Sleep();
free(BlackImage);
BlackImage = NULL;
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();
return 0;
}

View file

@ -0,0 +1,116 @@
/*****************************************************************************
* | File : EPD_7in5bc_test.c
* | Author : Waveshare team
* | Function : 5.83inch B&C e-paper test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2019-06-13
* | Info :
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_Test.h"
#include "EPD_7in5b_V2.h"
int EPD_7in5b_V2_test(void)
{
printf("EPD_7IN5BC_test Demo\r\n");
DEV_Module_Init();
printf("e-Paper Init and Clear...\r\n");
EPD_7IN5B_V2_Init();
EPD_7IN5B_V2_Clear();
DEV_Delay_ms(500);
//Create a new image cache named IMAGE_BW and fill it with white
UBYTE *Image;
UWORD Imagesize = ((EPD_7IN5B_V2_WIDTH % 8 == 0)? (EPD_7IN5B_V2_WIDTH / 8 ): (EPD_7IN5B_V2_WIDTH / 8 + 1)) * EPD_7IN5B_V2_HEIGHT;
if((Image = (UBYTE *)malloc(Imagesize / 2)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
printf("NewImage:Image\r\n");
Paint_NewImage(Image, EPD_7IN5B_V2_WIDTH, EPD_7IN5B_V2_HEIGHT / 2, 0, WHITE);
//Select Image
Paint_SelectImage(Image);
Paint_Clear(WHITE);
#if 1 // show image for array
printf("show image for array\r\n");
//The entire image size is Imagesize
//Since the memory problem is transmitted halfway, now the other half is transmitted, so the offset address is required.
EPD_7IN5B_V2_WritePicture(gImage_7in5_V2_b, 0);
EPD_7IN5B_V2_WritePicture(gImage_7in5_V2_b + Imagesize/2, 1);
EPD_7IN5B_V2_WritePicture(gImage_7in5_V2_ry, 2);
EPD_7IN5B_V2_WritePicture(gImage_7in5_V2_ry + Imagesize/2, 3);
DEV_Delay_ms(2000);
#endif
#if 1 // Drawing on the image
/*Horizontal screen*/
//1.Draw black image
Paint_SelectImage(Image);
Paint_Clear(WHITE);
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
EPD_7IN5B_V2_WritePicture(Image, 0);
Paint_Clear(WHITE);
EPD_7IN5B_V2_WritePicture(Image, 1);
//2.Draw red image
Paint_Clear(WHITE);
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
EPD_7IN5B_V2_WritePicture(Image, 2);
Paint_Clear(WHITE);
EPD_7IN5B_V2_WritePicture(Image, 3);
printf("EPD_Display\r\n");
DEV_Delay_ms(2000);
#endif
printf("Clear...\r\n");
EPD_7IN5B_V2_Clear();
printf("Goto Sleep...\r\n");
EPD_7IN5B_V2_Sleep();
free(Image);
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();
return 0;
}

View file

@ -36,6 +36,8 @@
#include "Debug.h"
#include <stdlib.h> // malloc() free()
int EPD_1in02d_test(void);
int EPD_1in54_test(void);
int EPD_1in54_V2_test(void);
int EPD_1in54b_test(void);
@ -60,5 +62,7 @@ int EPD_5in83_test(void);
int EPD_5in83bc_test(void);
int EPD_7in5_test(void);
int EPD_7in5_V2_test(void);
int EPD_7in5bc_test(void);
int EPD_7in5b_V2_test(void);
#endif

File diff suppressed because it is too large Load diff

View file

@ -31,6 +31,7 @@
#ifndef _IMAGEDATA_H_
#define _IMAGEDATA_H_
extern const unsigned char gImage_1in02d[];
extern const unsigned char gImage_1in54[];
extern const unsigned char gImage_1in54b_Black[];
@ -41,6 +42,8 @@ extern const unsigned char gImage_1in54c_Yellow[];
extern const unsigned char gImage_2in7[];
extern const unsigned char gImage_2in7b_Black[5808];
extern const unsigned char gImage_2in7b_Red[5808];
extern const unsigned char gImage_2in7_4Gray[];
extern const unsigned char gImage_2in9[];
extern const unsigned char gImage_2in9bc_b[];
@ -62,8 +65,11 @@ extern const unsigned char gImage_5in83bc_b[];
extern const unsigned char gImage_5in83bc_ry[];
extern const unsigned char gImage_7in5[];
extern const unsigned char gImage_7in5_V2[];
extern const unsigned char gImage_7in5bc_b[];
extern const unsigned char gImage_7in5bc_ry[];
extern const unsigned char gImage_7in5_V2_b[];
extern const unsigned char gImage_7in5_V2_ry[];
#endif
/* FILE END */

View file

@ -88,6 +88,8 @@ void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD
Paint.WidthMemory = Width;
Paint.HeightMemory = Height;
Paint.Color = Color;
Paint.Scale = 2;
Paint.WidthByte = (Width % 8 == 0)? (Width / 8 ): (Width / 8 + 1);
Paint.HeightByte = Height;
// printf("WidthByte = %d, HeightByte = %d\r\n", Paint.WidthByte, Paint.HeightByte);
@ -130,6 +132,19 @@ void Paint_SetRotate(UWORD Rotate)
}
}
void Paint_SetScale(UBYTE scale)
{
if(scale == 2){
Paint.Scale = scale;
Paint.WidthByte = (Paint.WidthMemory % 8 == 0)? (Paint.WidthMemory / 8 ): (Paint.WidthMemory / 8 + 1);
}else if(scale == 4){
Paint.Scale = scale;
Paint.WidthByte = (Paint.WidthMemory % 4 == 0)? (Paint.WidthMemory / 4 ): (Paint.WidthMemory / 4 + 1);
}else{
Debug("Set Scale Input parameter error\r\n");
Debug("Scale Only support: 2 4 \r\n");
}
}
/******************************************************************************
function: Select Image mirror
parameter:
@ -205,12 +220,21 @@ void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
return;
}
UDOUBLE Addr = X / 8 + Y * Paint.WidthByte;
UBYTE Rdata = Paint.Image[Addr];
if(Color == BLACK)
Paint.Image[Addr] = Rdata & ~(0x80 >> (X % 8));
else
Paint.Image[Addr] = Rdata | (0x80 >> (X % 8));
if(Paint.Scale == 2){
UDOUBLE Addr = X / 8 + Y * Paint.WidthByte;
UBYTE Rdata = Paint.Image[Addr];
if(Color == BLACK)
Paint.Image[Addr] = Rdata & ~(0x80 >> (X % 8));
else
Paint.Image[Addr] = Rdata | (0x80 >> (X % 8));
}else if(Paint.Scale == 4){
UDOUBLE Addr = X / 4 + Y * Paint.WidthByte;
Color = Color % 4;//Guaranteed color scale is 4 --- 0~3
UBYTE Rdata = Paint.Image[Addr];
Rdata = Rdata & (~(0xC0 >> ((X % 4)*2)));
Paint.Image[Addr] = Rdata | ((Color << 6) >> ((X % 4)*2));
}
}
/******************************************************************************
@ -261,6 +285,8 @@ void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color,
{
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
Debug("Paint_DrawPoint Input exceeds the normal display range\r\n");
printf("Xpoint = %d , Paint.Width = %d \r\n ",Xpoint,Paint.Width);
printf("Ypoint = %d , Paint.Height = %d \r\n ",Ypoint,Paint.Height);
return;
}
@ -723,3 +749,92 @@ void Paint_DrawBitMap(const unsigned char* image_buffer)
}
}
}
///******************************************************************************
//function: SDisplay half of monochrome bitmap
//parameter:
// Region : 1 Upper half
// 2 Lower half
//info:
//******************************************************************************/
//void Paint_DrawBitMap_Half(const unsigned char* image_buffer, UBYTE Region)
//{
// UWORD x, y;
// UDOUBLE Addr = 0;
//
// if(Region == 1){
// for (y = 0; y < Paint.HeightByte; y++) {
// for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
// Addr = x + y * Paint.WidthByte;
// Paint.Image[Addr] = (unsigned char)image_buffer[Addr];
// }
// }
// }else{
// for (y = 0; y < Paint.HeightByte; y++) {
// for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
// Addr = x + y * Paint.WidthByte ;
// Paint.Image[Addr] = \
// (unsigned char)image_buffer[Addr+ (Paint.HeightByte)*Paint.WidthByte];
// }
// }
// }
//}
///******************************************************************************
//function: SDisplay half of monochrome bitmap
//parameter:
// Region : 1 Upper half
// 2 Lower half
//info:
//******************************************************************************/
//void Paint_DrawBitMap_OneQuarter(const unsigned char* image_buffer, UBYTE Region)
//{
// UWORD x, y;
// UDOUBLE Addr = 0;
//
// if(Region == 1){
// for (y = 0; y < Paint.HeightByte; y++) {
// for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
// Addr = x + y * Paint.WidthByte;
// Paint.Image[Addr] = (unsigned char)image_buffer[Addr];
// }
// }
// }else if(Region == 2){
// for (y = 0; y < Paint.HeightByte; y++) {
// for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
// Addr = x + y * Paint.WidthByte ;
// Paint.Image[Addr] = \
// (unsigned char)image_buffer[Addr+ (Paint.HeightByte)*Paint.WidthByte];
// }
// }
// }else if(Region == 3){
// for (y = 0; y < Paint.HeightByte; y++) {
// for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
// Addr = x + y * Paint.WidthByte ;
// Paint.Image[Addr] = \
// (unsigned char)image_buffer[Addr+ (Paint.HeightByte)*Paint.WidthByte*2];
// }
// }
// }else if(Region == 4){
// for (y = 0; y < Paint.HeightByte; y++) {
// for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
// Addr = x + y * Paint.WidthByte ;
// Paint.Image[Addr] = \
// (unsigned char)image_buffer[Addr+ (Paint.HeightByte)*Paint.WidthByte*3];
// }
// }
// }
//}
void Paint_DrawBitMap_Block(const unsigned char* image_buffer, UBYTE Region)
{
UWORD x, y;
UDOUBLE Addr = 0;
for (y = 0; y < Paint.HeightByte; y++) {
for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
Addr = x + y * Paint.WidthByte ;
Paint.Image[Addr] = \
(unsigned char)image_buffer[Addr+ (Paint.HeightByte)*Paint.WidthByte*(Region - 1)];
}
}
}

View file

@ -82,6 +82,7 @@ typedef struct {
UWORD Mirror;
UWORD WidthByte;
UWORD HeightByte;
UWORD Scale;
} PAINT;
extern PAINT Paint;
@ -174,6 +175,7 @@ void Paint_SelectImage(UBYTE *image);
void Paint_SetRotate(UWORD Rotate);
void Paint_SetMirroring(UBYTE mirror);
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color);
void Paint_SetScale(UBYTE scale);
void Paint_Clear(UWORD Color);
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color);
@ -193,8 +195,10 @@ void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font,
//pic
void Paint_DrawBitMap(const unsigned char* image_buffer);
//void Paint_DrawBitMap_Half(const unsigned char* image_buffer, UBYTE Region);
//void Paint_DrawBitMap_OneQuarter(const unsigned char* image_buffer, UBYTE Region);
//void Paint_DrawBitMap_OneEighth(const unsigned char* image_buffer, UBYTE Region);
void Paint_DrawBitMap_Block(const unsigned char* image_buffer, UBYTE Region);
#endif

View file

@ -0,0 +1,391 @@
/*****************************************************************************
* | File : EPD_1IN02_1in02.c
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V1.0
* | Date : 2019-09-27
* | Info :
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_1in02d.h"
/**
* full screen update LUT
**/
const unsigned char lut_w1[] =
{
0x60 ,0x5A ,0x5A ,0x00 ,0x00 ,0x01 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
};
const unsigned char lut_b1[] =
{
0x90 ,0x5A ,0x5A ,0x00 ,0x00 ,0x01 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
};
/**
* partial screen update LUT
**/
const unsigned char lut_w[] =
{
0x60 ,0x01 ,0x01 ,0x00 ,0x00 ,0x01 ,
0x80 ,0x1f ,0x00 ,0x00 ,0x00 ,0x01 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
};
const unsigned char lut_b[] =
{
0x90 ,0x01 ,0x01 ,0x00 ,0x00 ,0x01 ,
0x40 ,0x1f ,0x00 ,0x00 ,0x00 ,0x01 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
};
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_1IN02_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);// Module reset
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************
function : send command
parameter:
command : Command register
******************************************************************************/
static void EPD_1IN02_SendCommand(UBYTE command)
{
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_Digital_Write(EPD_DC_PIN, 0);// command write
DEV_SPI_WriteByte(command);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : send data
parameter:
Data : Write data
******************************************************************************/
static void EPD_1IN02_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_Digital_Write(EPD_DC_PIN, 1); // command write
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : LUT download
******************************************************************************/
void EPD_1IN02_SetFulltReg(void)
{
unsigned int count;
EPD_1IN02_SendCommand(0x23);
for(count=0;count<42;count++)
{EPD_1IN02_SendData(lut_w1[count]);}
EPD_1IN02_SendCommand(0x24);
for(count=0;count<42;count++)
{EPD_1IN02_SendData(lut_b1[count]);}
}
/******************************************************************************
function : LUT download
******************************************************************************/
void EPD_1IN02_SetPartReg(void)
{
unsigned int count;
EPD_1IN02_SendCommand(0x23);
for(count=0;count<42;count++){
EPD_1IN02_SendData(lut_w[count]);
}
EPD_1IN02_SendCommand(0x24);
for(count=0;count<42;count++){
EPD_1IN02_SendData(lut_b[count]);
}
}
/******************************************************************************
function : Wait until the busy_pin goes LOW
******************************************************************************/
void EPD_1IN02_WaitUntilIdle(void)
{
unsigned char busy;
do
{
EPD_1IN02_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}
while(busy);
DEV_Delay_ms(800);
}
/******************************************************************************
function : Turn On Display
******************************************************************************/
void EPD_1IN02_TurnOnDisplay(void)
{
// EPD_1IN02_SendCommand(0x04); //power on
// EPD_1IN02_WaitUntilIdle();
EPD_1IN02_SendCommand(0x12); //Start refreshing the screen
DEV_Delay_ms(10);
EPD_1IN02_WaitUntilIdle();
// EPD_1IN02_SendCommand(0x02);
// EPD_1IN02_WaitUntilIdle(); //power off
}
/******************************************************************************
function :Initialize the e-Paper register
******************************************************************************/
UBYTE EPD_1IN02_Init(void)
{
EPD_1IN02_Reset();
EPD_1IN02_SendCommand(0xD2);
EPD_1IN02_SendData(0x3F);
EPD_1IN02_SendCommand(0x00);
EPD_1IN02_SendData (0x6F); //from outside
EPD_1IN02_SendCommand(0x01); //power setting
EPD_1IN02_SendData (0x03);
EPD_1IN02_SendData (0x00);
EPD_1IN02_SendData (0x2b);
EPD_1IN02_SendData (0x2b);
EPD_1IN02_SendCommand(0x06); //Configuring the charge pump
EPD_1IN02_SendData(0x3f);
EPD_1IN02_SendCommand(0x2A); //Setting XON and the options of LUT
EPD_1IN02_SendData(0x00);
EPD_1IN02_SendData(0x00);
EPD_1IN02_SendCommand(0x30); //Set the clock frequency
EPD_1IN02_SendData(0x17); //50Hz
EPD_1IN02_SendCommand(0x50); //Set VCOM and data output interval
EPD_1IN02_SendData(0x57);
EPD_1IN02_SendCommand(0x60); //Set The non-overlapping period of Gate and Source.
EPD_1IN02_SendData(0x22);
EPD_1IN02_SendCommand(0x61); //resolution setting
EPD_1IN02_SendData (0x50); //source 128
EPD_1IN02_SendData (0x80);
EPD_1IN02_SendCommand(0x82); //sets VCOM_DC value
EPD_1IN02_SendData(0x12); //-1v
EPD_1IN02_SendCommand(0xe3);//Set POWER SAVING
EPD_1IN02_SendData(0x33);
EPD_1IN02_SetFulltReg();
EPD_1IN02_SendCommand(0x04); //power on
EPD_1IN02_WaitUntilIdle();
return 0;
}
/******************************************************************************
function :Partial refresh initialization e-paper
******************************************************************************/
void EPD_1IN02_Part_Init(void)
{
EPD_1IN02_Reset();
EPD_1IN02_SendCommand(0xD2);
EPD_1IN02_SendData(0x3F);
EPD_1IN02_SendCommand(0x00);
EPD_1IN02_SendData (0x6F); //from outside
EPD_1IN02_SendCommand(0x01); //power setting
EPD_1IN02_SendData (0x03);
EPD_1IN02_SendData (0x00);
EPD_1IN02_SendData (0x2b);
EPD_1IN02_SendData (0x2b);
EPD_1IN02_SendCommand(0x06); //Configuring the charge pump
EPD_1IN02_SendData(0x3f);
EPD_1IN02_SendCommand(0x2A); //Setting XON and the options of LUT
EPD_1IN02_SendData(0x00);
EPD_1IN02_SendData(0x00);
EPD_1IN02_SendCommand(0x30); //Set the clock frequency
EPD_1IN02_SendData(0x17);
EPD_1IN02_SendCommand(0x50); //Set VCOM and data output interval
EPD_1IN02_SendData(0xf2);
EPD_1IN02_SendCommand(0x60); //Set The non-overlapping period of Gate and Source.
EPD_1IN02_SendData(0x22);
EPD_1IN02_SendCommand(0x82); //Set VCOM_DC value
EPD_1IN02_SendData(0x12);//-1v
EPD_1IN02_SendCommand(0xe3);//Set POWER SAVING
EPD_1IN02_SendData(0x33);
EPD_1IN02_SetPartReg();
EPD_1IN02_SendCommand(0x04);//Set POWER SAVING
EPD_1IN02_WaitUntilIdle();
}
/******************************************************************************
function : Clear screen
******************************************************************************/
void EPD_1IN02_Clear(void)
{
unsigned int i;
EPD_1IN02_SendCommand(0x10);
for(i=0;i<1280;i++){
EPD_1IN02_SendData(0X00);
}
EPD_1IN02_SendCommand(0x13); //Transfer new data
for(i=0;i<1280;i++){
EPD_1IN02_SendData(0xff);
}
EPD_1IN02_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
Image :Displayed data
******************************************************************************/
void EPD_1IN02_Display(UBYTE *Image)
{
UWORD Width;
Width = (EPD_1IN02_WIDTH % 8 == 0)? (EPD_1IN02_WIDTH / 8 ): (EPD_1IN02_WIDTH / 8 + 1);
//EPD_1IN02_Init();
EPD_1IN02_SendCommand(0x10);
for (UWORD j = 0; j < EPD_1IN02_HEIGHT; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_1IN02_SendData(0xff);
}
}
EPD_1IN02_SendCommand(0x13);
for (UWORD j = 0; j < EPD_1IN02_HEIGHT; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_1IN02_SendData(Image[i + j * Width]);
}
}
EPD_1IN02_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
old_Image: Last displayed data
Image2 : New data
******************************************************************************/
void EPD_1IN02_DisplayPartial(UBYTE *old_Image, UBYTE *Image)
{
/* Set partial Windows */
EPD_1IN02_SendCommand(0x91); //This command makes the display enter partial mode
EPD_1IN02_SendCommand(0x90); //resolution setting
EPD_1IN02_SendData(0); //x-start
EPD_1IN02_SendData(79); //x-end
EPD_1IN02_SendData(0);
EPD_1IN02_SendData(127); //y-end
EPD_1IN02_SendData(0x00);
UWORD Width;
Width = (EPD_1IN02_WIDTH % 8 == 0)? (EPD_1IN02_WIDTH / 8 ): (EPD_1IN02_WIDTH / 8 + 1);
/* send data */
EPD_1IN02_SendCommand(0x10);
for (UWORD j = 0; j < EPD_1IN02_HEIGHT; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_1IN02_SendData(old_Image[i + j * Width]);
}
}
EPD_1IN02_SendCommand(0x13);
for (UWORD j = 0; j < EPD_1IN02_HEIGHT; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_1IN02_SendData(Image[i + j * Width]);
}
}
/* Set partial refresh */
EPD_1IN02_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
******************************************************************************/
void EPD_1IN02_Sleep(void)
{
EPD_1IN02_SendCommand(0X50);
EPD_1IN02_SendData(0xf7);
EPD_1IN02_SendCommand(0X02); //power off
EPD_1IN02_WaitUntilIdle();
EPD_1IN02_SendCommand(0X07); //deep sleep
EPD_1IN02_SendData(0xA5);
DEV_Delay_ms(200);
printf("Turn off the power!!! \r\n");
DEV_Digital_Write(EPD_RST_PIN, 0);// Module reset
}

View file

@ -0,0 +1,47 @@
/*****************************************************************************
* | File : EPD_1IN02_1in02.h
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V1.0
* | Date : 2019-09-27
* | Info :
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef _EPD_1IN02_H_
#define _EPD_1IN02_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_1IN02_WIDTH 80
#define EPD_1IN02_HEIGHT 128
UBYTE EPD_1IN02_Init(void);
void EPD_1IN02_Clear(void);
void EPD_1IN02_Display(UBYTE *Image);
void EPD_1IN02_DisplayPartial(UBYTE *Image1, UBYTE *Image2);
void EPD_1IN02_Sleep(void);
void EPD_1IN02_Part_Init(void);
#endif

View file

@ -4,10 +4,20 @@
* | Function : 2.7inch e-paper
* | Info :
*----------------
* | This version: V3.0
* | Date : 2019-06-12
* | This version: V3.1
* | Date : 2019-10-10
* | Info :
* -----------------------------------------------------------------------------
* V3.1(2019-10-10):
* 1. Add 4 grayscale display
* Add EPD_2in7_gray_lut_vcom[]
* Add EPD_2in7_gray_lut_ww[]
* Add EPD_2in7_gray_lut_bw[]
* Add EPD_2in7_gray_lut_wb[]
* Add EPD_2in7_gray_lut_bb[]
* Add EPD_2in7_gray_SetLut()
* Add EPD_2IN7_Init_4Gray()
* Add EPD_2IN7_4GrayDisplay()
* V3.0(2019-06-12):
* 1.Change:
* lut_vcom_dc[] => EPD_2in7_lut_vcom_dc[]
@ -82,6 +92,107 @@
#include "EPD_2in7.h"
#include "Debug.h"
static const unsigned char EPD_2in7_lut_vcom_dc[] = {
0x00 ,0x00,
0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0x02,
0x60 ,0x28 ,0x28 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x00 ,0x12 ,0x12 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
};
static const unsigned char EPD_2in7_lut_ww[] = {
0x40 ,0x08 ,0x00 ,0x00 ,0x00 ,0x02,
0x90 ,0x28 ,0x28 ,0x00 ,0x00 ,0x01,
0x40 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0xA0 ,0x12 ,0x12 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
static const unsigned char EPD_2in7_lut_bw[] = {
0x40 ,0x08 ,0x00 ,0x00 ,0x00 ,0x02,
0x90 ,0x28 ,0x28 ,0x00 ,0x00 ,0x01,
0x40 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0xA0 ,0x12 ,0x12 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
static const unsigned char EPD_2in7_lut_bb[] = {
0x80 ,0x08 ,0x00 ,0x00 ,0x00 ,0x02,
0x90 ,0x28 ,0x28 ,0x00 ,0x00 ,0x01,
0x80 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x50 ,0x12 ,0x12 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
static const unsigned char EPD_2in7_lut_wb[] = {
0x80 ,0x08 ,0x00 ,0x00 ,0x00 ,0x02,
0x90 ,0x28 ,0x28 ,0x00 ,0x00 ,0x01,
0x80 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x50 ,0x12 ,0x12 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//////////////////////////////////////full screen update LUT////////////////////////////////////////////
//0~3 gray
static const unsigned char EPD_2in7_gray_lut_vcom[] =
{
0x00 ,0x00,
0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R21
static const unsigned char EPD_2in7_gray_lut_ww[] ={
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x10 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0xA0 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R22H r
static const unsigned char EPD_2in7_gray_lut_bw[] ={
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x99 ,0x0C ,0x01 ,0x03 ,0x04 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R23H w
static const unsigned char EPD_2in7_gray_lut_wb[] ={
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x99 ,0x0B ,0x04 ,0x04 ,0x01 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R24H b
static const unsigned char EPD_2in7_gray_lut_bb[] ={
0x80 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x20 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x50 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
/******************************************************************************
function : Software reset
parameter:
@ -139,6 +250,68 @@ static void EPD_2in7_ReadBusy(void)
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : set the look-up tables
parameter:
******************************************************************************/
static void EPD_2in7_SetLut(void)
{
unsigned int count;
EPD_2in7_SendCommand(0x20); //vcom
for(count = 0; count < 44; count++) {
EPD_2in7_SendData(EPD_2in7_lut_vcom_dc[count]);
}
EPD_2in7_SendCommand(0x21); //ww --
for(count = 0; count < 42; count++) {
EPD_2in7_SendData(EPD_2in7_lut_ww[count]);
}
EPD_2in7_SendCommand(0x22); //bw r
for(count = 0; count < 42; count++) {
EPD_2in7_SendData(EPD_2in7_lut_bw[count]);
}
EPD_2in7_SendCommand(0x23); //wb w
for(count = 0; count < 42; count++) {
EPD_2in7_SendData(EPD_2in7_lut_bb[count]);
}
EPD_2in7_SendCommand(0x24); //bb b
for(count = 0; count < 42; count++) {
EPD_2in7_SendData(EPD_2in7_lut_wb[count]);
}
}
void EPD_2in7_gray_SetLut(void)
{
unsigned int count;
EPD_2in7_SendCommand(0x20); //vcom
for(count=0;count<44;count++)
{EPD_2in7_SendData(EPD_2in7_gray_lut_vcom[count]);}
EPD_2in7_SendCommand(0x21); //red not use
for(count=0;count<42;count++)
{EPD_2in7_SendData(EPD_2in7_gray_lut_ww[count]);}
EPD_2in7_SendCommand(0x22); //bw r
for(count=0;count<42;count++)
{EPD_2in7_SendData(EPD_2in7_gray_lut_bw[count]);}
EPD_2in7_SendCommand(0x23); //wb w
for(count=0;count<42;count++)
{EPD_2in7_SendData(EPD_2in7_gray_lut_wb[count]);}
EPD_2in7_SendCommand(0x24); //bb b
for(count=0;count<42;count++)
{EPD_2in7_SendData(EPD_2in7_gray_lut_bb[count]);}
EPD_2in7_SendCommand(0x25); //vcom
for(count=0;count<42;count++)
{EPD_2in7_SendData(EPD_2in7_gray_lut_ww[count]);}
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
@ -147,37 +320,139 @@ void EPD_2IN7_Init(void)
{
EPD_2in7_Reset();
EPD_2in7_SendCommand(0x06); //boost soft start
EPD_2in7_SendData(0x07); //A
EPD_2in7_SendData(0x07); //B
EPD_2in7_SendData(0x17); //C
EPD_2in7_SendCommand(0x04);
EPD_2in7_ReadBusy();
EPD_2in7_SendCommand(0x00); //panel setting
EPD_2in7_SendData(0x1f); //LUT from OTP¡ê?128x296
EPD_2in7_SendCommand(0x01); // POWER_SETTING
EPD_2in7_SendData(0x03); // VDS_EN, VDG_EN
EPD_2in7_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
EPD_2in7_SendData(0x2b); // VDH
EPD_2in7_SendData(0x2b); // VDL
EPD_2in7_SendData(0x09); // VDHR
EPD_2in7_SendCommand(0x16);
EPD_2in7_SendData(0x00); //KW-BF KWR-AF BWROTP 0f
EPD_2in7_SendCommand(0x06); // BOOSTER_SOFT_START
EPD_2in7_SendData(0x07);
EPD_2in7_SendData(0x07);
EPD_2in7_SendData(0x17);
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x60);
EPD_2in7_SendData(0xa5);
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x73);
EPD_2in7_SendData(0x23);
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x7C);
EPD_2in7_SendData(0x00);
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x60);
EPD_2in7_SendData(0xA5);
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x89);
EPD_2in7_SendData(0xA5);
EPD_2in7_SendCommand(0X50);
EPD_2in7_SendData(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x90);
EPD_2in7_SendData(0x00);
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x93);
EPD_2in7_SendData(0x2A);
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0xA0);
EPD_2in7_SendData(0xA5);
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0xA1);
EPD_2in7_SendData(0x00);
// Power optimization
EPD_2in7_SendCommand(0xF8);
EPD_2in7_SendData(0x73);
EPD_2in7_SendData(0x41);
EPD_2in7_SendCommand(0x16); // PARTIAL_DISPLAY_REFRESH
EPD_2in7_SendData(0x00);
EPD_2in7_SendCommand(0x04); // POWER_ON
EPD_2in7_ReadBusy();
EPD_2in7_SendCommand(0x00); // PANEL_SETTING
EPD_2in7_SendData(0xAF); // KW-BF KWR-AF BWROTP 0f
EPD_2in7_SendCommand(0x30); // PLL_CONTROL
EPD_2in7_SendData(0x3A); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
EPD_2in7_SendCommand(0x82); // VCM_DC_SETTING_REGISTER
EPD_2in7_SendData(0x12);
EPD_2in7_SetLut();
}
void EPD_2IN7_Init_4Gray(void)
{
EPD_2in7_Reset();
EPD_2in7_SendCommand(0x01); //POWER SETTING
EPD_2in7_SendData (0x03);
EPD_2in7_SendData (0x00);
EPD_2in7_SendData (0x2b);
EPD_2in7_SendData (0x2b);
EPD_2in7_SendCommand(0x06); //booster soft start
EPD_2in7_SendData (0x07); //A
EPD_2in7_SendData (0x07); //B
EPD_2in7_SendData (0x17); //C
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0x60);
EPD_2in7_SendData (0xA5);
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0x89);
EPD_2in7_SendData (0xA5);
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0x90);
EPD_2in7_SendData (0x00);
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0x93);
EPD_2in7_SendData (0x2A);
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0xa0);
EPD_2in7_SendData (0xa5);
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0xa1);
EPD_2in7_SendData (0x00);
EPD_2in7_SendCommand(0xF8); //boost??
EPD_2in7_SendData (0x73);
EPD_2in7_SendData (0x41);
EPD_2in7_SendCommand(0x16);
EPD_2in7_SendData(0x00);
EPD_2in7_SendCommand(0x04);
EPD_2in7_ReadBusy();
EPD_2in7_SendCommand(0x00); //panel setting
EPD_2in7_SendData(0xbf); //KW-BF KWR-AF BWROTP 0f
EPD_2in7_SendCommand(0x30); //PLL setting
EPD_2in7_SendData (0x90); //100hz
EPD_2in7_SendCommand(0x61); //resolution setting
EPD_2in7_SendData (0x00); //176
EPD_2in7_SendData (0xb0);
EPD_2in7_SendData (0x01); //264
EPD_2in7_SendData (0x08);
EPD_2in7_SendCommand(0x82); //vcom_DC setting
EPD_2in7_SendData (0x12);
EPD_2in7_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_2in7_SendData(0x97);
}
/******************************************************************************
function : Clear screen
parameter:
@ -210,12 +485,19 @@ void EPD_2IN7_Clear(void)
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN7_Display(UBYTE *Image)
void EPD_2IN7_Display(const UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_2IN7_WIDTH % 8 == 0)? (EPD_2IN7_WIDTH / 8 ): (EPD_2IN7_WIDTH / 8 + 1);
Height = EPD_2IN7_HEIGHT;
EPD_2in7_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2in7_SendData(0XFF);
}
}
EPD_2in7_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
@ -226,12 +508,106 @@ void EPD_2IN7_Display(UBYTE *Image)
EPD_2in7_ReadBusy();
}
void EPD_2IN7_4GrayDisplay(const UBYTE *Image)
{
UDOUBLE i,j,k;
UBYTE temp1,temp2,temp3;
EPD_2in7_SendCommand(0x10);
for(i=0;i<5808;i++) //5808*4 46464
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = Image[i*2+j];
for(k=0;k<2;k++)
{
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if(temp2 == 0x80)
temp3 |= 0x01; //gray1
else //0x40
temp3 |= 0x00; //gray2
temp3 <<= 1;
temp1 <<= 2;
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0) //white
temp3 |= 0x01;
else if(temp2 == 0x00) //black
temp3 |= 0x00;
else if(temp2 == 0x80)
temp3 |= 0x01; //gray1
else //0x40
temp3 |= 0x00; //gray2
if(j!=1 || k!=1)
temp3 <<= 1;
temp1 <<= 2;
}
}
EPD_2in7_SendData(temp3);
}
// new data
EPD_2in7_SendCommand(0x13);
for(i=0;i<5808;i++) //5808*4 46464
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = Image[i*2+j];
for(k=0;k<2;k++)
{
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if(temp2 == 0x80)
temp3 |= 0x00; //gray1
else //0x40
temp3 |= 0x01; //gray2
temp3 <<= 1;
temp1 <<= 2;
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0) //white
temp3 |= 0x01;
else if(temp2 == 0x00) //black
temp3 |= 0x00;
else if(temp2 == 0x80)
temp3 |= 0x00; //gray1
else //0x40
temp3 |= 0x01; //gray2
if(j!=1 || k!=1)
temp3 <<= 1;
temp1 <<= 2;
}
}
EPD_2in7_SendData(temp3);
}
EPD_2in7_gray_SetLut();
EPD_2in7_SendCommand(0x12);
DEV_Delay_ms(200);
EPD_2in7_ReadBusy();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN7_Sleep(void)
{
EPD_2in7_SendCommand(0X50);
EPD_2in7_SendData(0xf7);
EPD_2in7_SendCommand(0X02); //power off
EPD_2in7_SendCommand(0X07); //deep sleep
EPD_2in7_SendData(0xA5);

View file

@ -4,10 +4,21 @@
* | Function : 2.7inch e-paper
* | Info :
*----------------
* | This version: V3.0
* | Date : 2019-06-12
* | This version: V3.1
* | Date : 2019-10-10
* | Info :
* -----------------------------------------------------------------------------
* V3.1(2019-10-10):
* 1. Add 4 grayscale display
* Add EPD_2in7_gray_lut_vcom[]
* Add EPD_2in7_gray_lut_ww[]
* Add EPD_2in7_gray_lut_bw[]
* Add EPD_2in7_gray_lut_wb[]
* Add EPD_2in7_gray_lut_bb[]
* Add EPD_2in7_gray_SetLut()
* Add EPD_2IN7_Init_4Gray()
* Add EPD_2IN7_4GrayDisplay()
*
* V3.0(2019-06-12):
* 1.Change:
* lut_vcom_dc[] => EPD_2in7_lut_vcom_dc[]
@ -86,11 +97,19 @@
// Display resolution
#define EPD_2IN7_WIDTH 176
#define EPD_2IN7_HEIGHT 264
#define EPD_2IN7_HEIGHT 264 //46464
//Gray level
#define GRAY1 0x03 //Blackest
#define GRAY2 0x02
#define GRAY3 0x01 //gray
#define GRAY4 0x00 //white
void EPD_2IN7_Init(void);
void EPD_2IN7_Clear(void);
void EPD_2IN7_Display(UBYTE *Image);
void EPD_2IN7_Display(const UBYTE *Image);
void EPD_2IN7_Sleep(void);
void EPD_2IN7_Init_4Gray(void);
void EPD_2IN7_4GrayDisplay(const UBYTE *Image);
#endif

View file

@ -0,0 +1,230 @@
/*****************************************************************************
* | File : EPD_7in5.c
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V2.0
* | Date : 2018-11-09
* | Info :
*****************************************************************************
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files(the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_7in5_V2.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Reg);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : send data
parameter:
Data : Write data
******************************************************************************/
static void EPD_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
static void EPD_WaitUntilIdle(void)
{
Debug("e-Paper busy\r\n");
unsigned char busy;
do{
EPD_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}while(busy);
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_7IN5_V2_TurnOnDisplay(void)
{
EPD_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_WaitUntilIdle();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
UBYTE EPD_7IN5_V2_Init(void)
{
EPD_Reset();
EPD_SendCommand(0x01); //POWER SETTING
EPD_SendData(0x07);
EPD_SendData(0x07); //VGH=20V,VGL=-20V
EPD_SendData(0x3f); //VDH=15V
EPD_SendData(0x3f); //VDL=-15V
EPD_SendCommand(0x04); //POWER ON
DEV_Delay_ms(100);
EPD_WaitUntilIdle();
EPD_SendCommand(0X00); //PANNEL SETTING
EPD_SendData(0x1F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_SendCommand(0x61); //tres
EPD_SendData(0x03); //source 800
EPD_SendData(0x20);
EPD_SendData(0x01); //gate 480
EPD_SendData(0xE0);
EPD_SendCommand(0X15);
EPD_SendData(0x00);
EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_SendData(0x10);
EPD_SendData(0x07);
EPD_SendCommand(0X60); //TCON SETTING
EPD_SendData(0x22);
return 0;
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_7IN5_V2_Clear(void)
{
UWORD Width, Height;
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
Height = EPD_7IN5_V2_HEIGHT;
UWORD i;
EPD_SendCommand(0x10);
for(i=0; i<Height*Width; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13);
for(i=0; i<Height*Width; i++) {
EPD_SendData(0x00);
}
EPD_7IN5_V2_TurnOnDisplay();
}
void EPD_7IN5_V2_ClearBlack(void)
{
UWORD Width, Height;
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
Height = EPD_7IN5_V2_HEIGHT;
UWORD i;
EPD_SendCommand(0x13);
for(i=0; i<Height*Width; i++) {
EPD_SendData(0xFF);
}
EPD_7IN5_V2_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_7IN5_V2_Display(const UBYTE *blackimage)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
Height = EPD_7IN5_V2_HEIGHT;
//send black data
EPD_SendCommand(0x13);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_SendData(~blackimage[i + j * Width]);
}
}
EPD_7IN5_V2_TurnOnDisplay();
}
void EPD_7IN5_V2_WritePicture(const UBYTE *blackimage, UBYTE Block)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
Height = EPD_7IN5_V2_HEIGHT;
if(Block == 0){
EPD_SendCommand(0x13);
}
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_SendData(~blackimage[i + j * Width]);
}
}
if(Block == 1){
EPD_7IN5_V2_TurnOnDisplay();
}
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_7IN5_V2_Sleep(void)
{
EPD_SendCommand(0X02); //power off
EPD_WaitUntilIdle();
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}

View file

@ -0,0 +1,50 @@
/*****************************************************************************
* | File : EPD_7in5_V2.h
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V2.0
* | Date : 2018-11-09
* | Info :
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
* 2.Change:EPD_Display(UBYTE *Image)
* Need to pass parameters: pointer to cached data
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef _EPD_7IN5_V2_H_
#define _EPD_7IN5_V2_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_7IN5_V2_WIDTH 800
#define EPD_7IN5_V2_HEIGHT 480
UBYTE EPD_7IN5_V2_Init(void);
void EPD_7IN5_V2_Clear(void);
void EPD_7IN5_V2_ClearBlack(void);
void EPD_7IN5_V2_Display(const UBYTE *blackimage);
void EPD_7IN5_V2_Sleep(void);
void EPD_7IN5_V2_WritePicture(const UBYTE *blackimage, UBYTE Block);
#endif

View file

@ -0,0 +1,275 @@
/*****************************************************************************
* | File : EPD_7IN5B_V2_7in5.c
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V2.0
* | Date : 2018-11-09
* | Info :
******************************************************************************
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files(the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_7in5b_V2.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_7IN5B_V2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_7IN5B_V2_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Reg);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : send data
parameter:
Data : Write data
******************************************************************************/
static void EPD_7IN5B_V2_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
void EPD_7IN5B_V2_WaitUntilIdle(void)
{
Debug("e-Paper busy\r\n");
unsigned char busy;
do {
EPD_7IN5B_V2_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}while(busy);
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_7IN5B_V2_TurnOnDisplay(void)
{
EPD_7IN5B_V2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_7IN5B_V2_WaitUntilIdle();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
UBYTE EPD_7IN5B_V2_Init(void)
{
EPD_7IN5B_V2_Reset();
EPD_7IN5B_V2_SendCommand(0x01); //POWER SETTING
EPD_7IN5B_V2_SendData(0x07);
EPD_7IN5B_V2_SendData(0x07); //VGH=20V,VGL=-20V
EPD_7IN5B_V2_SendData(0x3f); //VDH=15V
EPD_7IN5B_V2_SendData(0x3f); //VDL=-15V
EPD_7IN5B_V2_SendCommand(0x04); //POWER ON
DEV_Delay_ms(100);
EPD_7IN5B_V2_WaitUntilIdle();
EPD_7IN5B_V2_SendCommand(0X00); //PANNEL SETTING
EPD_7IN5B_V2_SendData(0x0F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_7IN5B_V2_SendCommand(0x61); //tres
EPD_7IN5B_V2_SendData(0x03); //source 800
EPD_7IN5B_V2_SendData(0x20);
EPD_7IN5B_V2_SendData(0x01); //gate 480
EPD_7IN5B_V2_SendData(0xE0);
EPD_7IN5B_V2_SendCommand(0X15);
EPD_7IN5B_V2_SendData(0x00);
EPD_7IN5B_V2_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_7IN5B_V2_SendData(0x11);
EPD_7IN5B_V2_SendData(0x07);
EPD_7IN5B_V2_SendCommand(0X60); //TCON SETTING
EPD_7IN5B_V2_SendData(0x22);
return 0;
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_7IN5B_V2_Clear(void)
{
UWORD Width, Height;
Width =(EPD_7IN5B_V2_WIDTH % 8 == 0)?(EPD_7IN5B_V2_WIDTH / 8 ):(EPD_7IN5B_V2_WIDTH / 8 + 1);
Height = EPD_7IN5B_V2_HEIGHT;
UWORD i;
EPD_7IN5B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_V2_SendData(0xff);
}
EPD_7IN5B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_V2_SendData(0x00);
}
EPD_7IN5B_V2_TurnOnDisplay();
}
void EPD_7IN5B_V2_ClearRed(void)
{
UWORD Width, Height;
Width =(EPD_7IN5B_V2_WIDTH % 8 == 0)?(EPD_7IN5B_V2_WIDTH / 8 ):(EPD_7IN5B_V2_WIDTH / 8 + 1);
Height = EPD_7IN5B_V2_HEIGHT;
UWORD i;
EPD_7IN5B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_V2_SendData(0xff);
}
EPD_7IN5B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_V2_SendData(0xff);
}
EPD_7IN5B_V2_TurnOnDisplay();
}
void EPD_7IN5B_V2_ClearBlack(void)
{
UWORD Width, Height;
Width =(EPD_7IN5B_V2_WIDTH % 8 == 0)?(EPD_7IN5B_V2_WIDTH / 8 ):(EPD_7IN5B_V2_WIDTH / 8 + 1);
Height = EPD_7IN5B_V2_HEIGHT;
UWORD i;
EPD_7IN5B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_V2_SendData(0x00);
}
EPD_7IN5B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_V2_SendData(0x00);
}
EPD_7IN5B_V2_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_7IN5B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5B_V2_WIDTH % 8 == 0)?(EPD_7IN5B_V2_WIDTH / 8 ):(EPD_7IN5B_V2_WIDTH / 8 + 1);
Height = EPD_7IN5B_V2_HEIGHT;
//send black data
EPD_7IN5B_V2_SendCommand(0x10);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_V2_SendData(blackimage[i + j * Width]);
}
}
EPD_7IN5B_V2_SendCommand(0x92);
//send red data
EPD_7IN5B_V2_SendCommand(0x13);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_V2_SendData(~ryimage[i + j * Width]);
}
}
EPD_7IN5B_V2_TurnOnDisplay();
}
//0 1 is a black area and 2 3 is a red area
void EPD_7IN5B_V2_WritePicture(const UBYTE *blackimage, UBYTE Block)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5B_V2_WIDTH % 8 == 0)?(EPD_7IN5B_V2_WIDTH / 8 ):(EPD_7IN5B_V2_WIDTH / 8 + 1);
Height = EPD_7IN5B_V2_HEIGHT;
if(Block == 0){
EPD_7IN5B_V2_SendCommand(0x10);
}else if(Block == 2){
EPD_7IN5B_V2_SendCommand(0x92);
EPD_7IN5B_V2_SendCommand(0x13);
}
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
if(Block>=2){
EPD_7IN5B_V2_SendData(~blackimage[i + j * Width]);
}else{
EPD_7IN5B_V2_SendData(blackimage[i + j * Width]);
}
}
}
if(Block == 3){
EPD_7IN5B_V2_TurnOnDisplay();
}
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_7IN5B_V2_Sleep(void)
{
EPD_7IN5B_V2_SendCommand(0X02); //power off
EPD_7IN5B_V2_WaitUntilIdle();
EPD_7IN5B_V2_SendCommand(0X07); //deep sleep
EPD_7IN5B_V2_SendData(0xA5);
}

View file

@ -0,0 +1,50 @@
/*****************************************************************************
* | File : EPD_7in5.h
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V2.0
* | Date : 2018-11-09
* | Info :
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
* 2.Change:EPD_Display(UBYTE *Image)
* Need to pass parameters: pointer to cached data
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef _EPD_7IN5B_V2_H_
#define _EPD_7IN5B_V2_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_7IN5B_V2_WIDTH 800
#define EPD_7IN5B_V2_HEIGHT 480
UBYTE EPD_7IN5B_V2_Init(void);
void EPD_7IN5B_V2_Clear(void);
void EPD_7IN5B_V2_ClearRed(void);
void EPD_7IN5B_V2_ClearBlack(void);
void EPD_7IN5B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_7IN5B_V2_Sleep(void);
void EPD_7IN5B_V2_WritePicture(const UBYTE *blackimage, UBYTE Block);
#endif