mirror of
https://github.com/gooddisplayshare/ESP32epdx.git
synced 2026-05-19 09:15:46 +08:00
v1.0.7
This commit is contained in:
@@ -28,9 +28,6 @@ void EPD_HW_Init(void)
|
||||
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);
|
||||
@@ -111,12 +108,24 @@ void EPD_Update_Fast(void)
|
||||
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(0x1C); //1C
|
||||
EPD_W21_WriteDATA(0xDF);
|
||||
EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
|
||||
Epaper_READBUSY();
|
||||
}
|
||||
@@ -431,8 +440,8 @@ void EPD_Display(unsigned char *Image)
|
||||
}
|
||||
EPD_Update();
|
||||
}
|
||||
//Fast refresh 2 initialization
|
||||
void EPD_HW_Init_Fast2(void)
|
||||
//4 Gray update initialization
|
||||
void EPD_HW_Init_4G(void)
|
||||
{
|
||||
EPD_W21_RST_0; // Module reset
|
||||
delay_xms(10);//At least 10ms delay
|
||||
@@ -459,22 +468,90 @@ void EPD_HW_Init_Fast2(void)
|
||||
EPD_W21_WriteCMD(0x20);
|
||||
Epaper_READBUSY();
|
||||
}
|
||||
//Fast 2 display
|
||||
void EPD_WhiteScreen_ALL_Fast2(const unsigned char *datas)
|
||||
//4 Gray display
|
||||
unsigned char In2bytes_Out1byte_RAM1(unsigned char data1,unsigned char data2)
|
||||
{
|
||||
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();
|
||||
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
|
||||
|
||||
@@ -28,9 +28,10 @@ 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
|
||||
//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);
|
||||
|
||||
@@ -44,7 +44,14 @@ void loop() {
|
||||
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.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -59,7 +59,62 @@ void EPD_init(void)
|
||||
EPD_W21_WriteCMD(0x04);
|
||||
lcd_chkstatus();
|
||||
}
|
||||
//Fast full screen update initialization
|
||||
void EPD_init_Fast(void)
|
||||
{
|
||||
delay(20);//At least 20ms delay
|
||||
EPD_W21_RST_0; // Module reset
|
||||
delay(50);//At least 50ms delay
|
||||
EPD_W21_RST_1;
|
||||
delay(50);//At least 50ms delay
|
||||
|
||||
lcd_chkstatus();
|
||||
EPD_W21_WriteCMD(0x4D);
|
||||
EPD_W21_WriteDATA(0x78);
|
||||
|
||||
EPD_W21_WriteCMD(0x00); //PSR
|
||||
EPD_W21_WriteDATA(0x0F);
|
||||
EPD_W21_WriteDATA(0x29);
|
||||
|
||||
EPD_W21_WriteCMD(0X06); //BTST_P
|
||||
EPD_W21_WriteDATA(0x0D); //47uH
|
||||
EPD_W21_WriteDATA(0x12);
|
||||
EPD_W21_WriteDATA(0x30);
|
||||
EPD_W21_WriteDATA(0x20);
|
||||
EPD_W21_WriteDATA(0x19);
|
||||
EPD_W21_WriteDATA(0x2A);
|
||||
EPD_W21_WriteDATA(0x22);
|
||||
|
||||
EPD_W21_WriteCMD(0x50); //CDI
|
||||
EPD_W21_WriteDATA(0x37);
|
||||
|
||||
EPD_W21_WriteCMD(0x61); //TRES
|
||||
EPD_W21_WriteDATA(Source_BITS/256); // Source_BITS_H
|
||||
EPD_W21_WriteDATA(Source_BITS%256); // Source_BITS_L
|
||||
EPD_W21_WriteDATA(Gate_BITS/256); // Gate_BITS_H
|
||||
EPD_W21_WriteDATA(Gate_BITS%256); // Gate_BITS_L
|
||||
|
||||
EPD_W21_WriteCMD(0xE9);
|
||||
EPD_W21_WriteDATA(0x01);
|
||||
|
||||
EPD_W21_WriteCMD(0x30);
|
||||
EPD_W21_WriteDATA(0x08);
|
||||
|
||||
EPD_W21_WriteCMD(0x04);
|
||||
lcd_chkstatus();
|
||||
|
||||
EPD_W21_WriteCMD(0xE0);
|
||||
EPD_W21_WriteDATA(0x02);
|
||||
|
||||
EPD_W21_WriteCMD(0xE6);
|
||||
EPD_W21_WriteDATA(0x5D);
|
||||
|
||||
EPD_W21_WriteCMD(0xA5);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
lcd_chkstatus();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void EPD_DeepSleep(void)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ void Display_All_Yellow(void);
|
||||
void Display_All_Red(void);
|
||||
|
||||
void Acep_color(unsigned char color);
|
||||
//Fast
|
||||
void EPD_init_Fast(void);
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,13 @@ void loop() {
|
||||
PIC_display(gImage_1);//To Display one image using full screen update.
|
||||
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
|
||||
delay(3000); //Delay for 3s.
|
||||
|
||||
/************Fast update mode(12s)*******************/
|
||||
#if 1 //Fast update demostration.
|
||||
EPD_init_Fast(); //Fast screen update initialization.
|
||||
PIC_display(gImage_1);//To Display one image using full screen update.
|
||||
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
|
||||
delay(3000); //Delay for 3s.
|
||||
#endif
|
||||
/************Full display 180*******************/
|
||||
#if 0//Full screen update initialization.
|
||||
EPD_init_180(); //Fast screen update initialization.
|
||||
|
||||
@@ -72,6 +72,81 @@ void EPD_init(void)
|
||||
|
||||
}
|
||||
|
||||
//Fast full screen update initialization
|
||||
void EPD_init_Fast(void)
|
||||
{
|
||||
delay(100);//At least 100ms delay
|
||||
EPD_W21_RST_0; // Module reset
|
||||
delay(50);//At least 50ms delay
|
||||
EPD_W21_RST_1;
|
||||
delay(50);//At least 50ms delay
|
||||
|
||||
lcd_chkstatus();
|
||||
EPD_W21_WriteCMD(0x4D);
|
||||
EPD_W21_WriteDATA(0x78);
|
||||
|
||||
EPD_W21_WriteCMD(0x00); //PSR
|
||||
EPD_W21_WriteDATA(0x0F);
|
||||
EPD_W21_WriteDATA(0x29);
|
||||
|
||||
EPD_W21_WriteCMD(0x01); //PWRR
|
||||
EPD_W21_WriteDATA(0x07);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
|
||||
EPD_W21_WriteCMD(0x03); //POFS
|
||||
EPD_W21_WriteDATA(0x10);
|
||||
EPD_W21_WriteDATA(0x54);
|
||||
EPD_W21_WriteDATA(0x44);
|
||||
|
||||
EPD_W21_WriteCMD(0x06); //BTST_P
|
||||
EPD_W21_WriteDATA(0x0F);
|
||||
EPD_W21_WriteDATA(0x0A);
|
||||
EPD_W21_WriteDATA(0x2F);
|
||||
EPD_W21_WriteDATA(0x25);
|
||||
EPD_W21_WriteDATA(0x22);
|
||||
EPD_W21_WriteDATA(0x2E);
|
||||
EPD_W21_WriteDATA(0x21);
|
||||
|
||||
EPD_W21_WriteCMD(0x50); //CDI
|
||||
EPD_W21_WriteDATA(0x37);
|
||||
|
||||
EPD_W21_WriteCMD(0x61); //TRES
|
||||
EPD_W21_WriteDATA(Source_BITS/256); // Source_BITS_H
|
||||
EPD_W21_WriteDATA(Source_BITS%256); // Source_BITS_L
|
||||
EPD_W21_WriteDATA(Gate_BITS/256); // Gate_BITS_H
|
||||
EPD_W21_WriteDATA(Gate_BITS%256); // Gate_BITS_L
|
||||
|
||||
EPD_W21_WriteCMD(0xE3);
|
||||
EPD_W21_WriteDATA(0x22);
|
||||
|
||||
EPD_W21_WriteCMD(0xB6);
|
||||
EPD_W21_WriteDATA(0x6F);
|
||||
|
||||
EPD_W21_WriteCMD(0xB4);
|
||||
EPD_W21_WriteDATA(0xD0);
|
||||
|
||||
EPD_W21_WriteCMD(0xE9);
|
||||
EPD_W21_WriteDATA(0x01);
|
||||
|
||||
EPD_W21_WriteCMD(0x30);
|
||||
EPD_W21_WriteDATA(0x08);
|
||||
|
||||
EPD_W21_WriteCMD(0x04);
|
||||
lcd_chkstatus();
|
||||
|
||||
EPD_W21_WriteCMD(0xE0);
|
||||
EPD_W21_WriteDATA(0x02);
|
||||
|
||||
EPD_W21_WriteCMD(0xE6);
|
||||
EPD_W21_WriteDATA(0x5A);
|
||||
|
||||
EPD_W21_WriteCMD(0xA5);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
lcd_chkstatus();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void EPD_DeepSleep(void)
|
||||
{
|
||||
EPD_W21_WriteCMD(0X02); //power off
|
||||
|
||||
@@ -31,8 +31,8 @@ void Display_All_Yellow(void);
|
||||
void Display_All_Red(void);
|
||||
|
||||
void Acep_color(unsigned char color);
|
||||
void EPD_init_Fast(void);
|
||||
|
||||
//Fast
|
||||
void EPD_init_Fast(void);
|
||||
|
||||
//GUI display
|
||||
void EPD_HW_Init_GUI(void);
|
||||
|
||||
@@ -39,6 +39,14 @@ void loop() {
|
||||
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
|
||||
delay(3000); //Delay for 3s.
|
||||
|
||||
/************Fast update mode(12s)*******************/
|
||||
#if 1 //Fast update demostration.
|
||||
EPD_init_Fast(); //Fast screen update initialization.
|
||||
PIC_display(gImage_1);//To Display one image using full screen update.
|
||||
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
|
||||
delay(3000); //Delay for 3s.
|
||||
#endif
|
||||
|
||||
/************Full display 180*******************/
|
||||
#if 0//Full screen update initialization.
|
||||
EPD_init_180(); //Fast screen update initialization.
|
||||
|
||||
@@ -11,7 +11,8 @@ void delay_xms(unsigned int xms)
|
||||
void lcd_chkstatus(void)
|
||||
{
|
||||
while(isEPD_W21_BUSY==0);
|
||||
|
||||
delay_xms(100);//At least 100ms delay
|
||||
|
||||
}
|
||||
|
||||
void EPD_init(void)
|
||||
@@ -80,6 +81,79 @@ void EPD_init(void)
|
||||
|
||||
}
|
||||
|
||||
void EPD_init_Fast(void)
|
||||
{
|
||||
delay_xms(100);//At least 100ms delay
|
||||
EPD_W21_RST_0; // Module reset
|
||||
delay_xms(50);//At least 50ms delay
|
||||
EPD_W21_RST_1;
|
||||
delay_xms(50);//At least 50ms delay
|
||||
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
|
||||
|
||||
EPD_W21_WriteCMD(0x4D);
|
||||
EPD_W21_WriteDATA(0x78);
|
||||
|
||||
EPD_W21_WriteCMD(0x00); //0x00
|
||||
EPD_W21_WriteDATA(0x2F);
|
||||
EPD_W21_WriteDATA(0x29);
|
||||
|
||||
EPD_W21_WriteCMD(0x06);//47uH
|
||||
EPD_W21_WriteDATA(0x0d);
|
||||
EPD_W21_WriteDATA(0x12);
|
||||
EPD_W21_WriteDATA(0x30);
|
||||
EPD_W21_WriteDATA(0x20);
|
||||
EPD_W21_WriteDATA(0x19);
|
||||
EPD_W21_WriteDATA(0x3D);
|
||||
EPD_W21_WriteDATA(0x0C);
|
||||
|
||||
EPD_W21_WriteCMD(0x06); //0x06
|
||||
EPD_W21_WriteDATA(0x0d);
|
||||
EPD_W21_WriteDATA(0x12);
|
||||
EPD_W21_WriteDATA(0x30);
|
||||
EPD_W21_WriteDATA(0x20);
|
||||
EPD_W21_WriteDATA(0x19);
|
||||
EPD_W21_WriteDATA(0x3D);
|
||||
EPD_W21_WriteDATA(0x0C);
|
||||
|
||||
EPD_W21_WriteCMD(0x50); //0x50
|
||||
EPD_W21_WriteDATA(0x37);
|
||||
|
||||
EPD_W21_WriteCMD(0x61);//0x61
|
||||
EPD_W21_WriteDATA(Source_BITS/256);
|
||||
EPD_W21_WriteDATA(Source_BITS%256);
|
||||
EPD_W21_WriteDATA(Gate_BITS/256);
|
||||
EPD_W21_WriteDATA(Gate_BITS%256);
|
||||
|
||||
EPD_W21_WriteCMD(0x65); //0x65
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
|
||||
EPD_W21_WriteCMD(0xE0);
|
||||
EPD_W21_WriteDATA(0x01);
|
||||
|
||||
EPD_W21_WriteCMD(0xE3);
|
||||
EPD_W21_WriteDATA(0x08);
|
||||
|
||||
EPD_W21_WriteCMD(0xE5);
|
||||
EPD_W21_WriteDATA(0x08);
|
||||
|
||||
EPD_W21_WriteCMD(0xE9);
|
||||
EPD_W21_WriteDATA(0x01);
|
||||
|
||||
EPD_W21_WriteCMD(0x04); //Power on
|
||||
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
|
||||
//Fast
|
||||
EPD_W21_WriteCMD(0xE0);
|
||||
EPD_W21_WriteDATA(0x03);
|
||||
EPD_W21_WriteCMD(0xE6);
|
||||
EPD_W21_WriteDATA(92);
|
||||
EPD_W21_WriteCMD(0xA5);
|
||||
EPD_W21_WriteDATA(0x00);
|
||||
lcd_chkstatus(); //waiting for the electronic paper IC to release the idle signal
|
||||
|
||||
}
|
||||
void EPD_sleep(void)
|
||||
{
|
||||
EPD_W21_WriteCMD(0X02); //power off
|
||||
|
||||
@@ -29,7 +29,9 @@ void Display_All_White(void);
|
||||
void Display_All_Yellow(void);
|
||||
void Display_All_Red(void);
|
||||
|
||||
void Acep_color(unsigned char color);
|
||||
void Acep_color(unsigned char color);
|
||||
//Fast
|
||||
void EPD_init_Fast(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,11 @@ void loop() {
|
||||
PIC_display(gImage_4G1);//To Display one image using full screen update.
|
||||
EPD_sleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
|
||||
delay(3000); //Delay for 3s.
|
||||
|
||||
/************Fast display*******************/
|
||||
EPD_init_Fast(); //Fast screen update initialization.
|
||||
PIC_display(gImage_4G1);//To Display one image using full screen update.
|
||||
EPD_sleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
|
||||
delay(3000); //Delay for 3s.
|
||||
#if 0//Demonstration of Display 4 c 0*olors, to enable this feature, please change 0 to 1.
|
||||
/************Full display*******************/
|
||||
EPD_init(); //Full screen update initialization.
|
||||
|
||||
600
examples/BT-EPD/example1-BT/EPD.cpp
Normal file
600
examples/BT-EPD/example1-BT/EPD.cpp
Normal 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
examples/BT-EPD/example1-BT/EPD.h
Normal file
41
examples/BT-EPD/example1-BT/EPD.h
Normal 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
|
||||
|
||||
|
||||
|
||||
3276
examples/BT-EPD/example1-BT/IMAGE.h
Normal file
3276
examples/BT-EPD/example1-BT/IMAGE.h
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 937 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,2 @@
|
||||
(40~47:@ABCDEFG ascii)
|
||||
//AA 55 E1 00 08 40 41 42 43 44 45 46 47 04 FF 0D 0A
|
||||
233
examples/BT-EPD/example1-BT/example1-BT.ino
Normal file
233
examples/BT-EPD/example1-BT/example1-BT.ino
Normal file
@@ -0,0 +1,233 @@
|
||||
#include<ESP32epdx.h> //E-paper SPI etc
|
||||
//EPD
|
||||
#include"EPD.h" //E-paper driver
|
||||
#include"IMAGE.h" //E-paper image data
|
||||
//BT
|
||||
#include "BluetoothSerial.h"
|
||||
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
|
||||
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
|
||||
#endif
|
||||
BluetoothSerial SerialBT;
|
||||
char BT_RX_BUF[100]; //BT receive data
|
||||
char StringNum[100];// BT display data
|
||||
unsigned int DataLength;// Data length
|
||||
|
||||
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
|
||||
|
||||
void setup() {
|
||||
/* ESP32-WROOM-32D (Using hardware SPI)
|
||||
BUSY——GPIO13 RES——GPIO12 DC——GPIO14 CS——GPIO27 SCK—GPIO18 SDIN—GPIO23 */
|
||||
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 ();
|
||||
//BT
|
||||
Serial.begin(115200);
|
||||
SerialBT.begin("ESP32test"); //Bluetooth device name
|
||||
Serial.println("The device started, now you can pair it with bluetooth!");
|
||||
}
|
||||
|
||||
//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;
|
||||
int num;
|
||||
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.
|
||||
|
||||
//Send the following test data in hexadecimal format using Bluetooth debugging assistant
|
||||
//AA 55 E1 00 08 40 41 42 43 44 45 46 47 04 FF 0D 0A (40~47:@ABCDEFG ascii)
|
||||
/*AA 55: Data Header
|
||||
E1: Function Bit
|
||||
00: Reserved
|
||||
08: Data Length
|
||||
40-47: Data Bit
|
||||
04: Verification
|
||||
FF 0D 0A: Data Tail
|
||||
*/
|
||||
while(1)
|
||||
{
|
||||
if(SerialBT.available()) //Bluetooth data reception
|
||||
{
|
||||
|
||||
BT_RX_BUF[num++]=SerialBT.read();
|
||||
}
|
||||
if(BT_RX_BUF[16]==0x0A) //Determine the data tail
|
||||
{
|
||||
Serial.println("BT_RX_BUF[16]==0x0A");
|
||||
//Get display data
|
||||
for(i=0;i<BT_RX_BUF[4];i++)
|
||||
{
|
||||
StringNum[i]=BT_RX_BUF[i+5]; //Extract data: 5-12 data sections
|
||||
}
|
||||
//Confirm BT data
|
||||
for(i=0;i<17;i++)
|
||||
{
|
||||
SerialBT.write(BT_RX_BUF[i]);
|
||||
Serial.write(BT_RX_BUF[i]);
|
||||
BT_RX_BUF[i]=0;
|
||||
}
|
||||
if(i==17)
|
||||
{
|
||||
i=0;
|
||||
num=0;
|
||||
}
|
||||
|
||||
//After receiving Bluetooth data, the electronic paper GUI displays the StrinNum, which is the real data sent by the phone:@ ABCDEFG
|
||||
#if 1 //Bluetooth receives 8 bytes of data
|
||||
//Data initialization settings
|
||||
Paint_NewImage(ImageBW, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); // Set screen size and display orientation
|
||||
Paint_SelectImage(ImageBW);// Set the virtual canvas data storage location
|
||||
/***********String***************************/
|
||||
Paint_Clear(WHITE);
|
||||
Paint_DrawString_EN(0, 0, "Good Display", &Font12, WHITE, BLACK); // Display Good Display
|
||||
Paint_DrawString_EN(0, 50, StringNum, &Font20, BLACK, WHITE); // Display Bluetooth data sent by mobile phone,@ABCDEFG
|
||||
Paint_DrawString_EN(0, 70, StringNum, &Font24, BLACK, WHITE); // Display Bluetooth data sent by mobile phone,@ABCDEFG
|
||||
EPD_HW_Init_GUI(); //EPD init GUI
|
||||
EPD_Display(ImageBW);//Display image
|
||||
EPD_DeepSleep();// EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
|
||||
#endif
|
||||
|
||||
#if 0 //StringNum is image data, use this function.
|
||||
EPD_HW_Init(); //Full screen update initialization.
|
||||
EPD_WhiteScreen_ALL(StringNum); // To Display one image using full screen refresh.
|
||||
EPD_DeepSleep(); // Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#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 0 //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
|
||||
|
||||
}
|
||||
600
examples/WiFi-EPD/example1-WiFi/EPD.cpp
Normal file
600
examples/WiFi-EPD/example1-WiFi/EPD.cpp
Normal 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
|
||||
***********************************************************/
|
||||
|
||||
37
examples/WiFi-EPD/example1-WiFi/EPD.h
Normal file
37
examples/WiFi-EPD/example1-WiFi/EPD.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#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);
|
||||
void EPD_Update(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
|
||||
|
||||
|
||||
|
||||
18526
examples/WiFi-EPD/example1-WiFi/IMAGE.h
Normal file
18526
examples/WiFi-EPD/example1-WiFi/IMAGE.h
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
300
examples/WiFi-EPD/example1-WiFi/example1-WiFi.ino
Normal file
300
examples/WiFi-EPD/example1-WiFi/example1-WiFi.ino
Normal file
@@ -0,0 +1,300 @@
|
||||
#include<ESP32epdx.h> //E-paper SPI etc
|
||||
//EPD
|
||||
#include"EPD.h" //E-paper driver
|
||||
#include"IMAGE.h" //E-paper image data
|
||||
//WiFi
|
||||
#include <WiFi.h>
|
||||
|
||||
unsigned char ImageBW[EPD_ARRAY];//Define canvas space
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//WiFi username and password setting
|
||||
/*
|
||||
const char* ssid = "GOODISPLAY";
|
||||
const char* password = "84619565@";
|
||||
*/
|
||||
const char* ssid = "CU_BBc6"; //WiFi username
|
||||
const char* password = "za9g8jvb"; //WiFi password
|
||||
|
||||
//String WifiData;
|
||||
int num;
|
||||
WiFiServer server(8080); //Default unchanged
|
||||
//IPAddress The local IP address can be set by first querying the local network segment through ImageToWiFi upper computer software.
|
||||
IPAddress staticIP(192, 168, 2, 208); //Change network segment and IP number
|
||||
IPAddress gateway(192, 168, 2, 1); //Change network segment
|
||||
IPAddress subnet(255, 255, 255, 0); //Default unchanged
|
||||
IPAddress dns1(192, 168, 2,1); //Change network segment
|
||||
IPAddress dns2(192, 168, 2,1); //Change network segment
|
||||
|
||||
|
||||
void setup() {
|
||||
/* ESP32-WROOM-32D (Using hardware SPI)
|
||||
BUSY——GPIO13 RES——GPIO12 DC——GPIO14 CS——GPIO27 SCK—GPIO18 SDIN—GPIO23 */
|
||||
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 ();
|
||||
//WiFi
|
||||
Serial.begin(115200);
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
|
||||
//WIFI Parameter settings
|
||||
WiFi.persistent(true);
|
||||
WiFi.mode(WIFI_STA); // switch off AP
|
||||
WiFi.setAutoConnect(true);
|
||||
WiFi.setAutoReconnect(true);
|
||||
WiFi.disconnect();
|
||||
|
||||
|
||||
//Pass in static IP address and gateway parameters DNS1, And 2
|
||||
if (WiFi.config(staticIP, gateway, subnet, dns1, dns2) == false) {
|
||||
Serial.println("Configuration failed.");
|
||||
}
|
||||
WiFi.begin(ssid, password); //DNS1 DNS2
|
||||
Connect1:
|
||||
int ConnectTimeout = 60; // 30 seconds
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(1000);
|
||||
Serial.print(".");
|
||||
Serial.print(WiFi.status());
|
||||
|
||||
if (--ConnectTimeout <= 0)
|
||||
{
|
||||
Serial.println();
|
||||
Serial.println("WiFi connect timeout");
|
||||
//goto Connect1;
|
||||
delay(10);
|
||||
ESP.restart(); //Reset ESP32 to ensure WiFi connection is OK
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected.");
|
||||
Serial.println("IP address: ");
|
||||
Serial.println(WiFi.localIP()); //local IP
|
||||
|
||||
server.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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Operation steps:
|
||||
1. Use the ImageToWiFi upper computer software to locate the local network segment.
|
||||
2. Set the device IP address.
|
||||
3. Set the network segment and IP number of the target device on the upper computer.
|
||||
4. Transfer image data to the device through ImageToWiFi software. Different electronic paper initialization and data sending commands may vary, and the actual electronic paper driver program shall prevail.
|
||||
*/
|
||||
void loop() {
|
||||
long i;
|
||||
long num;
|
||||
long dataLong=EPD_ARRAY;
|
||||
//If WiFi is connected, e-paper screen clearing
|
||||
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.
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("Reconnecting to WiFi...");
|
||||
WiFi.disconnect(); //Disconnect WiFi
|
||||
WiFi.reconnect(); //Reconnect WiFi
|
||||
}
|
||||
|
||||
WiFiClient client = server.available(); // listen for incoming clients
|
||||
if (client)
|
||||
{
|
||||
EPD_Init(); //Full screen update initialization.
|
||||
while (client.connected()) // loop while the client's connected
|
||||
{
|
||||
if (client.available()) // if there's bytes to read from the client,
|
||||
{
|
||||
//black and white datas////////////////////
|
||||
if(num==0)
|
||||
EPD_W21_WriteCMD(0x10); //Old Data
|
||||
if(num<dataLong) //black and white
|
||||
EPD_W21_WriteDATA(client.read()); //Write Old Data,This is necessary
|
||||
if(num==dataLong)
|
||||
EPD_W21_WriteCMD(0x13);//New Data
|
||||
if(num>=dataLong&&num<dataLong*2) //Red and White
|
||||
EPD_W21_WriteDATA(~client.read()); //Write New Data
|
||||
if(num>=dataLong*2) //Read excess data
|
||||
client.read(); //Read only without processing
|
||||
num++; //count add
|
||||
}
|
||||
}
|
||||
EPD_Update();//EPD refresh
|
||||
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
|
||||
num=0; //RESET 0
|
||||
// close the connection:
|
||||
client.println("OK");//Send data and receive OK signal
|
||||
client.stop();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#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 0 //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_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 0 //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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user