add 2in13_V3 example code (RPi)
This commit is contained in:
parent
c1974d4cde
commit
9c097b5cc3
6 changed files with 512 additions and 83 deletions
|
|
@ -4,8 +4,8 @@
|
|||
* | Function : 2.13inch e-paper V3 test demo
|
||||
* | Info :
|
||||
*----------------
|
||||
* | This version: V1.0
|
||||
* | Date : 2020-12-22
|
||||
* | This version: V1.1
|
||||
* | Date : 2021-10-30
|
||||
* | Info :
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
@ -33,40 +33,40 @@
|
|||
|
||||
int EPD_2in13_V3_test(void)
|
||||
{
|
||||
printf("EPD_2in13_V3_test Demo\r\n");
|
||||
Debug("EPD_2in13_V3_test Demo\r\n");
|
||||
if(DEV_Module_Init()!=0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("e-Paper Init and Clear...\r\n");
|
||||
Debug("e-Paper Init and Clear...\r\n");
|
||||
EPD_2in13_V3_Init();
|
||||
|
||||
struct timespec start={0,0}, finish={0,0};
|
||||
clock_gettime(CLOCK_REALTIME,&start);
|
||||
EPD_2in13_V3_Clear();
|
||||
clock_gettime(CLOCK_REALTIME,&finish);
|
||||
printf("%ld S\r\n",finish.tv_sec-start.tv_sec);
|
||||
Debug("%ld S\r\n",finish.tv_sec-start.tv_sec);
|
||||
|
||||
//Create a new image cache
|
||||
UBYTE *BlackImage;
|
||||
UWORD Imagesize = ((EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1)) * EPD_2in13_V3_HEIGHT;
|
||||
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||
printf("Failed to apply for black memory...\r\n");
|
||||
Debug("Failed to apply for black memory...\r\n");
|
||||
return -1;
|
||||
}
|
||||
printf("Paint_NewImage\r\n");
|
||||
Debug("Paint_NewImage\r\n");
|
||||
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||
Paint_Clear(WHITE);
|
||||
|
||||
#if 1 // show bmp
|
||||
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||
printf("show window BMP-----------------\r\n");
|
||||
Debug("show window BMP-----------------\r\n");
|
||||
Paint_SelectImage(BlackImage);
|
||||
GUI_ReadBmp("./pic/100x100.bmp", 0, 0);
|
||||
GUI_ReadBmp("./pic/100x100.bmp", 10, 10);
|
||||
EPD_2in13_V3_Display(BlackImage);
|
||||
DEV_Delay_ms(3000);
|
||||
|
||||
printf("show bmp------------------------\r\n");
|
||||
Debug("show bmp------------------------\r\n");
|
||||
Paint_SelectImage(BlackImage);
|
||||
GUI_ReadBmp("./pic/2in13_1.bmp", 0, 0);
|
||||
EPD_2in13_V3_Display(BlackImage);
|
||||
|
|
@ -74,7 +74,7 @@ int EPD_2in13_V3_test(void)
|
|||
#endif
|
||||
|
||||
#if 1 //show image for array
|
||||
printf("show image for array\r\n");
|
||||
Debug("show image for array\r\n");
|
||||
Paint_SelectImage(BlackImage);
|
||||
Paint_Clear(WHITE);
|
||||
Paint_DrawBitMap(gImage_2in13_2);
|
||||
|
|
@ -85,7 +85,7 @@ int EPD_2in13_V3_test(void)
|
|||
|
||||
#if 1 // Drawing on the image
|
||||
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||
printf("Drawing\r\n");
|
||||
Debug("Drawing\r\n");
|
||||
//1.Select Image
|
||||
Paint_SelectImage(BlackImage);
|
||||
Paint_Clear(WHITE);
|
||||
|
|
@ -109,8 +109,8 @@ int EPD_2in13_V3_test(void)
|
|||
Paint_DrawString_EN(140, 15, "waveshare", &Font16, BLACK, WHITE);
|
||||
Paint_DrawNum(140, 40, 123456789, &Font16, BLACK, WHITE);
|
||||
|
||||
Paint_DrawString_CN(140, 60, "你好abc", &Font12CN, BLACK, WHITE);
|
||||
Paint_DrawString_CN(5, 65, "微雪电子", &Font24CN, WHITE, BLACK);
|
||||
Paint_DrawString_CN(140, 60, "ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||
Paint_DrawString_CN(5, 65, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||
|
||||
EPD_2in13_V3_Display_Base(BlackImage);
|
||||
DEV_Delay_ms(3000);
|
||||
|
|
@ -118,7 +118,7 @@ int EPD_2in13_V3_test(void)
|
|||
|
||||
#if 1 //Partial refresh, example shows time
|
||||
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||
printf("Partial refresh\r\n");
|
||||
Debug("Partial refresh\r\n");
|
||||
Paint_SelectImage(BlackImage);
|
||||
|
||||
PAINT_TIME sPaint_time;
|
||||
|
|
@ -153,17 +153,17 @@ int EPD_2in13_V3_test(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
printf("Clear...\r\n");
|
||||
Debug("Clear...\r\n");
|
||||
EPD_2in13_V3_Init();
|
||||
EPD_2in13_V3_Clear();
|
||||
|
||||
printf("Goto Sleep...\r\n");
|
||||
Debug("Goto Sleep...\r\n");
|
||||
EPD_2in13_V3_Sleep();
|
||||
free(BlackImage);
|
||||
BlackImage = NULL;
|
||||
DEV_Delay_ms(2000);//important, at least 2s
|
||||
// close 5V
|
||||
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||
Debug("close 5V, Module enters 0 power consumption ...\r\n");
|
||||
DEV_Module_Exit();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ int main(void)
|
|||
// EPD_1in54_test();
|
||||
// EPD_1in54_V2_test();
|
||||
// EPD_1in54b_test();
|
||||
// EPD_1in54b_V2_test();
|
||||
// EPD_1in54b_V2_test();
|
||||
// EPD_1in54c_test();
|
||||
|
||||
// EPD_2in66_test();
|
||||
|
|
@ -43,8 +43,8 @@ int main(void)
|
|||
// EPD_2in9d_test();
|
||||
|
||||
// EPD_2in13_test();
|
||||
// EPD_2in13_V2_test();
|
||||
// EPD_2in13_V3_test();
|
||||
// EPD_2in13_V2_test();
|
||||
EPD_2in13_V3_test();
|
||||
// EPD_2in13bc_test();
|
||||
// EPD_2in13b_V3_test();
|
||||
// EPD_2in13d_test();
|
||||
|
|
@ -63,14 +63,14 @@ int main(void)
|
|||
// EPD_5in65f_test();
|
||||
|
||||
// EPD_5in83_test();
|
||||
// EPD_5in83_V2_test();
|
||||
// EPD_5in83_V2_test();
|
||||
// EPD_5in83bc_test();
|
||||
// EPD_5in83b_V2_test();
|
||||
|
||||
// EPD_5in84_test();
|
||||
|
||||
// EPD_7in5_test();
|
||||
// EPD_7in5_V2_test();
|
||||
// EPD_7in5_V2_test();
|
||||
|
||||
// EPD_7in5bc_test();
|
||||
// EPD_7in5b_V2_test();
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
* | Function : 2.13inch e-paper V3
|
||||
* | Info :
|
||||
*----------------
|
||||
* | This version: V1.0
|
||||
* | Date : 2020-12-22
|
||||
* | This version: V1.1
|
||||
* | Date : 2021-10-30
|
||||
* | Info :
|
||||
* -----------------------------------------------------------------------------
|
||||
#
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
#include "EPD_2in13_V3.h"
|
||||
#include "Debug.h"
|
||||
|
||||
UBYTE WF_PARTIAL_2IN13_V2[159] =
|
||||
UBYTE WF_PARTIAL_2IN13_V3[159] =
|
||||
{
|
||||
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
|
@ -52,9 +52,9 @@ UBYTE WF_PARTIAL_2IN13_V2[159] =
|
|||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
|
||||
0x22,0x17,0x41,0x00,0x32,0x36,
|
||||
};
|
||||
};
|
||||
|
||||
UBYTE WS_20_30_2IN13_V2[159] =
|
||||
UBYTE WS_20_30_2IN13_V3[159] =
|
||||
{
|
||||
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
|
|
@ -75,7 +75,7 @@ UBYTE WS_20_30_2IN13_V2[159] =
|
|||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
|
||||
0x22, 0x17, 0x41, 0x0, 0x32, 0x36
|
||||
};
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
function : Software reset
|
||||
|
|
@ -84,11 +84,11 @@ parameter:
|
|||
static void EPD_2in13_V3_Reset(void)
|
||||
{
|
||||
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||
DEV_Delay_ms(100);
|
||||
DEV_Delay_ms(20);
|
||||
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||
DEV_Delay_ms(2);
|
||||
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||
DEV_Delay_ms(100);
|
||||
DEV_Delay_ms(20);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
@ -140,17 +140,17 @@ parameter:
|
|||
******************************************************************************/
|
||||
static void EPD_2in13_V3_TurnOnDisplay(void)
|
||||
{
|
||||
EPD_2in13_V3_SendCommand(0x22); //Display Update Control
|
||||
EPD_2in13_V3_SendCommand(0x22); // Display Update Control
|
||||
EPD_2in13_V3_SendData(0xc7);
|
||||
EPD_2in13_V3_SendCommand(0x20); //Activate Display Update Sequence
|
||||
EPD_2in13_V3_SendCommand(0x20); // Activate Display Update Sequence
|
||||
EPD_2in13_V3_ReadBusy();
|
||||
}
|
||||
|
||||
static void EPD_2in13_V3_TurnOnDisplay_Partial(void)
|
||||
{
|
||||
EPD_2in13_V3_SendCommand(0x22); //Display Update Control
|
||||
EPD_2in13_V3_SendData(0x0f); // c0/ff
|
||||
EPD_2in13_V3_SendCommand(0x20); //Activate Display Update Sequence
|
||||
EPD_2in13_V3_SendCommand(0x22); // Display Update Control
|
||||
EPD_2in13_V3_SendData(0x0f); // fast:0x0c, quality:0x0f, 0xcf
|
||||
EPD_2in13_V3_SendCommand(0x20); // Activate Display Update Sequence
|
||||
EPD_2in13_V3_ReadBusy();
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,6 @@ static void EPD_2IN13_V2_LUT_by_host(UBYTE *lut)
|
|||
EPD_2in13_V3_SendData(*(lut+157)); // VSL
|
||||
EPD_2in13_V3_SendCommand(0x2c); // VCOM
|
||||
EPD_2in13_V3_SendData(*(lut+158));
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
@ -185,17 +184,15 @@ parameter:
|
|||
******************************************************************************/
|
||||
static void EPD_2in13_V3_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
|
||||
{
|
||||
// Ystart = 295 - Ystart;
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
|
||||
EPD_2in13_V3_SendData((Xstart>>3) & 0xFF);
|
||||
EPD_2in13_V3_SendData((Xend>>3) & 0xFF);
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
|
||||
EPD_2in13_V3_SendData(Yend & 0xFF);
|
||||
EPD_2in13_V3_SendData((Yend >> 8) & 0xFF);
|
||||
EPD_2in13_V3_SendData(Ystart & 0xFF);
|
||||
EPD_2in13_V3_SendData((Ystart >> 8) & 0xFF);
|
||||
EPD_2in13_V3_SendData(Yend & 0xFF);
|
||||
EPD_2in13_V3_SendData((Yend >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
@ -204,8 +201,6 @@ parameter:
|
|||
******************************************************************************/
|
||||
static void EPD_2in13_V3_SetCursor(UWORD Xstart, UWORD Ystart)
|
||||
{
|
||||
Ystart = 295 - Ystart;
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
|
||||
EPD_2in13_V3_SendData(Xstart & 0xFF);
|
||||
|
||||
|
|
@ -228,14 +223,15 @@ void EPD_2in13_V3_Init(void)
|
|||
EPD_2in13_V3_ReadBusy();
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x01); //Driver output control
|
||||
EPD_2in13_V3_SendData(0x27);
|
||||
EPD_2in13_V3_SendData(0x01);
|
||||
EPD_2in13_V3_SendData(0x01);
|
||||
EPD_2in13_V3_SendData(0xf9);
|
||||
EPD_2in13_V3_SendData(0x00);
|
||||
EPD_2in13_V3_SendData(0x00);
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x11); //data entry mode
|
||||
EPD_2in13_V3_SendData(0x01);
|
||||
EPD_2in13_V3_SendData(0x03);
|
||||
|
||||
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, 296-1);
|
||||
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
|
||||
EPD_2in13_V3_SetCursor(0, 0);
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x3C); //BorderWavefrom
|
||||
EPD_2in13_V3_SendData(0x05);
|
||||
|
|
@ -246,11 +242,9 @@ void EPD_2in13_V3_Init(void)
|
|||
|
||||
EPD_2in13_V3_SendCommand(0x18); //Read built-in temperature sensor
|
||||
EPD_2in13_V3_SendData(0x80);
|
||||
|
||||
EPD_2in13_V3_SetCursor(0, 0);
|
||||
|
||||
EPD_2in13_V3_ReadBusy();
|
||||
|
||||
EPD_2IN13_V2_LUT_by_host(WS_20_30_2IN13_V2);
|
||||
EPD_2IN13_V2_LUT_by_host(WS_20_30_2IN13_V3);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
@ -259,12 +253,17 @@ parameter:
|
|||
******************************************************************************/
|
||||
void EPD_2in13_V3_Clear(void)
|
||||
{
|
||||
UWORD i;
|
||||
EPD_2in13_V3_SendCommand(0x24); //write RAM for black(0)/white (1)
|
||||
for(i=0;i<4736;i++)
|
||||
{
|
||||
EPD_2in13_V3_SendData(0xff);
|
||||
}
|
||||
UWORD Width, Height;
|
||||
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||
Height = EPD_2in13_V3_HEIGHT;
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x24);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
EPD_2in13_V3_SendData(0XFF);
|
||||
}
|
||||
}
|
||||
|
||||
EPD_2in13_V3_TurnOnDisplay();
|
||||
}
|
||||
|
||||
|
|
@ -274,43 +273,62 @@ parameter:
|
|||
******************************************************************************/
|
||||
void EPD_2in13_V3_Display(UBYTE *Image)
|
||||
{
|
||||
UWORD i;
|
||||
EPD_2in13_V3_SendCommand(0x24); //write RAM for black(0)/white (1)
|
||||
for(i=0;i<4736;i++)
|
||||
{
|
||||
EPD_2in13_V3_SendData(Image[i]);
|
||||
}
|
||||
UWORD Width, Height;
|
||||
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||
Height = EPD_2in13_V3_HEIGHT;
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x24);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||
}
|
||||
}
|
||||
|
||||
EPD_2in13_V3_TurnOnDisplay();
|
||||
}
|
||||
|
||||
void EPD_2in13_V3_Display_Base(UBYTE *Image)
|
||||
{
|
||||
UWORD i;
|
||||
|
||||
/******************************************************************************
|
||||
function : Refresh a base image
|
||||
parameter:
|
||||
******************************************************************************/
|
||||
void EPD_2in13_V3_Display_Base(UBYTE *Image)
|
||||
{
|
||||
UWORD Width, Height;
|
||||
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||
Height = EPD_2in13_V3_HEIGHT;
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x24); //Write Black and White image to RAM
|
||||
for(i=0;i<4736;i++)
|
||||
{
|
||||
EPD_2in13_V3_SendData(Image[i]);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||
}
|
||||
}
|
||||
EPD_2in13_V3_SendCommand(0x26); //Write Black and White image to RAM
|
||||
for(i=0;i<4736;i++)
|
||||
{
|
||||
EPD_2in13_V3_SendData(Image[i]);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||
}
|
||||
}
|
||||
EPD_2in13_V3_TurnOnDisplay();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function : Sends the image buffer in RAM to e-Paper and partial refresh
|
||||
parameter:
|
||||
******************************************************************************/
|
||||
void EPD_2in13_V3_Display_Partial(UBYTE *Image)
|
||||
{
|
||||
UWORD i;
|
||||
UWORD Width, Height;
|
||||
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||
Height = EPD_2in13_V3_HEIGHT;
|
||||
|
||||
//Reset
|
||||
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||
DEV_Delay_ms(2);
|
||||
DEV_Delay_ms(1);
|
||||
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||
DEV_Delay_ms(3);
|
||||
|
||||
EPD_2IN13_V2_LUT_by_host(WF_PARTIAL_2IN13_V2);
|
||||
EPD_2IN13_V2_LUT_by_host(WF_PARTIAL_2IN13_V3);
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x37);
|
||||
EPD_2in13_V3_SendData(0x00);
|
||||
|
|
@ -332,13 +350,14 @@ void EPD_2in13_V3_Display_Partial(UBYTE *Image)
|
|||
EPD_2in13_V3_SendCommand(0x20); //Activate Display Update Sequence
|
||||
EPD_2in13_V3_ReadBusy();
|
||||
|
||||
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, 296-1);
|
||||
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
|
||||
EPD_2in13_V3_SetCursor(0, 0);
|
||||
|
||||
EPD_2in13_V3_SendCommand(0x24); //Write Black and White image to RAM
|
||||
for(i=0;i<4736;i++)
|
||||
{
|
||||
EPD_2in13_V3_SendData(Image[i]);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||
}
|
||||
}
|
||||
EPD_2in13_V3_TurnOnDisplay_Partial();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
* | Function : 2.13inch e-paper V3
|
||||
* | Info :
|
||||
*----------------
|
||||
* | This version: V1.0
|
||||
* | Date : 2020-12-22
|
||||
* | This version: V1.1
|
||||
* | Date : 2021-10-30
|
||||
* | Info :
|
||||
* -----------------------------------------------------------------------------
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue