up
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,392 @@
|
|||||||
|
#include "Display_EPD_W21_spi.h"
|
||||||
|
#include "Display_EPD_W21.h"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************
|
||||||
|
end file
|
||||||
|
***********************************************************/
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef _DISPLAY_EPD_W21_H_
|
||||||
|
#define _DISPLAY_EPD_W21_H_
|
||||||
|
|
||||||
|
|
||||||
|
#define EPD_WIDTH 240
|
||||||
|
#define EPD_HEIGHT 320
|
||||||
|
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
|
||||||
|
|
||||||
|
|
||||||
|
//Full screen refresh 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 refresh 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 refresh display
|
||||||
|
void EPD_Init_Fast(void);
|
||||||
|
void EPD_WhiteScreen_ALL_Fast(const unsigned char *datas);
|
||||||
|
//GUI display
|
||||||
|
void EPD_Init_GUI(void);
|
||||||
|
void EPD_Display(unsigned char *Image);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#include "Display_EPD_W21_spi.h"
|
||||||
|
#include <SPI.h>
|
||||||
|
|
||||||
|
//SPI write byte
|
||||||
|
void SPI_Write(unsigned char value)
|
||||||
|
{
|
||||||
|
SPI.transfer(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//SPI write command
|
||||||
|
void EPD_W21_WriteCMD(unsigned char command)
|
||||||
|
{
|
||||||
|
EPD_W21_CS_0;
|
||||||
|
EPD_W21_DC_0; // D/C# 0:command 1:data
|
||||||
|
SPI_Write(command);
|
||||||
|
EPD_W21_CS_1;
|
||||||
|
}
|
||||||
|
//SPI write data
|
||||||
|
void EPD_W21_WriteDATA(unsigned char datas)
|
||||||
|
{
|
||||||
|
EPD_W21_CS_0;
|
||||||
|
EPD_W21_DC_1; // D/C# 0:command 1:data
|
||||||
|
SPI_Write(datas);
|
||||||
|
EPD_W21_CS_1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef _DISPLAY_EPD_W21_SPI_
|
||||||
|
#define _DISPLAY_EPD_W21_SPI_
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
//IO settings
|
||||||
|
//SCK--GPIO23(SCLK)
|
||||||
|
//SDIN---GPIO18(MOSI)
|
||||||
|
#define isEPD_W21_BUSY digitalRead(A14) //BUSY
|
||||||
|
#define EPD_W21_RST_0 digitalWrite(A15,LOW) //RES
|
||||||
|
#define EPD_W21_RST_1 digitalWrite(A15,HIGH)
|
||||||
|
#define EPD_W21_DC_0 digitalWrite(A16,LOW) //DC
|
||||||
|
#define EPD_W21_DC_1 digitalWrite(A16,HIGH)
|
||||||
|
#define EPD_W21_CS_0 digitalWrite(A17,LOW) //CS
|
||||||
|
#define EPD_W21_CS_1 digitalWrite(A17,HIGH)
|
||||||
|
|
||||||
|
|
||||||
|
void SPI_Write(unsigned char value);
|
||||||
|
void EPD_W21_WriteDATA(unsigned char datas);
|
||||||
|
void EPD_W21_WriteCMD(unsigned char command);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#include <SPI.h>
|
||||||
|
//EPD
|
||||||
|
#include "Display_EPD_W21_spi.h"
|
||||||
|
#include "Display_EPD_W21.h"
|
||||||
|
#include "Ap_29demo.h"
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
pinMode(A14, INPUT); //BUSY
|
||||||
|
pinMode(A15, OUTPUT); //RES
|
||||||
|
pinMode(A16, OUTPUT); //DC
|
||||||
|
pinMode(A17, 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 refresh.
|
||||||
|
3.Please make sue that EPD enters sleep mode when refresh 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 refresh, fast refresh, and partial refresh demostration.
|
||||||
|
|
||||||
|
EPD_Init(); //Full screen refresh 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 refresh initialization.
|
||||||
|
EPD_WhiteScreen_ALL(gImage_1); //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.
|
||||||
|
delay(2000); //Delay for 2s.
|
||||||
|
/************Fast refresh mode(1.5s)*******************/
|
||||||
|
EPD_Init_Fast(); //Fast refresh initialization.
|
||||||
|
EPD_WhiteScreen_ALL(gImage_1); //To display one image using fast refresh.
|
||||||
|
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 refresh demostration.
|
||||||
|
//Partial refresh demo support displaying a clock at 5 locations with 00:00. If you need to perform partial refresh more than 5 locations, please use the feature of using partial refresh at the full screen demo.
|
||||||
|
//After 5 partial refreshes, implement a full screen refresh to clear the ghosting caused by partial refreshes.
|
||||||
|
//////////////////////Partial refresh 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 refresh.
|
||||||
|
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 refresh 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 refresh to update the full screen, to enable this feature, please change 0 to 1.
|
||||||
|
//After 5 partial refreshes, implement a full screen refresh to clear the ghosting caused by partial refreshes.
|
||||||
|
//////////////////////Partial refresh time demo/////////////////////////////////////
|
||||||
|
EPD_Init(); //Full screen refresh 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 refresh 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 refresh with 180-degree rotation, to enable this feature, please change 0 to 1.
|
||||||
|
/************Full display(2s)*******************/
|
||||||
|
EPD_Init_180(); //Full screen refresh initialization.
|
||||||
|
EPD_WhiteScreen_ALL(gImage_1); //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.
|
||||||
|
delay(2000); //Delay for 2s.
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
while(1); // The program stops here
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////END//////////////////////////////////////////////////
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"idf.openOcdConfigs": [
|
"idf.openOcdConfigs": [
|
||||||
"board/esp32s3-builtin.cfg"
|
"board/esp32s3-builtin.cfg"
|
||||||
],
|
],
|
||||||
"idf.portWin": "COM10",
|
"idf.portWin": "COM9",
|
||||||
"idf.currentSetup": "C:\\esp\\v5.5.3\\esp-idf",
|
"idf.currentSetup": "C:\\esp\\v5.5.3\\esp-idf",
|
||||||
"idf.customExtraVars": {
|
"idf.customExtraVars": {
|
||||||
"OPENOCD_SCRIPTS": "C:\\Espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220411/openocd-esp32/share/openocd/scripts",
|
"OPENOCD_SCRIPTS": "C:\\Espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220411/openocd-esp32/share/openocd/scripts",
|
||||||
|
|||||||
+1304
-160
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@
|
|||||||
#define EPD_CS_PIN 34
|
#define EPD_CS_PIN 34
|
||||||
#define EPD_DC_PIN 35
|
#define EPD_DC_PIN 35
|
||||||
#define EPD_BUSY_PIN 37
|
#define EPD_BUSY_PIN 37
|
||||||
|
#define EPD_RST_PIN 16
|
||||||
|
|
||||||
/********************* 屏幕参数定义 *********************/
|
/********************* 屏幕参数定义 *********************/
|
||||||
#define EPD_WIDTH 320 // 屏幕宽度
|
#define EPD_WIDTH 320 // 屏幕宽度
|
||||||
|
|||||||
@@ -69,15 +69,15 @@ void app_main(void)
|
|||||||
|
|
||||||
spi_init();
|
spi_init();
|
||||||
epd_init();
|
epd_init();
|
||||||
epd_clear(1);
|
//epd_clear(1);
|
||||||
// 3. 画测试点(黑色)
|
// // 3. 画测试点(黑色)
|
||||||
epd_draw_point(50, 50, 0); // (50,50) 黑点
|
// epd_draw_point(50, 50, 0); // (50,50) 黑点
|
||||||
epd_draw_point(50, 60, 0); // (50,60) 黑点
|
// epd_draw_point(50, 60, 0); // (50,60) 黑点
|
||||||
epd_draw_point(60, 50, 0); // (60,50) 黑点
|
// epd_draw_point(60, 50, 0); // (60,50) 黑点
|
||||||
epd_draw_point(60, 60, 0); // (60,60) 黑点
|
// epd_draw_point(60, 60, 0); // (60,60) 黑点
|
||||||
|
|
||||||
// 4. 刷新屏幕
|
// // 4. 刷新屏幕
|
||||||
epd_refresh();
|
// epd_refresh();
|
||||||
|
|
||||||
|
|
||||||
// 1. 初始化 SPIFFS
|
// 1. 初始化 SPIFFS
|
||||||
|
|||||||
@@ -59,15 +59,7 @@ void spi_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
esp_err_t spi_send_sync_fullduplex(const uint8_t *tx_data, uint8_t *rx_data, size_t len)
|
||||||
* @brief 同步SPI全双工传输函数(无队列,直接硬件收发)
|
|
||||||
* @param tx_data: 待发送数据缓冲区(NULL则仅接收)
|
|
||||||
* @param rx_data: 接收数据缓冲区(NULL则仅发送)
|
|
||||||
* @param len: 传输长度(字节数,收发长度一致)
|
|
||||||
* @return esp_err_t: 传输结果
|
|
||||||
* @note 全双工模式下,发送和接收同时进行,len需匹配收发数据长度
|
|
||||||
*/
|
|
||||||
esp_err_t epd_spi_send_sync_fullduplex(const uint8_t *tx_data, uint8_t *rx_data, size_t len)
|
|
||||||
{
|
{
|
||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
// ret = spi_device_set_speed(spi2, speed * 1000 * 1000);
|
// ret = spi_device_set_speed(spi2, speed * 1000 * 1000);
|
||||||
@@ -105,3 +97,17 @@ esp_err_t epd_spi_send_sync_fullduplex(const uint8_t *tx_data, uint8_t *rx_data,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPI 写数据
|
||||||
|
esp_err_t spi_send_data_8(uint8_t data)
|
||||||
|
{
|
||||||
|
spi_transaction_t trans = {
|
||||||
|
.length = 8, // 数据位数
|
||||||
|
.flags = SPI_TRANS_USE_TXDATA, // 必须加这个标志
|
||||||
|
};
|
||||||
|
trans.tx_data[0] = (data);
|
||||||
|
|
||||||
|
esp_err_t err = spi_device_transmit(spi2, &trans);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
|
|
||||||
void spi_init();
|
void spi_init();
|
||||||
esp_err_t epd_spi_send_sync_fullduplex(const uint8_t *tx_data, uint8_t *rx_data, size_t len);
|
esp_err_t spi_send_sync_fullduplex(const uint8_t *tx_data, uint8_t *rx_data, size_t len);
|
||||||
|
esp_err_t spi_send_data_8(uint8_t data);
|
||||||
|
|
||||||
extern spi_device_handle_t spi2;
|
extern spi_device_handle_t spi2;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Automatically generated file. DO NOT EDIT.
|
# Automatically generated file. DO NOT EDIT.
|
||||||
# Espressif IoT Development Framework (ESP-IDF) 5.5.3 Project Configuration
|
# Espressif IoT Development Framework (ESP-IDF) 5.5.2 Project Configuration
|
||||||
#
|
#
|
||||||
CONFIG_SOC_ADC_SUPPORTED=y
|
CONFIG_SOC_ADC_SUPPORTED=y
|
||||||
CONFIG_SOC_UART_SUPPORTED=y
|
CONFIG_SOC_UART_SUPPORTED=y
|
||||||
@@ -370,7 +370,6 @@ CONFIG_SOC_WIFI_HW_TSF=y
|
|||||||
CONFIG_SOC_WIFI_FTM_SUPPORT=y
|
CONFIG_SOC_WIFI_FTM_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_GCMP_SUPPORT=y
|
CONFIG_SOC_WIFI_GCMP_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_TXOP_SUPPORT=y
|
|
||||||
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y
|
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y
|
||||||
@@ -698,7 +697,6 @@ CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y
|
|||||||
#
|
#
|
||||||
# Hardware Settings
|
# Hardware Settings
|
||||||
#
|
#
|
||||||
CONFIG_ESP_HW_SUPPORT_FUNC_IN_IRAM=y
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Chip revision
|
# Chip revision
|
||||||
@@ -759,8 +757,6 @@ CONFIG_RTC_CLK_SRC_INT_RC=y
|
|||||||
# CONFIG_RTC_CLK_SRC_EXT_OSC is not set
|
# CONFIG_RTC_CLK_SRC_EXT_OSC is not set
|
||||||
# CONFIG_RTC_CLK_SRC_INT_8MD256 is not set
|
# CONFIG_RTC_CLK_SRC_INT_8MD256 is not set
|
||||||
CONFIG_RTC_CLK_CAL_CYCLES=1024
|
CONFIG_RTC_CLK_CAL_CYCLES=1024
|
||||||
CONFIG_RTC_CLK_FUNC_IN_IRAM=y
|
|
||||||
CONFIG_RTC_TIME_FUNC_IN_IRAM=y
|
|
||||||
# end of RTC Clock Config
|
# end of RTC Clock Config
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user