add 4inch epd 4 grayscale.
This commit is contained in:
parent
702def06bc
commit
8ed1b4696c
324 changed files with 14771 additions and 1979 deletions
|
|
@ -29,11 +29,14 @@
|
|||
******************************************************************************/
|
||||
#include "EPD_Test.h"
|
||||
#include "EPD_4in2.h"
|
||||
#include <string.h>
|
||||
|
||||
int EPD_4in2_test(void)
|
||||
{
|
||||
printf("EPD_4IN2_test Demo\r\n");
|
||||
DEV_Module_Init();
|
||||
if(DEV_Module_Init()!=0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("e-Paper Init and Clear...\r\n");
|
||||
EPD_4IN2_Init();
|
||||
|
|
@ -50,8 +53,7 @@ int EPD_4in2_test(void)
|
|||
}
|
||||
printf("Paint_NewImage\r\n");
|
||||
Paint_NewImage(BlackImage, EPD_4IN2_WIDTH, EPD_4IN2_HEIGHT, 0, WHITE);
|
||||
|
||||
|
||||
|
||||
#if 1 // show image for array
|
||||
printf("show image for array\r\n");
|
||||
Paint_SelectImage(BlackImage);
|
||||
|
|
@ -89,17 +91,95 @@ int EPD_4in2_test(void)
|
|||
|
||||
printf("EPD_Display\r\n");
|
||||
EPD_4IN2_Display(BlackImage);
|
||||
DEV_Delay_ms(2000);
|
||||
DEV_Delay_ms(2000);
|
||||
#endif
|
||||
printf("Support for partial refresh, but the refresh effect is not good, but it is not recommended\r\n");
|
||||
#if 0
|
||||
printf("Partial refresh\r\n");
|
||||
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(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, WHITE);
|
||||
Paint_DrawTime(150, 80, &sPaint_time, &Font20, WHITE, BLACK);
|
||||
EPD_4IN2_PartialDisplay(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, BlackImage);
|
||||
DEV_Delay_ms(500);//Analog clock 1s
|
||||
num = num - 1;
|
||||
if(num == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("Clear...\r\n");
|
||||
EPD_4IN2_Clear();
|
||||
EPD_4IN2_Init_4Gray();
|
||||
printf("show Gray------------------------\r\n");
|
||||
free(BlackImage);
|
||||
BlackImage = NULL;
|
||||
Imagesize = ((EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 4 ): (EPD_4IN2_WIDTH / 4 + 1)) * EPD_4IN2_HEIGHT;
|
||||
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||
printf("Failed to apply for black memory...\r\n");
|
||||
return -1;
|
||||
}
|
||||
Paint_NewImage(BlackImage, EPD_4IN2_WIDTH, EPD_4IN2_HEIGHT, 0, WHITE);
|
||||
Paint_SetScale(4);
|
||||
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_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(140, 0, "ÄãºÃabc", &Font12CN, GRAY1, GRAY4);
|
||||
Paint_DrawString_CN(140, 40, "ÄãºÃabc", &Font12CN, GRAY2, GRAY3);
|
||||
Paint_DrawString_CN(140, 80, "ÄãºÃabc", &Font12CN, GRAY3, GRAY2);
|
||||
Paint_DrawString_CN(140, 120, "ÄãºÃabc", &Font12CN, GRAY4, GRAY1);
|
||||
|
||||
Paint_DrawString_CN(220, 0, "΢ѩµç×Ó", &Font24CN, GRAY1, GRAY4);
|
||||
Paint_DrawString_CN(220, 40, "΢ѩµç×Ó", &Font24CN, GRAY2, GRAY3);
|
||||
Paint_DrawString_CN(220, 80, "΢ѩµç×Ó", &Font24CN, GRAY3, GRAY2);
|
||||
Paint_DrawString_CN(220, 120, "΢ѩµç×Ó", &Font24CN, GRAY4, GRAY1);
|
||||
|
||||
EPD_4IN2_4GrayDisplay(BlackImage);
|
||||
DEV_Delay_ms(500);
|
||||
|
||||
Paint_Clear(WHITE);
|
||||
EPD_4IN2_4GrayDisplay(gImage_4in2_4Gray);
|
||||
DEV_Delay_ms(2000);
|
||||
|
||||
|
||||
EPD_4IN2_Clear();
|
||||
|
||||
printf("Goto Sleep...\r\n");
|
||||
EPD_4IN2_Sleep();
|
||||
free(BlackImage);
|
||||
BlackImage = NULL;
|
||||
|
||||
|
||||
// close 5V
|
||||
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||
DEV_Module_Exit();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -57,6 +57,7 @@ extern const unsigned char gImage_2in13c_y[];
|
|||
extern const unsigned char gImage_2in13d[];
|
||||
|
||||
extern const unsigned char gImage_4in2[];
|
||||
extern const unsigned char gImage_4in2_4Gray[];
|
||||
extern const unsigned char gImage_4in2bc_b[];
|
||||
extern const unsigned char gImage_4in2bc_ry[];
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ typedef enum {
|
|||
#define FONT_FOREGROUND BLACK
|
||||
#define FONT_BACKGROUND WHITE
|
||||
|
||||
//4 Gray level
|
||||
#define GRAY1 0x03 //Blackest
|
||||
#define GRAY2 0x02
|
||||
#define GRAY3 0x01 //gray
|
||||
#define GRAY4 0x00 //white
|
||||
/**
|
||||
* The size of the point
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -99,12 +99,6 @@
|
|||
#define EPD_2IN7_WIDTH 176
|
||||
#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(const UBYTE *Image);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,31 @@
|
|||
* | Function : 4.2inch e-paper
|
||||
* | Info :
|
||||
*----------------
|
||||
* | This version: V3.0
|
||||
* | Date : 2019-06-13
|
||||
* | This version: V3.1
|
||||
* | Date : 2019-11-14
|
||||
* | Info :
|
||||
* -----------------------------------------------------------------------------
|
||||
* V3.1(2019-11-14):
|
||||
* 1.Add 4 grayscale drive and display program
|
||||
* Add EPD_4IN2_4Gray_lut_vcom[]
|
||||
* Add EPD_4IN2_4Gray_lut_ww[]
|
||||
* Add EPD_4IN2_4Gray_lut_bw[]
|
||||
* Add EPD_4IN2_4Gray_lut_wb
|
||||
* Add EPD_4IN2_4Gray_lut_bb
|
||||
* Add EPD_4IN2_Partial_SetLut()
|
||||
* Add EPD_4IN2_4Gray_lut()
|
||||
* Add EPD_4IN2_Init_4Gray()
|
||||
* Add EPD_4IN2_4GrayDisplay(....)
|
||||
* 2.Add partial refresh display
|
||||
* Add EPD_4IN2_Partial_lut_vcom1[]
|
||||
* Add EPD_4IN2_Partial_lut_ww1[]
|
||||
* Add EPD_4IN2_Partial_lut_bw1[]
|
||||
* Add EPD_4IN2_Partial_lut_wb1[]
|
||||
* Add EPD_4IN2_Partial_lut_bb1[]
|
||||
* Add EPD_4IN2_Partial_SetLut()
|
||||
* Add EPD_4IN2_PartialDisplay(...)
|
||||
* Poor display, no display function by default
|
||||
*
|
||||
* V3.0(2019-06-13):
|
||||
* 1.Change:
|
||||
* lut_vcomDC[] => EPD_4IN2_lut_vcomDC[]
|
||||
|
|
@ -137,6 +158,108 @@ static const unsigned char EPD_4IN2_lut_bb[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
/******************************partial screen update LUT*********************************/
|
||||
const unsigned char EPD_4IN2_Partial_lut_vcom1[] ={
|
||||
0x00 ,0x19 ,0x01 ,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,
|
||||
0x00 ,0x00, };
|
||||
|
||||
const unsigned char EPD_4IN2_Partial_lut_ww1[] ={
|
||||
0x00 ,0x19 ,0x01 ,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 EPD_4IN2_Partial_lut_bw1[] ={
|
||||
0x80 ,0x19 ,0x01 ,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 EPD_4IN2_Partial_lut_wb1[] ={
|
||||
0x40 ,0x19 ,0x01 ,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 EPD_4IN2_Partial_lut_bb1[] ={
|
||||
0x00 ,0x19 ,0x01 ,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, };
|
||||
|
||||
/******************************gray*********************************/
|
||||
//0~3 gray
|
||||
const unsigned char EPD_4IN2_4Gray_lut_vcom[] =
|
||||
{
|
||||
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
|
||||
const unsigned char EPD_4IN2_4Gray_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
|
||||
const unsigned char EPD_4IN2_4Gray_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
|
||||
const unsigned char EPD_4IN2_4Gray_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
|
||||
const unsigned char EPD_4IN2_4Gray_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:
|
||||
|
|
@ -184,7 +307,9 @@ parameter:
|
|||
void EPD_4IN2_ReadBusy(void)
|
||||
{
|
||||
Debug("e-Paper busy\r\n");
|
||||
EPD_4IN2_SendCommand(0x71);
|
||||
while(DEV_Digital_Read(EPD_BUSY_PIN) == 0) { //LOW: idle, HIGH: busy
|
||||
EPD_4IN2_SendCommand(0x71);
|
||||
DEV_Delay_ms(100);
|
||||
}
|
||||
Debug("e-Paper busy release\r\n");
|
||||
|
|
@ -234,6 +359,60 @@ static void EPD_4IN2_SetLut(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void EPD_4IN2_Partial_SetLut(void)
|
||||
{
|
||||
unsigned int count;
|
||||
EPD_4IN2_SendCommand(0x20);
|
||||
for(count=0;count<44;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_vcom1[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x21);
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_ww1[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x22);
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bw1[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x23);
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_wb1[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x24);
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bb1[count]);}
|
||||
}
|
||||
|
||||
//LUT download
|
||||
static void EPD_4IN2_4Gray_lut(void)
|
||||
{
|
||||
unsigned int count;
|
||||
{
|
||||
EPD_4IN2_SendCommand(0x20); //vcom
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_vcom[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x21); //red not use
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x22); //bw r
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bw[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x23); //wb w
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_wb[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x24); //bb b
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bb[count]);}
|
||||
|
||||
EPD_4IN2_SendCommand(0x25); //vcom
|
||||
for(count=0;count<42;count++)
|
||||
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);}
|
||||
}
|
||||
}
|
||||
/******************************************************************************
|
||||
function : Initialize the e-Paper register
|
||||
parameter:
|
||||
|
|
@ -278,6 +457,42 @@ void EPD_4IN2_Init(void)
|
|||
EPD_4IN2_SetLut();
|
||||
}
|
||||
|
||||
void EPD_4IN2_Init_4Gray(void)
|
||||
{
|
||||
EPD_4IN2_Reset();
|
||||
EPD_4IN2_SendCommand(0x01); //POWER SETTING
|
||||
EPD_4IN2_SendData (0x03);
|
||||
EPD_4IN2_SendData (0x00); //VGH=20V,VGL=-20V
|
||||
EPD_4IN2_SendData (0x2b); //VDH=15V
|
||||
EPD_4IN2_SendData (0x2b); //VDL=-15V
|
||||
EPD_4IN2_SendData (0x13);
|
||||
|
||||
EPD_4IN2_SendCommand(0x06); //booster soft start
|
||||
EPD_4IN2_SendData (0x17); //A
|
||||
EPD_4IN2_SendData (0x17); //B
|
||||
EPD_4IN2_SendData (0x17); //C
|
||||
|
||||
EPD_4IN2_SendCommand(0x04);
|
||||
EPD_4IN2_ReadBusy();
|
||||
|
||||
EPD_4IN2_SendCommand(0x00); //panel setting
|
||||
EPD_4IN2_SendData(0x3f); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
|
||||
|
||||
EPD_4IN2_SendCommand(0x30); //PLL setting
|
||||
EPD_4IN2_SendData (0x3c); //100hz
|
||||
|
||||
EPD_4IN2_SendCommand(0x61); //resolution setting
|
||||
EPD_4IN2_SendData (0x01); //400
|
||||
EPD_4IN2_SendData (0x90);
|
||||
EPD_4IN2_SendData (0x01); //300
|
||||
EPD_4IN2_SendData (0x2c);
|
||||
|
||||
EPD_4IN2_SendCommand(0x82); //vcom_DC setting
|
||||
EPD_4IN2_SendData (0x12);
|
||||
|
||||
EPD_4IN2_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
|
||||
EPD_4IN2_SendData(0x97);
|
||||
}
|
||||
/******************************************************************************
|
||||
function : Clear screen
|
||||
parameter:
|
||||
|
|
@ -301,7 +516,8 @@ void EPD_4IN2_Clear(void)
|
|||
EPD_4IN2_SendData(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
EPD_4IN2_SendCommand(0x12); //DISPLAY REFRESH
|
||||
DEV_Delay_ms(10);
|
||||
EPD_4IN2_TurnOnDisplay();
|
||||
}
|
||||
|
||||
|
|
@ -321,10 +537,154 @@ void EPD_4IN2_Display(UBYTE *Image)
|
|||
EPD_4IN2_SendData(Image[i + j * Width]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EPD_4IN2_TurnOnDisplay();
|
||||
}
|
||||
|
||||
void EPD_4IN2_PartialDisplay(UWORD X_start,UWORD Y_start,UWORD X_end,UWORD Y_end, UBYTE *Image)
|
||||
{
|
||||
UWORD Width, Height;
|
||||
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
|
||||
Height = EPD_4IN2_HEIGHT;
|
||||
|
||||
X_start = (X_start % 8 == 0)? (X_start): (X_start/8*8+8);
|
||||
X_end = (X_end % 8 == 0)? (X_end): (X_end/8*8+8);
|
||||
|
||||
EPD_4IN2_SendCommand(0X50);
|
||||
EPD_4IN2_SendData(0xf7);
|
||||
DEV_Delay_ms(100);
|
||||
|
||||
EPD_4IN2_SendCommand(0x82); //vcom_DC setting
|
||||
EPD_4IN2_SendData (0x08);
|
||||
EPD_4IN2_SendCommand(0X50);
|
||||
EPD_4IN2_SendData(0x47);
|
||||
EPD_4IN2_Partial_SetLut();
|
||||
EPD_4IN2_SendCommand(0x91); //This command makes the display enter partial mode
|
||||
EPD_4IN2_SendCommand(0x90); //resolution setting
|
||||
EPD_4IN2_SendData ((X_start)/256);
|
||||
EPD_4IN2_SendData ((X_start)%256); //x-start
|
||||
|
||||
EPD_4IN2_SendData ((X_end )/256);
|
||||
EPD_4IN2_SendData ((X_end )%256-1); //x-end
|
||||
|
||||
EPD_4IN2_SendData (Y_start/256);
|
||||
EPD_4IN2_SendData (Y_start%256); //y-start
|
||||
|
||||
EPD_4IN2_SendData (Y_end/256);
|
||||
EPD_4IN2_SendData (Y_end%256-1); //y-end
|
||||
EPD_4IN2_SendData (0x28);
|
||||
|
||||
EPD_4IN2_SendCommand(0x10); //writes Old data to SRAM for programming
|
||||
for (UWORD j = 0; j < Y_end - Y_start; j++) {
|
||||
for (UWORD i = 0; i < (X_end - X_start)/8; i++) {
|
||||
EPD_4IN2_SendData(Image[(Y_start + j)*Width + X_start/8 + i]);
|
||||
}
|
||||
}
|
||||
EPD_4IN2_SendCommand(0x13); //writes New data to SRAM.
|
||||
for (UWORD j = 0; j < Y_end - Y_start; j++) {
|
||||
for (UWORD i = 0; i < (X_end - X_start)/8; i++) {
|
||||
EPD_4IN2_SendData(~Image[(Y_start + j)*Width + X_start/8 + i]);
|
||||
}
|
||||
}
|
||||
|
||||
EPD_4IN2_SendCommand(0x12); //DISPLAY REFRESH
|
||||
DEV_Delay_ms(10); //The delay here is necessary, 200uS at least!!!
|
||||
EPD_4IN2_TurnOnDisplay();
|
||||
}
|
||||
|
||||
void EPD_4IN2_4GrayDisplay(const UBYTE *Image)
|
||||
{
|
||||
UDOUBLE i,j,k;
|
||||
UBYTE temp1,temp2,temp3;
|
||||
/****Color display description****
|
||||
white gray1 gray2 black
|
||||
0x10| 01 01 00 00
|
||||
0x13| 01 00 01 00
|
||||
*********************************/
|
||||
EPD_4IN2_SendCommand(0x10);
|
||||
|
||||
for(i=0;i<15000;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_4IN2_SendData(temp3);
|
||||
}
|
||||
// new data
|
||||
EPD_4IN2_SendCommand(0x13);
|
||||
for(i=0;i<15000;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_4IN2_SendData(temp3);
|
||||
}
|
||||
|
||||
EPD_4IN2_4Gray_lut();
|
||||
EPD_4IN2_TurnOnDisplay();
|
||||
}
|
||||
/******************************************************************************
|
||||
function : Enter sleep mode
|
||||
parameter:
|
||||
|
|
|
|||
|
|
@ -4,10 +4,31 @@
|
|||
* | Function : 4.2inch e-paper
|
||||
* | Info :
|
||||
*----------------
|
||||
* | This version: V3.0
|
||||
* | Date : 2019-06-13
|
||||
* | This version: V3.1
|
||||
* | Date : 2019-11-14
|
||||
* | Info :
|
||||
* -----------------------------------------------------------------------------
|
||||
* V3.1(2019-11-14):
|
||||
* 1.Add 4 grayscale drive and display program
|
||||
* Add EPD_4IN2_4Gray_lut_vcom[]
|
||||
* Add EPD_4IN2_4Gray_lut_ww[]
|
||||
* Add EPD_4IN2_4Gray_lut_bw[]
|
||||
* Add EPD_4IN2_4Gray_lut_wb
|
||||
* Add EPD_4IN2_4Gray_lut_bb
|
||||
* Add EPD_4IN2_Partial_SetLut()
|
||||
* Add EPD_4IN2_4Gray_lut()
|
||||
* Add EPD_4IN2_Init_4Gray()
|
||||
* Add EPD_4IN2_4GrayDisplay(....)
|
||||
* 2.Add partial refresh display
|
||||
* Add EPD_4IN2_Partial_lut_vcom1[]
|
||||
* Add EPD_4IN2_Partial_lut_ww1[]
|
||||
* Add EPD_4IN2_Partial_lut_bw1[]
|
||||
* Add EPD_4IN2_Partial_lut_wb1[]
|
||||
* Add EPD_4IN2_Partial_lut_bb1[]
|
||||
* Add EPD_4IN2_Partial_SetLut()
|
||||
* Add EPD_4IN2_PartialDisplay(...)
|
||||
* Poor display, no display function by default
|
||||
*
|
||||
* V3.0(2019-06-13):
|
||||
* 1.Change:
|
||||
* lut_vcomDC[] => EPD_4IN2_lut_vcomDC[]
|
||||
|
|
@ -101,5 +122,8 @@ void EPD_4IN2_Init(void);
|
|||
void EPD_4IN2_Clear(void);
|
||||
void EPD_4IN2_Display(UBYTE *Image);
|
||||
void EPD_4IN2_Sleep(void);
|
||||
void EPD_4IN2_PartialDisplay(UWORD X_start,UWORD Y_start,UWORD X_end,UWORD Y_end, UBYTE *Image);
|
||||
|
||||
void EPD_4IN2_Init_4Gray(void);
|
||||
void EPD_4IN2_4GrayDisplay(const UBYTE *Image);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue