Skip to content

Commit d3b28d0

Browse files
committed
use OTP lut for EPD_4in2
1 parent 07b7b98 commit d3b28d0

File tree

2 files changed

+12
-108
lines changed

2 files changed

+12
-108
lines changed

EPD/EPD_4in2.c

Lines changed: 8 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -30,53 +30,6 @@
3030
******************************************************************************/
3131
#include "EPD_4in2.h"
3232

33-
static const unsigned char EPD_4IN2_lut_vcom0[] = {
34-
0x00, 0x08, 0x08, 0x00, 0x00, 0x02,
35-
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x01,
36-
0x00, 0x08, 0x08, 0x00, 0x00, 0x02,
37-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41-
0x00, 0x00,
42-
};
43-
static const unsigned char EPD_4IN2_lut_ww[] = {
44-
0x50, 0x08, 0x08, 0x00, 0x00, 0x02,
45-
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
46-
0xA0, 0x08, 0x08, 0x00, 0x00, 0x02,
47-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51-
};
52-
static const unsigned char EPD_4IN2_lut_bw[] = {
53-
0x50, 0x08, 0x08, 0x00, 0x00, 0x02,
54-
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
55-
0xA0, 0x08, 0x08, 0x00, 0x00, 0x02,
56-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60-
};
61-
static const unsigned char EPD_4IN2_lut_wb[] = {
62-
0xA0, 0x08, 0x08, 0x00, 0x00, 0x02,
63-
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
64-
0x50, 0x08, 0x08, 0x00, 0x00, 0x02,
65-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69-
};
70-
static const unsigned char EPD_4IN2_lut_bb[] = {
71-
0x20, 0x08, 0x08, 0x00, 0x00, 0x02,
72-
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x01,
73-
0x10, 0x08, 0x08, 0x00, 0x00, 0x02,
74-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78-
};
79-
8033
/******************************************************************************
8134
function : Software reset
8235
parameter:
@@ -85,18 +38,13 @@ static void EPD_4IN2_Reset(void)
8538
{
8639
DEV_Digital_Write(EPD_RST_PIN, 1);
8740
DEV_Delay_ms(10);
88-
DEV_Digital_Write(EPD_RST_PIN, 0);
89-
DEV_Delay_ms(10);
90-
DEV_Digital_Write(EPD_RST_PIN, 1);
91-
DEV_Delay_ms(10);
92-
DEV_Digital_Write(EPD_RST_PIN, 0);
93-
DEV_Delay_ms(10);
94-
DEV_Digital_Write(EPD_RST_PIN, 1);
95-
DEV_Delay_ms(10);
96-
DEV_Digital_Write(EPD_RST_PIN, 0);
97-
DEV_Delay_ms(10);
98-
DEV_Digital_Write(EPD_RST_PIN, 1);
99-
DEV_Delay_ms(10);
41+
for (UBYTE i = 0; i < 3; i++)
42+
{
43+
DEV_Digital_Write(EPD_RST_PIN, 0);
44+
DEV_Delay_ms(10);
45+
DEV_Digital_Write(EPD_RST_PIN, 1);
46+
DEV_Delay_ms(10);
47+
}
10048
}
10149

10250
/******************************************************************************
@@ -147,75 +95,28 @@ void EPD_4IN2_TurnOnDisplay(void)
14795
EPD_4IN2_ReadBusy();
14896
}
14997

150-
/******************************************************************************
151-
function : set the look-up tables
152-
parameter:
153-
******************************************************************************/
154-
static void EPD_4IN2_SetLut(void)
155-
{
156-
unsigned int count;
157-
EPD_4IN2_SendCommand(0x20);
158-
for(count=0;count<36;count++)
159-
{EPD_4IN2_SendData(EPD_4IN2_lut_vcom0[count]);}
160-
161-
EPD_4IN2_SendCommand(0x21);
162-
for(count=0;count<36;count++)
163-
{EPD_4IN2_SendData(EPD_4IN2_lut_ww[count]);}
164-
165-
EPD_4IN2_SendCommand(0x22);
166-
for(count=0;count<36;count++)
167-
{EPD_4IN2_SendData(EPD_4IN2_lut_bw[count]);}
168-
169-
EPD_4IN2_SendCommand(0x23);
170-
for(count=0;count<36;count++)
171-
{EPD_4IN2_SendData(EPD_4IN2_lut_wb[count]);}
172-
173-
EPD_4IN2_SendCommand(0x24);
174-
for(count=0;count<36;count++)
175-
{EPD_4IN2_SendData(EPD_4IN2_lut_bb[count]);}
176-
}
177-
17898
/******************************************************************************
17999
function : Initialize the e-Paper register
180100
parameter:
181101
******************************************************************************/
182102
void EPD_4IN2_Init(void)
183103
{
184104
EPD_4IN2_Reset();
185-
EPD_4IN2_SendCommand(0x01); // POWER SETTING
186-
EPD_4IN2_SendData (0x03); // VDS_EN, VDG_EN internal
187-
EPD_4IN2_SendData (0x00); // VCOM_HV, VGHL_LV=16V
188-
EPD_4IN2_SendData (0x2b); // VDH=11V
189-
EPD_4IN2_SendData (0x2b); // VDL=11V
190-
191-
EPD_4IN2_SendCommand(0x06); // boost soft start
192-
EPD_4IN2_SendData (0x17); // A
193-
EPD_4IN2_SendData (0x17); // B
194-
EPD_4IN2_SendData (0x17); // C
195105

196106
EPD_4IN2_SendCommand(0x04); // POWER ON
197107
EPD_4IN2_ReadBusy();
198108

199109
EPD_4IN2_SendCommand(0x00); // panel setting
200-
EPD_4IN2_SendData(0x3f); // 300x400 B/W mode, LUT set by register
201-
202-
203-
EPD_4IN2_SendCommand(0x30); // PLL setting (clock frequency)
204-
EPD_4IN2_SendData (0x3c); // 3c=50HZ 3a=100HZ 29=150Hz 39=200HZ 31=171HZ
110+
EPD_4IN2_SendData(0x1f); // 400x300 B/W mode, LUT from OTP
205111

206112
EPD_4IN2_SendCommand(0x61); // resolution setting
207113
EPD_4IN2_SendData (EPD_4IN2_WIDTH / 256);
208114
EPD_4IN2_SendData (EPD_4IN2_WIDTH % 256);
209115
EPD_4IN2_SendData (EPD_4IN2_HEIGHT / 256);
210116
EPD_4IN2_SendData (EPD_4IN2_HEIGHT % 256);
211117

212-
EPD_4IN2_SendCommand(0x82); // vcom_DC setting
213-
EPD_4IN2_SendData (0x12); // -0.1 + 18 * -0.05 = -1.0V
214-
215118
EPD_4IN2_SendCommand(0x50); // VCOM AND DATA INTERVAL SETTING
216119
EPD_4IN2_SendData(0x97); // LUTB=0 LUTW=1 interval=10
217-
218-
EPD_4IN2_SetLut();
219120
}
220121

221122
/******************************************************************************

html/js/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ async function sendCmWithData(cmd, data){
7171
}
7272

7373
async function send4GrayLut() {
74+
await sendcmd("0300");
75+
await sendcmd("043F"); // Load LUT from register
76+
7477
await sendCmWithData("20", "000A0000000160141400000100140000000100130A010001000000000000000000000000000000000000"); // vcom
7578
await sendCmWithData("21", "400A0000000190141400000110140A000001A01301000001000000000000000000000000000000000000"); // red not use
7679
await sendCmWithData("22", "400A0000000190141400000100140A000001990C01030401000000000000000000000000000000000000"); // bw r
@@ -95,7 +98,7 @@ async function sendimg(cmdIMG) {
9598
if (mode === "4gray") {
9699
await send4GrayLut();
97100
await sendcmd("05");
98-
await sendcmd(`01${driver}`);
101+
await sendcmd(`01${driver}`); // restore lut
99102
} else {
100103
await sendcmd("05");
101104
}

0 commit comments

Comments
 (0)