first commit

This commit is contained in:
p23 2025-10-28 00:34:09 +08:00
commit 7eccac107c
297 changed files with 473382 additions and 0 deletions

11
CMakeLists.txt Normal file
View file

@ -0,0 +1,11 @@
file(GLOB_RECURSE MY_LIB_SOURCES
"ESP32epdx/src/*.cpp"
"ESP32epdx/src/GUI/*.cpp"
"pubsubclient/src/*.cpp")
idf_component_register(
#SRCS "main.cpp" "EPD.cpp" "wifi_helper.cpp" "mqtt.cpp" ${MY_LIB_SOURCES}
#INCLUDE_DIRS "" "ESP32epdx/src" "ESP32epdx/src/GUI" "pubsubclient/src"
SRCS "main.cpp" "EPD.cpp" "wifi_helper.c" "mqtt_helper.c" ${MY_LIB_SOURCES}
INCLUDE_DIRS "" "ESP32epdx/src" "ESP32epdx/src/GUI"
)

600
EPD.cpp Normal file
View file

@ -0,0 +1,600 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//Fast update 2 initialization
void EPD_HW_Init_Fast2(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//Fast 2 display
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(*datas);
datas++;
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Fast();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

41
EPD.h Normal file
View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 152
#define EPD_HEIGHT 296
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Fast2(void);
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

2
ESP32epdx/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
library.properties

0
ESP32epdx/LICENSE Normal file
View file

26
ESP32epdx/README.md Normal file
View file

@ -0,0 +1,26 @@
v1.0.8
Added 3.97-inch monochrome and 4-color options, updated 2.9/5.79/7.5/11.6-inch 4-color options, and added fast refresh function.
增加3.97寸单色、四色更新2.9/5.79/7.5/11.6寸四色,增加快刷功能。
v1.0.7
Add BT and WiFi control e-paper display examples
增加BT和WiFi控制电子纸显示示例
v1.0.6
Add a 4-color e-paper driver for sizes and improve GUI functionality
增加4色电子纸驱动程序完善GUI功能
v1.0.5
Add a 3-color e-paper driver for sizes and improve GUI functionality
增加3色电子纸驱动程序完善GUI功能
v1.0.4
Add a 2-color e-paper driver for sizes under 7.5 inches and improve GUI functionality
增加2色电子纸驱动程序7.5寸以上完善GUI功能
v1.0.1
Add a 2-color e-paper driver for sizes under 7.5 inches and improve GUI functionality
增加2色电子纸驱动程序7.5寸以下完善GUI功能

View file

@ -0,0 +1,546 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+112-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+112-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+112-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+112-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+112-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+112-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 88
#define EPD_HEIGHT 184
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI display
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,158 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
/************4 Gray update mode(2s)*******************/
#if 1 //To enable this feature, please change 0 to 1
/************Onder versions do not support this feature*******************/
EPD_HW_Init_4G(); //Fast update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(32,56+24*0,Num[i], //x-A,y-A,DATA-A
32,56+24*1,Num[0], //x-B,y-B,DATA-B
32,56+24*2,gImage_numdot, //x-C,y-C,DATA-C
32,56+24*3,Num[0], //x-D,y-D,DATA-D
32,56+24*4,Num[1],24,32); //x-E,y-E,DATA-E,Resolution 24*32
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(5, 10, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(5, 25, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(5, 45, 123456789, &Font16, BLACK, WHITE); //11*16.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,392 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
unsigned char oldData[2024];
unsigned char oldDataP[256];
unsigned char oldDataA[256];
unsigned char oldDataB[256];
unsigned char oldDataC[256];
unsigned char oldDataD[256];
unsigned char oldDataE[256];
unsigned char partFlag=1;
void lcd_chkstatus(void)
{
while(isEPD_W21_BUSY==0);
}
//UC8175
void EPD_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
lcd_chkstatus();
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0x5f); //LUT from OTP
EPD_W21_WriteCMD(0x2A); //IC hidden instructions
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
const unsigned char lut_w[] =
{
0x60 ,0x01 ,0x01 ,0x00 ,0x00 ,0x01 ,
0x80 ,0x0f ,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 ,0x0f ,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 ,
};
void Part_lut_bw(void)
{
unsigned int count;
EPD_W21_WriteCMD(0x23);
for(count=0;count<42;count++)
{EPD_W21_WriteDATA(lut_w[count]);}
EPD_W21_WriteCMD(0x24);
for(count=0;count<42;count++)
{EPD_W21_WriteDATA(lut_b[count]);}
}
void EPD_Init_Part(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
lcd_chkstatus();
EPD_W21_WriteCMD(0xD2);
EPD_W21_WriteDATA(0x3F);
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA (0x6F); //from outside
EPD_W21_WriteCMD(0x01); //power setting
EPD_W21_WriteDATA (0x03);
EPD_W21_WriteDATA (0x00);
EPD_W21_WriteDATA (0x26);
EPD_W21_WriteDATA (0x26);
EPD_W21_WriteCMD(0x06);
EPD_W21_WriteDATA(0x3F);
EPD_W21_WriteCMD(0x2A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x30);
EPD_W21_WriteDATA(0x13); //50Hz
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xF2);
EPD_W21_WriteCMD(0x60);
EPD_W21_WriteDATA(0x22);
EPD_W21_WriteCMD(0x82);
EPD_W21_WriteDATA(0x12);//-0.1v
EPD_W21_WriteCMD(0xe3);
EPD_W21_WriteDATA(0x33);
Part_lut_bw();
EPD_W21_WriteCMD(0x04); //power on
lcd_chkstatus();
}
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0xf7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
delay(100);
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
//Full screen update function
void EPD_Update(void)
{
//update
EPD_W21_WriteCMD(0x12); //DISPLAY update
delay(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
}
EPD_Update();
}
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF);
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
oldData[i]=0xFF;
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldData[i]=datas[i];
}
EPD_Update();
}
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start); //y-start
EPD_W21_WriteDATA (y_end); //y-end
EPD_W21_WriteDATA (0x00);
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM
if(partFlag==1)
{
partFlag=0;
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldData[i]=datas[i];
}
EPD_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
EPD_Init_Part();
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
oldData[i]=datas[i];
}
EPD_Update();
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN*num-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start); //y-start
EPD_W21_WriteDATA (y_end); //y-end
EPD_W21_WriteDATA (0x00);
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM
if(partFlag==1)
{
partFlag=0;
for(i=0;i<PART_COLUMN*PART_LINE*num/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataA[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataB[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataC[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataD[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataE[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_A[i]);
oldDataA[i]=datas_A[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_B[i]);
oldDataB[i]=datas_B[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_C[i]);
oldDataC[i]=datas_C[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_D[i]);
oldDataD[i]=datas_D[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_E[i]);
oldDataE[i]=datas_E[i];
}
EPD_Update();
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
EPD_Dis_Part_RAM(x_start,y_start,datas_A,datas_B,datas_C,datas_D,datas_E,num,PART_COLUMN,PART_LINE);
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
lcd_chkstatus();
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0x53); //180 mirror
EPD_W21_WriteCMD(0x2A); //IC hidden instructions
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
//GUI
void EPD_Display(unsigned char *Image)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(Image[i]); //Transfer the actual displayed data
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,31 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 80
#define EPD_HEIGHT 128
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_Init_Part(void);
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,143 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
{
EPD_Dis_Part_Time(24,4,Num[i],Num[0],gImage_numdot,Num[0],Num[1],5,24,32); //x,y,DATA-A~E,number,Resolution 32*32
}
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_Dis_PartAll(gImage_p1);
EPD_Dis_PartAll(gImage_p2);
EPD_Dis_PartAll(gImage_p3);
EPD_Dis_PartAll(gImage_p4);
EPD_Dis_PartAll(gImage_p5);
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 25, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 45, 123456789, &Font16, BLACK, WHITE); //Font16
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

View file

@ -0,0 +1,752 @@
//24*32
const unsigned char Num[10][96] = {
//0
{
0X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XFF,0X00,0X00,0X00,0X00,0X00,0X48,
0X00,0X00,0X7F,0XFF,0X00,0X00,0X70,0X00,0X00,0X48,0X00,0X00,0X7F,0XFF,0X00,0X00,
0X00,0X00,0X00,0X7F,0X00,0X00,0X7F,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0XFF,0XFF,0X00,0X00,0X3C,0X20,0X00,0X00,0X00,0X00,0XFF,0XFF,0X00,0X00,0X7E,0X20,
0X00,0X00,0X00,0X00,0XFF,0XFF,0X00,0X00,0X43,0X20,0X00,0X49,0X00,0X00,0XFF,0XFF,
0X00,0X00,0X41,0XA0,0X00,0X49,0X00,0X01,0XFF,0XFF,0X00,0X00,0X40,0XE0,0X00,0X49,
0X00,0X01,0XFF,0XFF,0X00,0X00,0X60,0X60,0X00,0X49,0X00,0X01,0XFF,0XFF,0X00,0X00,
0X20,0X20,0X00,0X7F,0X00,0X03,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,
0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X03,0XFF,0XFF,0X00,0X00,0X3F,0XC0,0X00,0X00,0X00,0X07,0XFF,0XFF,
0X00,0X00,0X7F,0XE0,0X00,0X30,0X00,0X07,0XFF,0XFF,0X00,0X00,0X40,0X20,0X00,0X48,
0X00,0X07,0XFF,0XFF,0X00,0X00,0X40,0X20,0X00,0X48,0X00,0X0F,0XFF,0XFF,0X00,0X00,
0X40,0X20,0X00,0X48,0X00,0X0F,0XFF,0XFF,0X00,0X00,0X7F,0XE0,0X00,0X7F,0X00,0X0F,
0XFF,0XFF,0X00,0X00,0X3F,0XC0,0X00,0X00,0X00,0X1F,0XFF,0XFF,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X1F,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X01,0X00,0X1F,0XFF,0XFF,
0X00,0X00,0X00,0X00,0X00,0X0E,0X00,0X1F,0XFF,0XFF,0X00,0X00,0X00,0X20,0X00,0X34,
0X00,0X3F,0XFF,0XFF,0X00,0X00,0X00,0X20,0X00,0X44,0X00,0X3F,0XFF,0XFF,0X00,0X00,
0X00,0X00,0X00,0X34,0X00,0X3F,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X0E,0X00,0X3F,
0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X01,0X00,0X7F,0XFF,0XFF,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X7F,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X7F,0XFF,0XFF,
0X00,0X00,0X7F,0XE0,0X00,0X30,0X00,0XFF,0XFF,0XFF,0X00,0X00,0X7F,0XE0,0X00,0X48,
0X00,0XFF,0XFF,0XFF,0X00,0X00,0X30,0X00,0X00,0X48,0X00,0XFF,0XFF,0XFF,0X00,0X00,
0X10,0X00,0X00,0X48,0X01,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X7F,0X01,0XFF,
0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,
0X00,0X00,0X01,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X04,0X03,0XFF,0XFF,0XFF,
0X00,0X00,0X00,0X00,0X00,0X04,0X03,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X04,
0X03,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X49,0X07,0XFF,
0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X49,0X07,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,
0X00,0X49,0X0F,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X49,0X0F,0X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FF,0XFF,0XFF,0XE0,0X00,0X07,0XCF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XCF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XCF,0XFF,0XFF,
};

View file

@ -0,0 +1,379 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen refresh initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen refresh update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial refresh update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen refresh display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial refresh of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial refresh display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial refresh display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial refresh write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+24-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+24-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+24-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+24-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+24-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+24-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,36 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 192
#define EPD_HEIGHT 176
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//GUI display
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,149 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(64,40+32*0,Num[i], //x-A,y-A,DATA-A
64,40+32*1,Num[0], //x-B,y-B,DATA-B
64,40+32*2,gImage_numdot, //x-C,y-C,DATA-C
64,40+32*3,Num[0], //x-D,y-D,DATA-D
64,40+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 100, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 110, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 125, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 145, 123456789, &Font20, BLACK, WHITE); //Font20
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,378 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256); EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,35 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 200
#define EPD_HEIGHT 200
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//GUI display
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,153 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
/* EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s */
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(64,56+32*0,Num[i], //x-A,y-A,DATA-A
64,56+32*1,Num[0], //x-B,y-B,DATA-B
64,56+32*2,gImage_numdot, //x-C,y-C,DATA-C
64,56+32*3,Num[0], //x-D,y-D,DATA-D
64,56+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 100, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 110, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 125, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 145, 123456789, &Font20, BLACK, WHITE); //Font20
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,537 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256); EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 200
#define EPD_HEIGHT 200
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI display
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,163 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
/* EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s */
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
/************4 Gray update mode(2s)*******************/
#if 1 //To enable this feature, please change 0 to 1
/************Onder versions do not support this feature*******************/
EPD_HW_Init_4G(); //Fast update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(64,56+32*0,Num[i], //x-A,y-A,DATA-A
64,56+32*1,Num[0], //x-B,y-B,DATA-B
64,56+32*2,gImage_numdot, //x-C,y-C,DATA-C
64,56+32*3,Num[0], //x-D,y-D,DATA-D
64,56+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //2s
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 100, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 110, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 125, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 145, 123456789, &Font20, BLACK, WHITE); //Font20
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,396 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,34 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 128
#define EPD_HEIGHT 250
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,141 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(24,72+32*0,Num[i], //x-A,y-A,DATA-A
24,72+32*1,Num[0], //x-B,y-B,DATA-B
24,72+32*2,gImage_numdot, //x-C,y-C,DATA-C
24,72+32*3,Num[0], //x-D,y-D,DATA-D
24,72+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,600 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update 1 initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update 1 update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//Fast update 2 initialization
void EPD_HW_Init_Fast2(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//Fast 2 display
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(*datas);
datas++;
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Fast();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 128
#define EPD_HEIGHT 250
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Fast2(void);
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,150 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 0 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(24,72+32*0,Num[i], //x-A,y-A,DATA-A
24,72+32*1,Num[0], //x-B,y-B,DATA-B
24,72+32*2,gImage_numdot, //x-C,y-C,DATA-C
24,72+32*3,Num[0], //x-D,y-D,DATA-D
24,72+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,250 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
///////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,23 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 128
#define EPD_HEIGHT 250
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,109 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,438 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
unsigned char oldData[2888];
unsigned char oldDataP[256];
unsigned char oldDataA[256];
unsigned char oldDataB[256];
unsigned char oldDataC[256];
unsigned char oldDataD[256];
unsigned char oldDataE[256];
unsigned char partFlag=1;
void lcd_chkstatus(void)
{
while(isEPD_W21_BUSY==0);
}
//UC8151D
void EPD_Init(void)
{
unsigned char i;
for(i=0;i<3;i++)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
}
lcd_chkstatus();
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0x1f); //LUT from OTP£¬KW-BF KWR-AF BWROTP 0f BWOTP 1f
EPD_W21_WriteDATA(0x0D);
EPD_W21_WriteCMD(0x61); //resolution setting
EPD_W21_WriteDATA (EPD_WIDTH);
EPD_W21_WriteDATA (EPD_HEIGHT/256);
EPD_W21_WriteDATA (EPD_HEIGHT%256);
EPD_W21_WriteCMD(0x04);
lcd_chkstatus();//waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
const unsigned char 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 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 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 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 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, };
void lut1(void)
{
unsigned int count;
EPD_W21_WriteCMD(0x20);
for(count=0;count<44;count++)
{EPD_W21_WriteDATA(lut_vcom1[count]);}
EPD_W21_WriteCMD(0x21);
for(count=0;count<42;count++)
{EPD_W21_WriteDATA(lut_ww1[count]);}
EPD_W21_WriteCMD(0x22);
for(count=0;count<42;count++)
{EPD_W21_WriteDATA(lut_bw1[count]);}
EPD_W21_WriteCMD(0x23);
for(count=0;count<42;count++)
{EPD_W21_WriteDATA(lut_wb1[count]);}
EPD_W21_WriteCMD(0x24);
for(count=0;count<42;count++)
{EPD_W21_WriteDATA(lut_bb1[count]);}
}
void EPD_Init_Part(void)
{
unsigned char i;
for(i=0;i<3;i++)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
}
lcd_chkstatus();
EPD_W21_WriteCMD(0x01); //POWER SETTING
EPD_W21_WriteDATA (0x03);
EPD_W21_WriteDATA (0x00);
EPD_W21_WriteDATA (0x2b);
EPD_W21_WriteDATA (0x2b);
EPD_W21_WriteDATA (0x03);
EPD_W21_WriteCMD(0x06); //boost soft start
EPD_W21_WriteDATA (0x17); //A
EPD_W21_WriteDATA (0x17); //B
EPD_W21_WriteDATA (0x17); //C
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0xbf); //LUT from OTP£¬128x296
EPD_W21_WriteDATA(0x0D);
EPD_W21_WriteCMD(0x30);
EPD_W21_WriteDATA (0x3C); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
EPD_W21_WriteCMD(0x61); //resolution setting
EPD_W21_WriteDATA (EPD_WIDTH);
EPD_W21_WriteDATA (EPD_HEIGHT/256);
EPD_W21_WriteDATA (EPD_HEIGHT%256);
EPD_W21_WriteCMD(0x82); //vcom_DC setting
EPD_W21_WriteDATA (0x12);
lut1();
EPD_W21_WriteCMD(0x04);
lcd_chkstatus();
}
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0xf7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
delay_xms(100); //!!!The delay here is necessary,100mS at least!!!
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
//Full screen update update function
void EPD_Update(void)
{
//update
EPD_W21_WriteCMD(0x12); //DISPLAY update
delay_xms(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
}
EPD_Update();
}
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF);
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
oldData[i]=0xFF;
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldData[i]=datas[i];
}
EPD_Update();
}
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start/256);
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256); //y-end
EPD_W21_WriteDATA (0x28);
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM
if(partFlag==1)
{
partFlag=0;
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldData[i]=datas[i];
}
EPD_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
EPD_Init_Part();
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
oldData[i]=datas[i];
}
EPD_Update();
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN*num-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start/256);
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256); //y-end
EPD_W21_WriteDATA (0x28);
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM
if(partFlag==1)
{
partFlag=0;
for(i=0;i<PART_COLUMN*PART_LINE*num/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataA[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataB[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataC[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataD[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataE[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_A[i]);
oldDataA[i]=datas_A[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_B[i]);
oldDataB[i]=datas_B[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_C[i]);
oldDataC[i]=datas_C[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_D[i]);
oldDataD[i]=datas_D[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_E[i]);
oldDataE[i]=datas_E[i];
}
EPD_Update();
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
EPD_Dis_Part_RAM(x_start,y_start,datas_A,datas_B,datas_C,datas_D,datas_E,num,PART_COLUMN,PART_LINE);
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
unsigned char i;
for(i=0;i<3;i++)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
}
lcd_chkstatus();
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0x13); //LUT from OTP£¬KW-BF KWR-AF BWROTP 0f BWOTP 1f
EPD_W21_WriteDATA(0x0D);
EPD_W21_WriteCMD(0x61); //resolution setting
EPD_W21_WriteDATA (EPD_WIDTH);
EPD_W21_WriteDATA (EPD_HEIGHT/256);
EPD_W21_WriteDATA (EPD_HEIGHT%256);
EPD_W21_WriteCMD(0x04);
lcd_chkstatus();//waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x10);
for (j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(0xff);
}
}
EPD_W21_WriteCMD(0x13);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,30 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 112
#define EPD_HEIGHT 208
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_Init_Part(void);
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE);
//GUI display
void EPD_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,143 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
{
EPD_Dis_Part_Time(48,46,Num[i],Num[0],gImage_numdot,Num[0],Num[1],5,24,32); //x,y,DATA-A~E,number,Resolution 24*32
}
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_Dis_PartAll(gImage_p1);
EPD_Dis_PartAll(gImage_p2);
EPD_Dis_PartAll(gImage_p3);
EPD_Dis_PartAll(gImage_p4);
EPD_Dis_PartAll(gImage_p5);
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 25, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 45, 123456789, &Font16, BLACK, WHITE); //Font16
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,600 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//Fast update 2 initialization
void EPD_HW_Init_Fast2(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//Fast 2 display
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(*datas);
datas++;
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Fast();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 152
#define EPD_HEIGHT 296
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Fast2(void);
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,152 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(48,92+32*0,Num[i], //x-A,y-A,DATA-A
48,92+32*1,Num[0], //x-B,y-B,DATA-B
48,92+32*2,gImage_numdot, //x-C,y-C,DATA-C
48,92+32*3,Num[0], //x-D,y-D,DATA-D
48,92+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 95, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 115, 123456789, &Font20, BLACK, WHITE); //Font20
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,568 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x6E);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF4);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//4 Gray update function
void EPD_Update_4G(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xCF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Basemap update function
void EPD_Update_Basemap(void)
{
EPD_W21_WriteCMD(0x22); //start update image
EPD_W21_WriteDATA(0xF4); // MCU send LUT
EPD_W21_WriteCMD(0x20); // Run
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x3C);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0x3C); //1C
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Basemap();
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
/*
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
*/
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(tempOriginal);
}
EPD_Update_4G();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,39 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 184
#define EPD_HEIGHT 360
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,150 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(64,132+32*0,Num[i], //x-A,y-A,DATA-A
64,132+32*1,Num[0], //x-B,y-B,DATA-B
64,132+32*2,gImage_numdot, //x-C,y-C,DATA-C
64,132+32*3,Num[0], //x-D,y-D,DATA-D
64,132+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 95, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 115, 123456789, &Font20, BLACK, WHITE); //Font20
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,532 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C);
EPD_W21_WriteDATA(0x05);
//4 Gray
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x11); // Data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,40 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 176
#define EPD_HEIGHT 264
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,150 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(1s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updatees, implement a full screen update to clear the ghosting caused by partial updatees.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(64,56+32*0,Num[i], //x-A,y-A,DATA-A
64,56+32*1,Num[0], //x-B,y-B,DATA-B
64,56+32*2,gImage_numdot, //x-C,y-C,DATA-C
64,56+32*3,Num[0], //x-D,y-D,DATA-D
64,56+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updatees, implement a full screen update to clear the ghosting caused by partial updatees.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,516 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
}
//Fast update 1 initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+32-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 176
#define EPD_HEIGHT 264
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Fast2(void);
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,150 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(48,48+32*0,Num[i], //x-A,y-A,DATA-A
48,48+32*1,Num[0], //x-B,y-B,DATA-B
48,48+32*2,gImage_numdot, //x-C,y-C,DATA-C
48,48+32*3,Num[0], //x-D,y-D,DATA-D
48,48+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 70, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 80, 123456789, &Font12, BLACK, WHITE); //Font12
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,559 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen refresh initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast refresh 1 initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x6E);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen refresh update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF4);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast refresh 1 update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//4 Gray update function
void EPD_Update_4G(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xCF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial refresh update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xDF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen refresh display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Fast refresh display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial refresh of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Partial refresh display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial refresh display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial refresh write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x01);//Show mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT+46-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_W21_WriteCMD(0x26);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(tempOriginal);
}
EPD_Update_4G();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,42 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 168
#define EPD_HEIGHT 384
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Fast2(void);
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
void EPD_Update_4G(void);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,147 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode(2s)*******************/
#if 1 //To enable this feature, please change 0 to 1
/************Onder versions do not support this feature*******************/
EPD_HW_Init_4G(); //Fast update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(32,92+32*0,Num[i], //x-A,y-A,DATA-A
32,92+32*1,Num[0], //x-B,y-B,DATA-B
32,92+32*2,gImage_numdot, //x-C,y-C,DATA-C
32,92+32*3,Num[0], //x-D,y-D,DATA-D
32,92+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 80, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 90, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 105, 123456789, &Font16, BLACK, WHITE); //Font16
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,600 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x64);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10); //At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//Fast update 2 initialization
void EPD_HW_Init_Fast2(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//Fast 2 display
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(*datas);
datas++;
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update_Fast();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0xB1);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_Fast();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,41 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 128
#define EPD_HEIGHT 296
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Fast2(void);
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,151 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 0 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(32,92+32*0,Num[i], //x-A,y-A,DATA-A
32,92+32*1,Num[0], //x-B,y-B,DATA-B
32,92+32*2,gImage_numdot, //x-C,y-C,DATA-C
32,92+32*3,Num[0], //x-D,y-D,DATA-D
32,92+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 80, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 90, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 105, 123456789, &Font16, BLACK, WHITE); //Font16
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,438 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
unsigned char oldData[12480];
unsigned char oldDataP[256];
unsigned char oldDataA[256];
unsigned char oldDataB[256];
unsigned char oldDataC[256];
unsigned char oldDataD[256];
unsigned char oldDataE[256];
unsigned char partFlag=1;
void lcd_chkstatus(void)
{
while(!isEPD_W21_BUSY); //0:BUSY, 1:FREE
}
//UC8253
void EPD_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00); // panel setting PSR
EPD_W21_WriteDATA(0x1F); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N 0xFF=LUT from register,0xDF=LUT from OTP. (Default)
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
void EPD_Init_Fast(void) //1.0s
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00); // panel setting PSR
EPD_W21_WriteDATA(0x1F); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N 0xFF=LUT from register,0xDF=LUT from OTP. (Default)
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5A);
}
void EPD_init_Fast2(void) //1.5s
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00); // panel setting PSR
EPD_W21_WriteDATA(0x1F); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N 0xFF=LUT from register,0xDF=LUT from OTP. (Default)
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x6E);
}
void EPD_Init_Part(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00); // panel setting PSR
EPD_W21_WriteDATA(0x1F); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N 0xFF=LUT from register,0xDF=LUT from OTP. (Default)
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x79);
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xD7);
}
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
delay(100);//At least 100ms delay
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
void Power_off(void)
{
EPD_W21_WriteCMD(0x02); //POWER ON
lcd_chkstatus();
}
//Full screen refresh update function
void EPD_Update(void)
{
//Refresh
EPD_W21_WriteCMD(0x12); //DISPLAY REFRESH
delay(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
oldData[i]=datas[i];
}
EPD_Update();
Power_off();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
oldData[i]=0xff;
}
EPD_Update();
Power_off();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
oldData[i]=0x00;
}
EPD_Update();
Power_off();
}
//Partial refresh of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldData[i]=datas[i];
}
EPD_Update();
Power_off();
}
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start/256);
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256); //y-end
EPD_W21_WriteDATA (0x01);
if(partFlag==1)
{
partFlag=0;
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataP[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldDataP[i]=datas[i];
}
EPD_Update();
Power_off();
}
//Full screen partial refresh display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
EPD_Init_Part();
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
oldData[i]=datas[i];
}
EPD_Update();
Power_off();
}
//Partial refresh write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,j,x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE*num-1;
y_end=y_start+PART_COLUMN-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start/256);
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256); //y-end
EPD_W21_WriteDATA (0x01);
if(partFlag==1)
{
partFlag=0;
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE*num/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN;i++)
{
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(oldDataA[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(oldDataB[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(oldDataC[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(oldDataD[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(oldDataE[i*PART_LINE/8+j]);
}
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN;i++)
{
for(j=0;j<PART_LINE/8;j++)
{
EPD_W21_WriteDATA(datas_A[i*PART_LINE/8+j]);
oldDataA[i*PART_LINE/8+j]=datas_A[i*PART_LINE/8+j];
}
for(j=0;j<PART_LINE/8;j++)
{
EPD_W21_WriteDATA(datas_B[i*PART_LINE/8+j]);
oldDataB[i*PART_LINE/8+j]=datas_B[i*PART_LINE/8+j];
}
for(j=0;j<PART_LINE/8;j++)
{
EPD_W21_WriteDATA(datas_C[i*PART_LINE/8+j]);
oldDataC[i*PART_LINE/8+j]=datas_C[i*PART_LINE/8+j];
}
for(j=0;j<PART_LINE/8;j++)
{
EPD_W21_WriteDATA(datas_D[i*PART_LINE/8+j]);
oldDataD[i*PART_LINE/8+j]=datas_D[i*PART_LINE/8+j];
}
for(j=0;j<PART_LINE/8;j++)
{
EPD_W21_WriteDATA(datas_E[i*PART_LINE/8+j]);
oldDataE[i*PART_LINE/8+j]=datas_E[i*PART_LINE/8+j];
}
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
EPD_Dis_Part_RAM(x_start,y_start,datas_A,datas_B,datas_C,datas_D,datas_E,num,PART_COLUMN,PART_LINE);
EPD_Update();
Power_off();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x13); //180 mirror
EPD_W21_WriteCMD(0x04); //POWER ON
delay(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
//GUI display
//GUI
void EPD_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x13);
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x10);
for (j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(oldData[j*Width+i]);
}
}
EPD_W21_WriteCMD(0x13);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[j*Width+i]); //Transfer the actual displayed data
oldData[i]=Image[i];
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,35 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 240
#define EPD_HEIGHT 320
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_Init_Part(void);
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE);
//Fast update display
void EPD_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//GUI
void EPD_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,149 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
{
EPD_Dis_Part_Time(40,150,Num[1],Num[0],gImage_numdot,Num[0],Num[i],5,64,32); //x,y,DATA-A~E,number,Resolution 32*64
}
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_Dis_PartAll(gImage_p1);
EPD_Dis_PartAll(gImage_p2);
EPD_Dis_PartAll(gImage_p3);
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 90, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(150, 90, 30, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(200, 90, 30, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_Init_GUI(); //Full screen updateinitialization.
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawString_EN(0, 70, "Good Display", &Font24, BLACK, WHITE); //Font24
Paint_DrawNum(0, 100, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 110, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 125, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 145, 123456789, &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 170, 123456789, &Font24, BLACK, WHITE); //Font24
EPD_Init_GUI(); //Full screen updateinitialization.
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,518 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
unsigned char oldData[12480];
unsigned char oldDataP[256];
unsigned char oldDataA[256];
unsigned char oldDataB[256];
unsigned char oldDataC[256];
unsigned char oldDataD[256];
unsigned char oldDataE[256];
unsigned char partFlag=1;
void lcd_chkstatus(void)
{
while(!isEPD_W21_BUSY); //0:BUSY, 1:FREE
}
//UC8253
void EPD_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
void EPD_Init_Fast(void) //1.5s
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5F); //0x5F--1.5s
}
void EPD_Init_Part(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x6E);
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xD7);
}
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
void Power_off(void)
{
EPD_W21_WriteCMD(0x02); //POWER ON
lcd_chkstatus();
}
//Full screen update update function
void EPD_Update(void)
{
//update
EPD_W21_WriteCMD(0x12); //DISPLAY update
delay(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
oldData[i]=datas[i];
}
EPD_Update();
Power_off();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
oldData[i]=0xff;
}
EPD_Update();
Power_off();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
oldData[i]=0x00;
}
EPD_Update();
Power_off();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldData[i]=datas[i];
}
EPD_Update();
Power_off();
}
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start/256);
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256); //y-end
EPD_W21_WriteDATA (0x01);
if(partFlag==1)
{
partFlag=0;
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataP[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
oldDataP[i]=datas[i];
}
EPD_Update();
Power_off();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
EPD_Init_Part();
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(oldData[i]); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
oldData[i]=datas[i];
}
EPD_Update();
Power_off();
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,x_end,y_end;
x_start=x_start-x_start%8;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN*num-1;
EPD_Init_Part();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start); //x-start
EPD_W21_WriteDATA (x_end); //x-end
EPD_W21_WriteDATA (y_start/256);
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256); //y-end
EPD_W21_WriteDATA (0x01);
if(partFlag==1)
{
partFlag=0;
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE*num/8;i++)
EPD_W21_WriteDATA(0xFF);
}
else
{
EPD_W21_WriteCMD(0x10); //writes Old data to SRAM for programming
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataA[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataB[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataC[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataD[i]);
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
EPD_W21_WriteDATA(oldDataE[i]);
}
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
{
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_A[i]);
oldDataA[i]=datas_A[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_B[i]);
oldDataB[i]=datas_B[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_C[i]);
oldDataC[i]=datas_C[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_D[i]);
oldDataD[i]=datas_D[i];
}
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas_E[i]);
oldDataE[i]=datas_E[i];
}
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
EPD_Dis_Part_RAM(x_start,y_start,datas_A,datas_B,datas_C,datas_D,datas_E,num,PART_COLUMN,PART_LINE);
EPD_Update();
Power_off();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x1B); //180 mirror
EPD_W21_WriteCMD(0x04); //POWER ON
delay(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
//4 grayscale demo function
void EPD_Init_4G(void) //
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x1F);
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5A); //0x5A--4 Gray
}
/********Color display description
white gray1 gray2 black
0x10| 01 01 00 00
0x13| 01 00 01 00
****************/
void EPD_WhiteScreen_ALL_4G (const unsigned char *datas)
{
unsigned int i,j,k;
unsigned char temp1,temp2,temp3;
//old data
EPD_W21_WriteCMD(0x10);
for(i=0;i<12480;i++) //12480*2 416*240
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = datas[i*2+j];
for(k=0;k<4;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 if(temp2 == 0x40)
temp3 |= 0x00; //gray2
if(j==0)
{
temp1 <<= 2;
temp3 <<= 1;
}
if(j==1&&k!=3)
{
temp1 <<= 2;
temp3 <<= 1;
}
}
}
EPD_W21_WriteDATA(temp3);
}
//new data
EPD_W21_WriteCMD(0x13);
for(i=0;i<12480;i++) //12480*2 416*240
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = datas[i*2+j];
for(k=0;k<4;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 if(temp2 == 0x40)
temp3 |= 0x01; //gray2
if(j==0)
{
temp1 <<= 2;
temp3 <<= 1;
}
if(j==1&&k!=3)
{
temp1 <<= 2;
temp3 <<= 1;
}
}
}
EPD_W21_WriteDATA(temp3);
}
//update
EPD_Update();
Power_off();
}
//GUI display
//GUI
void EPD_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x13);
EPD_W21_WriteCMD(0x04); //Power on
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x10);
for (j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(oldData[j*Width+i]);
}
}
EPD_W21_WriteCMD(0x13);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[j*Width+i]); //Transfer the actual displayed data
oldData[i]=Image[i];
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,37 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 240
#define EPD_HEIGHT 416
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_Init_Part(void);
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE);
//Fast update display
void EPD_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_Init_4G(void);
void EPD_WhiteScreen_ALL_4G (const unsigned char *datas);
//GUI
void EPD_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,155 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
EPD_Init_4G(); //Fast update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
{
EPD_Dis_Part_Time(100,120,Num[1],Num[0],gImage_numdot,Num[0],Num[i],5,32,64); //x,y,DATA-A~E,number,Resolution 32*64
}
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_Dis_PartAll(gImage_p1);
EPD_Dis_PartAll(gImage_p2);
EPD_Dis_PartAll(gImage_p3);
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 90, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(150, 90, 30, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(200, 90, 30, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_Init_GUI(); //Full screen updateinitialization.
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawString_EN(0, 70, "Good Display", &Font24, BLACK, WHITE); //Font24
Paint_DrawNum(0, 100, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(0, 110, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(0, 125, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(0, 145, 123456789, &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(0, 170, 123456789, &Font24, BLACK, WHITE); //Font24
EPD_Init_GUI(); //Full screen updateinitialization.
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,682 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x03);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x03);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
//Fast(1.5s)
EPD_W21_WriteCMD(0x1A);
EPD_W21_WriteDATA(0x6A);
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x03);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
//4 Gray
EPD_W21_WriteCMD(0x1A);
EPD_W21_WriteDATA(0x5A);
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xD7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//4 Gray update function
void EPD_Update_4G(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xD7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start-x_start%8; //x address start
x_end=x_start+PART_LINE-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
//Reset
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x80);
//
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteDATA(x_end%256); //x address end2
EPD_W21_WriteDATA(x_end/256); //x address end1
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
//Reset
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x80);
//
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start-x_start%8; //x address start
x_end=x_start+PART_LINE-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
//Reset
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x80);
//
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteDATA(x_end%256); //x address end2
EPD_W21_WriteDATA(x_end/256); //x address end1
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x00); //180
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02); //mirror
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/*********************4 Gray****************************/
//4 Gray display
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
// delay_us(5) ;
}
return outdata;
}
unsigned char In2bytes_Out1byte_RAM2(unsigned char data1,unsigned char data2)
{
unsigned int i;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=data1;
TempData2=data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char tempOriginal;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
tempOriginal= In2bytes_Out1byte_RAM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(~tempOriginal);
}
EPD_Update_4G();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,38 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 480
#define EPD_HEIGHT 800
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
#endif

View file

@ -0,0 +1,154 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(152,92+32*0,Num[i], //x-A,y-A,DATA-A
152,92+32*1,Num[0], //x-B,y-B,DATA-B
152,92+32*2,gImage_numdot, //x-C,y-C,DATA-C
152,92+32*3,Num[0], //x-D,y-D,DATA-D
152,92+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 0, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
//Line
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1);
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1);
Paint_DrawLine(170, 15, 170, 55, BLACK, LINE_STYLE_DOTTED, DOT_PIXEL_1X1);
Paint_DrawLine(150, 35, 190, 35, BLACK, LINE_STYLE_DOTTED, DOT_PIXEL_1X1);
//Rectangle
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1);
//Circle
Paint_DrawCircle(150, 200, 100, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
Paint_DrawCircle(250, 200, 100, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1);
EPD_HW_Init_GUI(); //EPD init GUI
EPD_WhiteScreen_ALL(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawString_EN(0, 70, "Good Display", &Font24, BLACK, WHITE); //Font24
Paint_DrawNum(220, 200, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(220, 210, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(220, 225, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(220, 245, 123456789, &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(220, 270, 123456789, &Font24, BLACK, WHITE); //Font24
EPD_HW_Init_GUI(); //EPD init GUI
EPD_WhiteScreen_ALL(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,145 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
void lcd_chkstatus(void)
{
while(isEPD_W21_BUSY==0);
}
//UC8276
void EPD_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
lcd_chkstatus();
EPD_W21_WriteCMD(0x04);
lcd_chkstatus();//waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0x1f); //LUT from OTP£¬KW-BF KWR-AF BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0x61); //resolution setting
EPD_W21_WriteDATA (EPD_WIDTH/256);
EPD_W21_WriteDATA (EPD_WIDTH%256);
EPD_W21_WriteDATA (EPD_HEIGHT/256);
EPD_W21_WriteDATA (EPD_HEIGHT%256);
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
delay_xms(100); //!!!The delay here is necessary,100mS at least!!!
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
//Full screen update function
void EPD_Update(void)
{
//update
EPD_W21_WriteCMD(0x12); //DISPLAY update
delay_xms(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]); //Transfer the actual displayed data
}
EPD_Update();
}
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<15000;i++)
{
EPD_W21_WriteDATA(0xFF);
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<15000;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
}
//update
EPD_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10);//At least 10ms delay
lcd_chkstatus();
EPD_W21_WriteCMD(0x04);
lcd_chkstatus();//waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0x00); //panel setting
EPD_W21_WriteDATA(0x13); //LUT from OTP£¬KW-BF KWR-AF BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0x61); //resolution setting
EPD_W21_WriteDATA (EPD_WIDTH/256);
EPD_W21_WriteDATA (EPD_WIDTH%256);
EPD_W21_WriteDATA (EPD_HEIGHT/256);
EPD_W21_WriteDATA (EPD_HEIGHT%256);
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10); //Transfer old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //Transfer the actual displayed data
}
EPD_W21_WriteCMD(0x13); //Transfer new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(Image[i]); //Transfer the actual displayed data
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,22 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 400
#define EPD_HEIGHT 300
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_DeepSleep(void);
void EPD_Update(void);
void lcd_chkstatus(void);
void EPD_WhiteScreen_White(void);
void EPD_Init_180(void);
//GUI
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,115 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_2); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 0, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
//Line
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1);
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1);
Paint_DrawLine(170, 15, 170, 55, BLACK, LINE_STYLE_DOTTED, DOT_PIXEL_1X1);
Paint_DrawLine(150, 35, 190, 35, BLACK, LINE_STYLE_DOTTED, DOT_PIXEL_1X1);
//Rectangle
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1);
//Circle
Paint_DrawCircle(150, 200, 100, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
Paint_DrawCircle(250, 200, 100, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1);
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawString_EN(0, 70, "Good Display", &Font24, BLACK, WHITE); //Font24
Paint_DrawNum(220, 200, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(220, 210, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(220, 225, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(220, 245, 123456789, &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(220, 270, 123456789, &Font24, BLACK, WHITE); //Font24
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,515 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x03);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x03);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
//TEMP (1.5s)
EPD_W21_WriteCMD(0x1A);
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteCMD(0x22);
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start-x_start%8; //x address start
x_end=x_start+PART_LINE-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
//Reset
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x80);
//
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteDATA(x_end%256); //x address end2
EPD_W21_WriteDATA(x_end/256); //x address end1
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
//Reset
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x80);
//
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start-x_start%8; //x address start
x_end=x_start+PART_LINE-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
//Reset
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x80);
//
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteDATA(x_end%256); //x address end2
EPD_W21_WriteDATA(x_end/256); //x address end1
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start%256); //x address start2
EPD_W21_WriteDATA(x_start/256); //x address start1
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x00); //180
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x18);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x0C);
EPD_W21_WriteDATA(0xAE);
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteDATA(0xC3);
EPD_W21_WriteDATA(0xC0);
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02); //mirror
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_WIDTH-1)%256);
EPD_W21_WriteDATA((EPD_WIDTH-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,38 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 480
#define EPD_HEIGHT 800
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,142 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 0 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(320,124+48*0, Num[1], //x-A,y-A,DATA-A
320,124+48*1, Num[0], //x-B,y-B,DATA-B
320,124+48*2, gImage_numdot, //x-C,y-C,DATA-C
320,124+48*3, Num[0], //x-D,y-D,DATA-D
320,124+48*4,Num[i],48,104); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_HEIGHT, EPD_WIDTH, 90, WHITE); //(is differrent!!!)Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(150, 200, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(250,200, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //5*8.
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //7*12.
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //11*16.
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //14*20.
Paint_DrawString_EN(0, 80, "Good Display", &Font24, BLACK, WHITE); //17*24.
Paint_DrawNum(200, 200, 123456789, &Font8, BLACK, WHITE); //5*8.
Paint_DrawNum(200, 210, 123456789, &Font12, BLACK, WHITE); //7*12.
Paint_DrawNum(200, 225, 123456789, &Font16, BLACK, WHITE); //11*16.
Paint_DrawNum(200, 245, 123456789, &Font20, BLACK, WHITE); //14*20.
Paint_DrawNum(200, 270, 123456789, &Font24, BLACK, WHITE); //17*24.
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,659 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
//Busy function
void Epaper_READBUSY(void)
{
while(1)
{ //=1 BUSY
if(isEPD_W21_BUSY==0) break;
}
}
//Full screen update initialization
void EPD_HW_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x40);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//Fast update initialization
void EPD_HW_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x21);
EPD_W21_WriteDATA(0x40);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C);
EPD_W21_WriteDATA(0x05);
//1.5s
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x6E);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x11); // Data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update function
void EPD_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xF7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Fast update function
void EPD_Update_Fast(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xC7);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//4 Gray update function
void EPD_Update_4G(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xCF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//Partial update function
void EPD_Part_Update(void)
{
EPD_W21_WriteCMD(0x22); //Display Update Control
EPD_W21_WriteDATA(0xFF);
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
Epaper_READBUSY();
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update_Fast();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_W21_WriteCMD(0x26); //Write Black and White image to RAM
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x21);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256);//y address start2
EPD_W21_WriteDATA(y_start/256);//y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int PART_COLUMN, PART_LINE;
PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x21);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Part_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0x10); //Enter deep sleep
EPD_W21_WriteDATA(0x01);
delay_xms(100);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x21);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom,
EPD_W21_WriteDATA(0x80);
EPD_W21_WriteCMD(0x44); // set RAM x address start/end
EPD_W21_WriteDATA(x_start); //x address start
EPD_W21_WriteDATA(x_end); //y address end
EPD_W21_WriteCMD(0x45); // set RAM y address start/end
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteDATA(y_end%256); //y address end2
EPD_W21_WriteDATA(y_end/256); //y address end1
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(x_start); //x start address
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X127;
EPD_W21_WriteDATA(y_start%256); //y address start2
EPD_W21_WriteDATA(y_start/256); //y address start1
EPD_W21_WriteCMD(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
)
{
EPD_Dis_Part_RAM(x_startA,y_startA,datasA,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startB,y_startB,datasB,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startC,y_startC,datasC,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startD,y_startD,datasD,PART_COLUMN,PART_LINE);
EPD_Dis_Part_RAM(x_startE,y_startE,datasE,PART_COLUMN,PART_LINE);
EPD_Part_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_HW_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10); //At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x40);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
Epaper_READBUSY();
}
// GUI initialization
void EPD_HW_Init_GUI(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
Epaper_READBUSY();
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x01); //Driver output control
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x01); //mirror
EPD_W21_WriteCMD(0x21); // Display update control
EPD_W21_WriteDATA(0x40);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x3C); //BorderWavefrom
EPD_W21_WriteDATA(0x05);
EPD_W21_WriteCMD(0x11); //data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
Width = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
Height = EPD_HEIGHT;
EPD_W21_WriteCMD(0x24);
for ( j = 0; j < Height; j++) {
for ( i = 0; i < Width; i++) {
EPD_W21_WriteDATA(Image[i + j * Width]);
}
}
EPD_Update();
}
//4 Gray update initialization
void EPD_HW_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x12); //SWRESET
Epaper_READBUSY();
EPD_W21_WriteCMD(0x3C);
EPD_W21_WriteDATA(0x05);
//4 Gray
EPD_W21_WriteCMD(0x1A); // Write to temperature register
EPD_W21_WriteDATA(0x5A);
EPD_W21_WriteCMD(0x22); // Load temperature value
EPD_W21_WriteDATA(0x91);
EPD_W21_WriteCMD(0x20);
Epaper_READBUSY();
EPD_W21_WriteCMD(0x11); // Data entry mode
EPD_W21_WriteDATA(0x01);
EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(EPD_WIDTH/8-1);
EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
Epaper_READBUSY();
}
unsigned char R24_DTM1(unsigned char Image_data1,unsigned char Image_data2)
{
unsigned int i,all;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=Image_data1;
TempData2=Image_data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x40))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(all=0;all<4;all++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x40)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
unsigned char R26_DTM2(unsigned char Image_data1,unsigned char Image_data2)
{
unsigned int i,all;
unsigned char TempData1,TempData2;
unsigned char outdata=0x00;
TempData1=Image_data1;
TempData2=Image_data2;
for(i=0;i<4;i++)
{
outdata=outdata<<1;
if( ((TempData1&0xC0)==0xC0) || ((TempData1&0xC0)==0x80))
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData1=TempData1<<2;
}
for(all=0;all<4;all++)
{
outdata=outdata<<1;
if((TempData2&0xC0)==0xC0||(TempData2&0xC0)==0x80)
outdata=outdata|0x01;
else
outdata=outdata|0x00;
TempData2=TempData2<<2;
}
return outdata;
}
//4 Gray update display function
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i;
unsigned char value;
EPD_W21_WriteCMD(0x24); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
value= R24_DTM1( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(value);
}
EPD_W21_WriteCMD(0x26); //write RAM for black(0)/white (1)
for(i=0;i<EPD_ARRAY*2;i+=2)
{
value= R26_DTM2( *(datas+i),*(datas+i+1));
EPD_W21_WriteDATA(value);
}
EPD_Update_4G();
}
void pic_display_4line(void)
{
unsigned int i,row,col;
EPD_W21_WriteCMD(0x24); //¿ªÊ¼´«ÊäºÚ°×ͼÏñ
for(col=0;col<300;col++)
{
for(row=0;row<13;row++)
{
EPD_W21_WriteDATA(0xFF);
}
for(row=0;row<12;row++)
{
EPD_W21_WriteDATA(0x00);
}
for(row=0;row<12;row++)
{
EPD_W21_WriteDATA(0xFF);
}
for(row=0;row<13;row++)
{
EPD_W21_WriteDATA(0x00);
}
}
EPD_W21_WriteCMD(0x26); //¿ªÊ¼´«ÊäºìͼÏñ
for(col=0;col<300;col++)
{
for(row=0;row<13;row++)
{
EPD_W21_WriteDATA(0xFF);
}
for(row=0;row<12;row++)
{
EPD_W21_WriteDATA(0xFF);
}
for(row=0;row<12;row++)
{
EPD_W21_WriteDATA(0x00);
}
for(row=0;row<13;row++)
{
EPD_W21_WriteDATA(0x00);
}
}
EPD_Update_4G();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,39 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 400
#define EPD_HEIGHT 300
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_HW_Init(void);
void EPD_HW_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Fast update display
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
void pic_display_4line(void); //GUI
void EPD_HW_Init_GUI(void);
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,155 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(152,92+32*0,Num[i], //x-A,y-A,DATA-A
152,92+32*1,Num[0], //x-B,y-B,DATA-B
152,92+32*2,gImage_numdot, //x-C,y-C,DATA-C
152,92+32*3,Num[0], //x-D,y-D,DATA-D
152,92+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial update.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000);//Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 0, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
//Line
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1);
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1);
Paint_DrawLine(170, 15, 170, 55, BLACK, LINE_STYLE_DOTTED, DOT_PIXEL_1X1);
Paint_DrawLine(150, 35, 190, 35, BLACK, LINE_STYLE_DOTTED, DOT_PIXEL_1X1);
//Rectangle
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1);
//Circle
Paint_DrawCircle(150, 200, 100, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
Paint_DrawCircle(250, 200, 100, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1);
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawString_EN(0, 70, "Good Display", &Font24, BLACK, WHITE); //Font24
Paint_DrawNum(220, 200, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(220, 210, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(220, 225, 123456789, &Font16, BLACK, WHITE); //Font16
Paint_DrawNum(220, 245, 123456789, &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(220, 270, 123456789, &Font24, BLACK, WHITE); //Font24
EPD_HW_Init_GUI(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 800
#define EPD_HEIGHT 272
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
#define Source_BYTES 400/8
#define Gate_BITS 272
#define ALLSCREEN_BYTES Source_BYTES*Gate_BITS
#define NUM_LINE_BYTES 8// =64/8
#define NUM_COLUMN_BYTES 30
#define PART_LINE_BYTES 8// =64/8
#define PART_COLUMN_BYTES 150
//EPD
void Epaper_READBUSY(void);
void Epaper_Spi_WriteByte(unsigned char TxData);
void EPD_W21_WriteCMD(unsigned char cmd);
void EPD_W21_WriteDATA(unsigned char data);
void EPD_HW_Init(void); //Electronic paper initialization
void EPD_Update(void);
void EPD_Part_Init(void);//Local update initialization
void EPD_Part_Update(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_DeepSleep(void);
//Display
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_myself_M(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
void EPD_Dis_Part_myself_S(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
void EPD_Dis_Part_myself_All(unsigned int x_startA,unsigned int y_startA,const unsigned char * datasA,
unsigned int x_startB,unsigned int y_startB,const unsigned char * datasB,
unsigned int x_startC,unsigned int y_startC,const unsigned char * datasC,
unsigned int x_startD,unsigned int y_startD,const unsigned char * datasD,
unsigned int x_startE,unsigned int y_startE,const unsigned char * datasE,
unsigned int PART_COLUMN,unsigned int PART_LINE
);
//Display canvas function
void EPD_HW_Init_GUI(void); //EPD init GUI
void EPD_Display(unsigned char *Image);
void EPD_Standby(void);
void EPD_HW_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
void EPD_HW_Init_Part(void);
void EPD_Dis_Part_M(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_S(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
//4 gray
void EPD_HW_Init_4G(void);
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas);
void EPD_WhiteScreen_ALL_4line(void);
#endif

View file

@ -0,0 +1,131 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 0 //Full screen update, fast update, and partial update demostration.
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode*******************/
#if 1 //To enable this feature, please change 0 to 1
EPD_HW_Init_4G(); //4 Gray update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
for(i=0;i<6;i++)
EPD_Dis_Part_myself_S(64,80,Num[1], //x-A,y-A,DATA-A
64+48,80,Num[0], //x-B,y-B,DATA-B
64+48*2,80,gImage_numdot, //x-C,y-C,DATA-C
64+48*3,80,Num[0], //x-D,y-D,DATA-D
64+48*4,80,Num[i],104,48); //x-D,y-D,DATA-D,Resolution 104*48
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI demostration.
///////////////////////////GUI///////////////////////////////////////////////////////////////////////////////////
//Data initialization settings
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 180, WHITE); //Set screen size and display orientation
/**************Drawing**********************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
//Point.
Paint_DrawPoint(10, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(10, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(10, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(10, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 5, 50, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(50, 5, 20, 35, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 5, 50, 35, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(70, 5, 100, 35, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(30, 50, 10, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(80, 50, 10, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_HW_Init(); //EPD init GUI
EPD_Display(ImageBW);//display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
/***********String&Number***************************/
Paint_SelectImage(ImageBW);//Set the virtual canvas data storage location
Paint_Clear(WHITE);
Paint_DrawString_EN(10, 0, "Good Display", &Font8, BLACK, WHITE); //Font8
Paint_DrawString_EN(10, 10, "Good Display", &Font12, BLACK, WHITE); //Font12
Paint_DrawString_EN(10, 25, "Good Display", &Font16, BLACK, WHITE); //Font16
Paint_DrawString_EN(10, 45, "Good Display", &Font20, BLACK, WHITE); //Font20
Paint_DrawNum(10, 80, 123456789, &Font8, BLACK, WHITE); //Font8
Paint_DrawNum(10, 90, 123456789, &Font12, BLACK, WHITE); //Font12
Paint_DrawNum(10, 105, 123456789, &Font16, BLACK, WHITE); //Font16
EPD_HW_Init(); //EPD init GUI
EPD_Display(ImageBW); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
#endif
//Clear
EPD_HW_Init(); //EPD init
EPD_WhiteScreen_White();//EPD Clear
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //2s
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,459 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
unsigned char PartImage[1000];//Define Partial canvas space
//Busy function
void lcd_chkstatus(void)
{
while(1)
{ //=0 BUSY
if(isEPD_W21_BUSY==1) break;
}
}
//Full screen update initialization
void EPD_Init(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x1F);
EPD_W21_WriteCMD(0x04); //POWER ON
delay(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x21);
EPD_W21_WriteDATA(0x07);
}
//Fast update initialization
void EPD_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x1F);
EPD_W21_WriteCMD(0x04); //POWER ON
delay(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x29);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5A);
}
//Partial update initialization
void EPD_Init_Part(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x1F);
EPD_W21_WriteCMD(0x04); //POWER ON
delay(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x6E);
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update update function
void EPD_Update(void)
{
//update
EPD_W21_WriteCMD(0x12); //DISPLAY update
delay(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xA9);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start/256);
EPD_W21_WriteDATA (x_start%256); //x-start
EPD_W21_WriteDATA (x_end/256);
EPD_W21_WriteDATA (x_end%256-1); //x-end
EPD_W21_WriteDATA (y_start/256); //
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256-1); //y-end
EPD_W21_WriteDATA (0x01);
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int x_start=0,y_start=0,x_end,y_end;
unsigned int PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xA9);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start/256);
EPD_W21_WriteDATA (x_start%256); //x-start
EPD_W21_WriteDATA (x_end/256);
EPD_W21_WriteDATA (x_end%256-1); //x-end
EPD_W21_WriteDATA (y_start/256); //
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256-1); //y-end
EPD_W21_WriteDATA (0x01);
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0xf7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
delay(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,j;
unsigned int x_end,y_end;
x_end=x_start+PART_LINE*num-1;
y_end=y_start+PART_COLUMN-1;
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xA9);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start/256);
EPD_W21_WriteDATA (x_start%256); //x-start
EPD_W21_WriteDATA (x_end/256);
EPD_W21_WriteDATA (x_end%256-1); //x-end
EPD_W21_WriteDATA (y_start/256); //
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256-1); //y-end
EPD_W21_WriteDATA (0x01);
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN;i++)
{
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_A[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_B[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_C[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_D[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_E[i*PART_LINE/8+j]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
EPD_Dis_Part_RAM(x_start,y_start,datas_A,datas_B,datas_C,datas_D,datas_E,num,PART_COLUMN,PART_LINE);
EPD_Update();
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay(10);//At least 10ms delay
EPD_W21_RST_1;
delay(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x13);
EPD_W21_WriteCMD(0x04); //POWER ON
delay(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x21);
EPD_W21_WriteDATA(0x07);
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(Image[i]);
}
EPD_Update();
}
// 4 Gray display
void EPD_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x00);
EPD_W21_WriteDATA(0x1F);
EPD_W21_WriteCMD(0x04); //POWER ON
delay_xms(300);
lcd_chkstatus();
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x21);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5F); //0x5A--1.5s, 0x5F--4 Gray
}
void EPD_WhiteScreen_ALL_4G(const unsigned char *datas)
{
unsigned int i,j,k;
unsigned char temp1,temp2,temp3;
//old data
EPD_W21_WriteCMD(0x10);
for(i=0;i<38880;i++) //38880*2 648*480
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = datas[i*2+j];
for(k=0;k<4;k++)
{
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if((temp2>=0x80)&&(temp2<0xC0))
temp3 |= 0x00; //gray1
else if(temp2 == 0x40)
temp3 |= 0x01; //gray2
if((j==0&&k<=3)||(j==1&&k<=2))
{
temp3 <<= 1;
temp1 <<= 2;
}
}
}
EPD_W21_WriteDATA(temp3);
}
//new data
EPD_W21_WriteCMD(0x13);
for(i=0;i<38880*2;i++) //38880*2 648*480
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = datas[i*2+j];
for(k=0;k<4;k++)
{
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if((temp2>=0x80)&&(temp2<0xC0))
temp3 |= 0x01; //gray1
else if(temp2 == 0x40)
temp3 |= 0x00; //gray2
if((j==0&&k<=3)||(j==1&&k<=2))
{
temp3 <<= 1;
temp1 <<= 2;
}
}
}
EPD_W21_WriteDATA(temp3);
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,36 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 648
#define EPD_HEIGHT 480
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_Init_Part(void);
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE);
//Fast update display
void EPD_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_Init_4G(void);
void EPD_WhiteScreen_ALL_4G (const unsigned char *datas);
//GUI
void EPD_Display(unsigned char *Image);
#endif

View file

@ -0,0 +1,156 @@
#include<ESP32epdx.h> //E-paper SPI etc
//EPD
#include"EPD.h" //E-paper driver
#include"IMAGE.h" //E-paper image data
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
void setup() {
/* ESP32-WROOM-32D (Using hardware SPI)
BUSYGPIO13 RESGPIO12 DCGPIO14 CSGPIO27 SCKGPIO18 SDINGPIO23 */
pinMode(13, INPUT); //BUSY
pinMode(12, OUTPUT); //RES
pinMode(14, OUTPUT); //DC
pinMode(27, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial update.
3.Please make sue that EPD enters sleep mode when update is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen update, fast update, and partial update demostration.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast update mode(1.5s)*******************/
EPD_Init_Fast(); //Fast update initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display one image using fast update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************4 Gray update mode(2s)*******************/
EPD_Init_4G(); //Fast update initialization.
EPD_WhiteScreen_ALL_4G(gImage_4G1); //To display one image using 4 gray update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#if 1 //Partial update demostration.
//Partial update demo support displaying a clock at 5 locations with 00:00. If you need to perform partial update more than 5 locations, please use the feature of using partial update at the full screen demo.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial update.
EPD_Init_Part(); //Pa update initialization.
for(i=0;i<6;i++)
{
EPD_Dis_Part_Time(200,180,Num[1],Num[0],gImage_numdot,Num[0],Num[i],5,104,48); //x,y,DATA-A~E,Resolution 48*104
}
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demo of using partial update to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial updates, implement a full screen update to clear the ghosting caused by partial updates.
//////////////////////Partial update time demo/////////////////////////////////////
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_Init_Part();
EPD_Dis_PartAll(gImage_p1);
EPD_Dis_PartAll(gImage_p2);
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#if 1 //Demonstration of full screen update with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_Init_180(); //Full screen update initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen update.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
#if 1 //GUI Demo(GUI examples can display points, lines, rectangles, circles, letters, numbers, etc).
//Data initialization settings.
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 0, WHITE); //Set canvas parameters, GUI image rotation, please change 0 to 0/90/180/270.
Paint_SelectImage(ImageBW); //Select current settings.
/**************Drawing demonstration**********************/
Paint_Clear(WHITE); //Clear canvas.
//Point.
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT); //point 1x1.
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT); //point 2x2.
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT); //point 3x3.
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT); //point 4x4.
//Line.
Paint_DrawLine(20, 10, 70, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 1.
Paint_DrawLine(70, 10, 20, 60, BLACK, LINE_STYLE_SOLID, DOT_PIXEL_1X1); //1x1line 2.
//Rectangle.
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow rectangle 1.
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //Hollow rectangle 2.
//Circle.
Paint_DrawCircle(150, 90, 30, BLACK, DRAW_FILL_EMPTY, DOT_PIXEL_1X1); //Hollow circle.
Paint_DrawCircle(200, 90, 30, BLACK, DRAW_FILL_FULL, DOT_PIXEL_1X1); //solid circle.
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW); //Display GUI image.
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //Delay for 2s.
/***********Letter demo***************************/
Paint_Clear(WHITE); //Clear canvas.
Paint_DrawString_EN(0, 0, "Good Display", &Font8, BLACK, WHITE); //5*8.
Paint_DrawString_EN(0, 10, "Good Display", &Font12, BLACK, WHITE); //7*12.
Paint_DrawString_EN(0, 25, "Good Display", &Font16, BLACK, WHITE); //11*16.
Paint_DrawString_EN(0, 45, "Good Display", &Font20, BLACK, WHITE); //14*20.
Paint_DrawString_EN(0, 80, "Good Display", &Font24, BLACK, WHITE); //17*24.
Paint_DrawNum(0, 120, 123456789, &Font8, BLACK, WHITE); //5*8.
Paint_DrawNum(0, 130, 123456789, &Font12, BLACK, WHITE); //7*12.
Paint_DrawNum(0, 155, 123456789, &Font16, BLACK, WHITE); //11*16.
Paint_DrawNum(0, 175, 123456789, &Font20, BLACK, WHITE); //14*20.
Paint_DrawNum(0, 210, 123456789, &Font24, BLACK, WHITE); //17*24.
EPD_Init(); //Full screen update initialization.
EPD_Display(ImageBW);//Display GUI image.
EPD_DeepSleep(); //EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
delay(2000); //Delay for 2s.
#endif
//Clear
EPD_Init(); //Full screen update initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
while(1); // The program stops here
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,600 @@
#include <EPD_SPI.h>
#include "EPD.h"
//Delay Functions
void delay_xms(unsigned int xms)
{
delay(xms);
}
////////////////////////////////////E-paper demo//////////////////////////////////////////////////////////
unsigned char PartImage[1000];//Define Partial canvas space
//Busy function
void lcd_chkstatus(void)
{
while(1)
{ //=0 BUSY
if(isEPD_W21_BUSY==1) break;
}
}
//Full screen update initialization
void EPD_Init(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x01); //POWER SETTING
EPD_W21_WriteDATA (0x07);
EPD_W21_WriteDATA (0x07); //VGH=20V,VGL=-20V
EPD_W21_WriteDATA (0x3f); //VDH=15V
EPD_W21_WriteDATA (0x3f); //VDL=-15V
//Enhanced display drive(Add 0x06 command)
EPD_W21_WriteCMD(0x06); //Booster Soft Start
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteDATA (0x28);
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteCMD(0x04); //POWER ON
delay_xms(100);
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X00); //PANNEL SETTING
EPD_W21_WriteDATA(0x1F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0x61); //tres
EPD_W21_WriteDATA (0x03); //source 800
EPD_W21_WriteDATA (0x20);
EPD_W21_WriteDATA (0x01); //gate 480
EPD_W21_WriteDATA (0xE0);
EPD_W21_WriteCMD(0X15);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x10);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0X60); //TCON SETTING
EPD_W21_WriteDATA(0x22);
}
//Fast update 1 initialization
void EPD_Init_Fast(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0X00); //PANNEL SETTING
EPD_W21_WriteDATA(0x1F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x10);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x04); //POWER ON
delay_xms(100);
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
//Enhanced display drive(Add 0x06 command)
EPD_W21_WriteCMD(0x06); //Booster Soft Start
EPD_W21_WriteDATA (0x27);
EPD_W21_WriteDATA (0x27);
EPD_W21_WriteDATA (0x18);
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5A);
}
//Partial update initialization
void EPD_Init_Part(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0X00); //PANNEL SETTING
EPD_W21_WriteDATA(0x1F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0x04); //POWER ON
delay_xms(100);
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x6E);
}
//////////////////////////////Display Update Function///////////////////////////////////////////////////////
//Full screen update update function
void EPD_Update(void)
{
//update
EPD_W21_WriteCMD(0x12); //DISPLAY update
delay_xms(1); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
}
//////////////////////////////Display Data Transfer Function////////////////////////////////////////////
//Full screen update display function
void EPD_WhiteScreen_ALL(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Fast update display function
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Clear screen display
void EPD_WhiteScreen_White_Basemap(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //is different
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_Update();
}
//Display all black
void EPD_WhiteScreen_Black(void)
{
unsigned int i;
//Write Data
EPD_W21_WriteCMD(0x10);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x13);
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xff);
}
EPD_Update();
}
//Partial update of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap( const unsigned char * datas)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0xFF); //is different
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Partial update display
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xA9);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start/256);
EPD_W21_WriteDATA (x_start%256); //x-start
EPD_W21_WriteDATA (x_end/256);
EPD_W21_WriteDATA (x_end%256-1); //x-end
EPD_W21_WriteDATA (y_start/256); //
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256-1); //y-end
EPD_W21_WriteDATA (0x01);
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Full screen partial update display
void EPD_Dis_PartAll(const unsigned char * datas)
{
unsigned int i;
unsigned int x_start=0,y_start=0,x_end,y_end;
unsigned int PART_COLUMN=EPD_HEIGHT,PART_LINE=EPD_WIDTH;
x_end=x_start+PART_LINE-1;
y_end=y_start+PART_COLUMN-1;
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xA9);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start/256);
EPD_W21_WriteDATA (x_start%256); //x-start
EPD_W21_WriteDATA (x_end/256);
EPD_W21_WriteDATA (x_end%256-1); //x-end
EPD_W21_WriteDATA (y_start/256); //
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256-1); //y-end
EPD_W21_WriteDATA (0x01);
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
EPD_W21_WriteDATA(datas[i]);
}
EPD_Update();
}
//Deep sleep function
void EPD_DeepSleep(void)
{
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0xf7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}
//Partial update write address and data
void EPD_Dis_Part_RAM(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
unsigned int i,j;
unsigned int x_end,y_end;
x_end=x_start+PART_LINE*num-1;
y_end=y_start+PART_COLUMN-1;
EPD_W21_WriteCMD(0x50);
EPD_W21_WriteDATA(0xA9);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting
EPD_W21_WriteDATA (x_start/256);
EPD_W21_WriteDATA (x_start%256); //x-start
EPD_W21_WriteDATA (x_end/256);
EPD_W21_WriteDATA (x_end%256-1); //x-end
EPD_W21_WriteDATA (y_start/256); //
EPD_W21_WriteDATA (y_start%256); //y-start
EPD_W21_WriteDATA (y_end/256);
EPD_W21_WriteDATA (y_end%256-1); //y-end
EPD_W21_WriteDATA (0x01);
EPD_W21_WriteCMD(0x13); //writes New data to SRAM.
for(i=0;i<PART_COLUMN;i++)
{
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_A[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_B[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_C[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_D[i*PART_LINE/8+j]);
for(j=0;j<PART_LINE/8;j++)
EPD_W21_WriteDATA(datas_E[i*PART_LINE/8+j]);
}
}
//Clock display
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE)
{
EPD_Dis_Part_RAM(x_start,y_start,datas_A,datas_B,datas_C,datas_D,datas_E,num,PART_COLUMN,PART_LINE);
EPD_Update();
EPD_W21_WriteCMD(0X92); //This command makes the display exit partial mode and enter normal mode.
}
////////////////////////////////Other newly added functions////////////////////////////////////////////
//Display rotation 180 degrees initialization
void EPD_Init_180(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0x01); //POWER SETTING
EPD_W21_WriteDATA (0x07);
EPD_W21_WriteDATA (0x07); //VGH=20V,VGL=-20V
EPD_W21_WriteDATA (0x3f); //VDH=15V
EPD_W21_WriteDATA (0x3f); //VDL=-15V
//Enhanced display drive(Add 0x06 command)
EPD_W21_WriteCMD(0x06); //Booster Soft Start
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteDATA (0x28);
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteCMD(0x04); //POWER ON
delay_xms(100);
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
EPD_W21_WriteCMD(0X00); //PANNEL SETTING
EPD_W21_WriteDATA(0x13); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0x61); //tres
EPD_W21_WriteDATA (0x03); //source 800
EPD_W21_WriteDATA (0x20);
EPD_W21_WriteDATA (0x01); //gate 480
EPD_W21_WriteDATA (0xE0);
EPD_W21_WriteCMD(0X15);
EPD_W21_WriteDATA(0x00);
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x10);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0X60); //TCON SETTING
EPD_W21_WriteDATA(0x22);
}
//GUI display
void EPD_Display(unsigned char *Image)
{
unsigned int i;
EPD_W21_WriteCMD(0x10); //write old data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(0x00);
}
EPD_W21_WriteCMD(0x13); //write new data
for(i=0;i<EPD_ARRAY;i++)
{
EPD_W21_WriteDATA(~Image[i]);
}
EPD_Update();
}
// 4 Gray display
void EPD_Init_4G(void)
{
EPD_W21_RST_0; // Module reset
delay_xms(10);//At least 10ms delay
EPD_W21_RST_1;
delay_xms(10); //At least 10ms delay
EPD_W21_WriteCMD(0X00); //PANNEL SETTING
EPD_W21_WriteDATA(0x1F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_W21_WriteCMD(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_W21_WriteDATA(0x10);
EPD_W21_WriteDATA(0x07);
EPD_W21_WriteCMD(0x04); //POWER ON
delay_xms(100);
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
//Enhanced display drive(Add 0x06 command)
EPD_W21_WriteCMD(0x06); //Booster Soft Start
EPD_W21_WriteDATA (0x27);
EPD_W21_WriteDATA (0x27);
EPD_W21_WriteDATA (0x18);
EPD_W21_WriteDATA (0x17);
EPD_W21_WriteCMD(0xE0);
EPD_W21_WriteDATA(0x02);
EPD_W21_WriteCMD(0xE5);
EPD_W21_WriteDATA(0x5F); //0x5A--1.5s, 0x5F--4 Gray
}
void EPD_WhiteScreen_ALL_4G (const unsigned char *datas)
{
unsigned int i,j,k;
unsigned char temp1,temp2,temp3;
//old data
EPD_W21_WriteCMD(0x10);
for(i=0;i<48000;i++) //48000*2 800*480
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = datas[i*2+j];
for(k=0;k<4;k++)
{
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if((temp2>=0x80)&&(temp2<0xC0))
temp3 |= 0x00; //gray1
else if(temp2 == 0x40)
temp3 |= 0x01; //gray2
if((j==0&&k<=3)||(j==1&&k<=2))
{
temp3 <<= 1;
temp1 <<= 2;
}
}
}
EPD_W21_WriteDATA(~temp3);
}
//new data
EPD_W21_WriteCMD(0x13);
for(i=0;i<48000*2;i++) //48000*2 800*480
{
temp3=0;
for(j=0;j<2;j++)
{
temp1 = datas[i*2+j];
for(k=0;k<4;k++)
{
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if((temp2>=0x80)&&(temp2<0xC0))
temp3 |= 0x01; //gray1
else if(temp2 == 0x40)
temp3 |= 0x00; //gray2
if((j==0&&k<=3)||(j==1&&k<=2))
{
temp3 <<= 1;
temp1 <<= 2;
}
}
}
EPD_W21_WriteDATA(~temp3);
}
EPD_Update();
}
void Display_4Level_Gray(void)
{
unsigned int i,j;
lcd_chkstatus();
EPD_W21_WriteCMD(0x10);
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0x00);
}
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0xFF);
}
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0x00);
}
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0xFF);
}
lcd_chkstatus();
EPD_W21_WriteCMD(0x13);
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0x00);
}
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0x00);
}
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0xFF);
}
for(i=0;i<800*480/16/2;i++)
{
EPD_W21_WriteDATA(0xFF);
}
EPD_Update();
}
/***********************************************************
end file
***********************************************************/

View file

@ -0,0 +1,36 @@
#ifndef _EPD_H_
#define _EPD_H_
#define EPD_WIDTH 800
#define EPD_HEIGHT 480
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
//Full screen update display
void EPD_Init(void);
void EPD_Init_180(void);
void EPD_WhiteScreen_ALL(const unsigned char *datas);
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
//Partial update display
void EPD_Init_Part(void);
void EPD_SetRAMValue_BaseMap(const unsigned char * datas);
void EPD_Dis_PartAll(const unsigned char * datas);
void EPD_Dis_Part(unsigned int x_start,unsigned int y_start,const unsigned char * datas,unsigned int PART_COLUMN,unsigned int PART_LINE);
void EPD_Dis_Part_Time(unsigned int x_start,unsigned int y_start,
const unsigned char * datas_A,const unsigned char * datas_B,
const unsigned char * datas_C,const unsigned char * datas_D,const unsigned char * datas_E,
unsigned char num,unsigned int PART_COLUMN,unsigned int PART_LINE);
//Fast update display
void EPD_Init_Fast(void);
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
//4 Gray
void EPD_Init_4G(void);
void EPD_WhiteScreen_ALL_4G (const unsigned char *datas);
//GUI
void EPD_Display(unsigned char *Image);
#endif

Some files were not shown because too many files have changed in this diff Show more