Skip to content

Commit

Permalink
Update display driver
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerganov committed Jan 4, 2024
1 parent 2f8b21a commit a678ae9
Showing 1 changed file with 104 additions and 4 deletions.
108 changes: 104 additions & 4 deletions target/src/EPD_3in52_rse.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "EPD.h"
#include "debug.h"

static int lut_flag = 0;

static void EPD_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_CS_PIN, 0);
Expand Down Expand Up @@ -39,14 +41,110 @@ static void EPD_Refresh()
EPD_ReadBusy();
}

const unsigned char lut_R20_GC[] = {
0x01,0x0f,0x0f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
const unsigned char lut_R21_GC[] = {
0x01,0x4f,0x8f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
const unsigned char lut_R22_GC[] = {
0x01,0x0f,0x8f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
const unsigned char lut_R23_GC[] = {
0x01,0x4f,0x8f,0x4f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
const unsigned char lut_R24_GC[] = {
0x01,0x0f,0x8f,0x4f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

static void lut_GC()
{
int count;
EPD_SendCommand(0x20); // vcom
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R20_GC[count]);
}

EPD_SendCommand(0x21); // red not use
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R21_GC[count]);
}

EPD_SendCommand(0x24); // bb b
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R24_GC[count]);
}

if (lut_flag == 0) {
EPD_SendCommand(0x22); // bw r
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R22_GC[count]);
}

EPD_SendCommand(0x23); // wb w
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R23_GC[count]);
}
lut_flag = 1;
} else {
EPD_SendCommand(0x22); // bw r
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R23_GC[count]);
}

EPD_SendCommand(0x23); // wb w
for (count = 0; count < 56; count++) {
EPD_SendData(lut_R22_GC[count]);
}
lut_flag = 0;
}
}

void EPD_Init()
{
lut_flag = 0;
EPD_Reset();
DEV_Delay_ms(100);

EPD_SendCommand(0x00); // panel setting register
EPD_SendData(0x1F);
EPD_SendData(0b00111111);
EPD_SendData(0x0D);

DEV_Delay_ms(10);

EPD_SendCommand(0x01); // POWER SETTING PWR
Expand All @@ -57,9 +155,9 @@ void EPD_Init()
EPD_SendData(0x03); // OPTEN VDHR[6:0] VHDR=6.4V
// T_VDS_OFF[1:0] 00=1 frame; 01=2 frame; 10=3 frame; 11=4 frame
EPD_SendCommand(0x06); // booster soft start BTST
EPD_SendData(0b00010111); // BT_PHA[7:0]
EPD_SendData(0b00010111); // BT_PHB[7:0]
EPD_SendData(0b00010111); // x x BT_PHC[5:0]
EPD_SendData(0x17);
EPD_SendData(0x37);
EPD_SendData(0x3D);

EPD_SendCommand(0x82); // VCOM_DC setting VDCS
EPD_SendData(0x07); // x VDCS[6:0] VCOM_DC value= -1.9v 00~3f,0x12=-1.9v
Expand Down Expand Up @@ -100,6 +198,7 @@ void EPD_Clear()
}
}
EPD_SendCommand(0x11);
lut_GC();
EPD_Refresh();
}

Expand All @@ -123,6 +222,7 @@ void EPD_Display(const UBYTE *blackImage, const UBYTE *redImage)
}
}
EPD_SendCommand(0x11);
lut_GC();
EPD_Refresh();
}

Expand Down

0 comments on commit a678ae9

Please sign in to comment.