Added fast refresh and improved partial refresh effect to the 4.2inch e-Paper

This commit is contained in:
SSYYL 2022-02-08 10:28:56 +08:00
parent 15df676682
commit d6e11eaae6
18 changed files with 4070 additions and 1871 deletions

View file

@ -39,7 +39,6 @@ Epd::Epd() {
height = EPD_HEIGHT;
};
int Epd::Init(void) {
/* this calls the peripheral hardware interface, see epdif */
if (IfInit() != 0) {
@ -47,23 +46,38 @@ int Epd::Init(void) {
}
/* EPD hardware init start */
Reset();
SendCommand(POWER_SETTING);
SendCommand(0x01);
SendData(0x03); // VDS_EN, VDG_EN
SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
SendData(0x2b); // VDH
SendData(0x2b); // VDL
SendData(0xff); // VDHR
SendCommand(BOOSTER_SOFT_START);
SendCommand(0x06);
SendData(0x17);
SendData(0x17);
SendData(0x17); //07 0f 17 1f 27 2F 37 2f
SendCommand(POWER_ON);
SendCommand(0x04);
WaitUntilIdle();
SendCommand(PANEL_SETTING);
SendCommand(0x00);
SendData(0xbf); // KW-BF KWR-AF BWROTP 0f
SendData(0x0b);
SendCommand(PLL_CONTROL);
SendCommand(0x30);
SendData(0x3c); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
SendCommand(0x61); // resolution setting
SendData(0x01);
SendData(0x90); //128
SendData(0x01); //
SendData(0x2c);
SendCommand(0x82); // vcom_DC setting
SendData(0x12);
SendCommand(0X50); // VCOM AND DATA INTERVAL SETTING
SendData(0x97); // 97white border 77black border VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7
SetLut();
/* EPD hardware init end */
return 0;
}
@ -304,27 +318,27 @@ void Epd::Set_4GrayDisplay(const char *Image, int x, int y, int w, int l)
void Epd::SetLut(void) {
unsigned int count;
SendCommand(LUT_FOR_VCOM); //vcom
for(count = 0; count < 44; count++) {
for(count = 0; count < 36; count++) {
SendData(lut_vcom0[count]);
}
SendCommand(LUT_WHITE_TO_WHITE); //ww --
for(count = 0; count < 42; count++) {
for(count = 0; count < 36; count++) {
SendData(lut_ww[count]);
}
SendCommand(LUT_BLACK_TO_WHITE); //bw r
for(count = 0; count < 42; count++) {
for(count = 0; count < 36; count++) {
SendData(lut_bw[count]);
}
SendCommand(LUT_WHITE_TO_BLACK); //wb w
for(count = 0; count < 42; count++) {
for(count = 0; count < 36; count++) {
SendData(lut_bb[count]);
}
SendCommand(LUT_BLACK_TO_BLACK); //bb b
for(count = 0; count < 42; count++) {
for(count = 0; count < 36; count++) {
SendData(lut_wb[count]);
}
}
@ -387,9 +401,7 @@ void Epd::DisplayFrame(const unsigned char* frame_buffer) {
DelayMs(2);
}
SetLut();
SendCommand(DISPLAY_REFRESH);
SendCommand(0x12);
DelayMs(100);
WaitUntilIdle();
}
@ -457,55 +469,56 @@ void Epd::Sleep() {
const unsigned char lut_vcom0[] =
{
0x00, 0x17, 0x00, 0x00, 0x00, 0x02,
0x00, 0x17, 0x17, 0x00, 0x00, 0x02,
0x00, 0x0A, 0x01, 0x00, 0x00, 0x01,
0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x08, 0x00, 0x00, 0x02,
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x01,
0x00, 0x08, 0x08, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
const unsigned char lut_ww[] ={
0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x17, 0x17, 0x00, 0x00, 0x02,
0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x50, 0x08, 0x08, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
0xA0, 0x08, 0x08, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char lut_bw[] ={
0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x17, 0x17, 0x00, 0x00, 0x02,
0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x50, 0x08, 0x08, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
0xA0, 0x08, 0x08, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char lut_bb[] ={
0x80, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x17, 0x17, 0x00, 0x00, 0x02,
0x80, 0x0A, 0x01, 0x00, 0x00, 0x01,
0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA0, 0x08, 0x08, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
0x50, 0x08, 0x08, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char lut_wb[] ={
0x80, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x17, 0x17, 0x00, 0x00, 0x02,
0x80, 0x0A, 0x01, 0x00, 0x00, 0x01,
0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x08, 0x08, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
0x10, 0x08, 0x08, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};