Skip to content

Commit 5db6ad3

Browse files
committed
add grayscale support
1 parent a730f9a commit 5db6ad3

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

examples/ThinkInk_gray4/ThinkInk_gray4.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
// 2.9" Grayscale Featherwing or Breakout:
2222
ThinkInk_290_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
23+
// 4.2" Grayscale display
24+
//ThinkInk_420_Grayscale4_T2 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
2325

2426
#define COLOR1 EPD_BLACK
2527
#define COLOR2 EPD_LIGHT

src/drivers/Adafruit_IL0398.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const uint8_t il0398_default_init_code[] {
1010
IL0398_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
1111
IL0398_POWER_ON, 0,
1212
0xFF, 20, // busy wait
13-
IL0398_PANEL_SETTING, 2, 0x0F, 0x0, // lut from OTP & vcom = 0v
14-
IL0398_VCOM, 1, 0xD7,
13+
IL0398_PANEL_SETTING, 2, 0x1F, 0x0D, // lut from OTP & vcom = 0v
14+
IL0398_VCOM, 1, 0x97,
1515
0xFE};
1616

1717
// clang-format on
@@ -145,6 +145,10 @@ void Adafruit_IL0398::powerUp() {
145145
}
146146
EPD_commandList(init_code);
147147

148+
if (_epd_lut_code) {
149+
EPD_commandList(_epd_lut_code);
150+
}
151+
148152
buf[0] = (HEIGHT >> 8) & 0xFF;
149153
buf[1] = HEIGHT & 0xFF;
150154
buf[2] = (WIDTH >> 8) & 0xFF;

src/panels/ThinkInk_420_Grayscale4_T2.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,74 @@
33

44
#include "Adafruit_EPD.h"
55

6+
// clang-format off
7+
8+
static const uint8_t ti_420t2_gray4_init_code[] {
9+
IL0398_POWER_SETTING, 5, 0x03, 0x00, 0x2b, 0x2b, 0x13,
10+
IL0398_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
11+
IL0398_POWER_ON, 0,
12+
0xFF, 200,
13+
IL0398_PANEL_SETTING, 1, 0x3F,
14+
IL0398_PLL, 1, 0x3C,
15+
IL0398_VCM_DC_SETTING, 1, 0x12,
16+
IL0398_VCOM, 1, 0x97,
17+
0xFE // EOM
18+
};
19+
20+
static const uint8_t ti_420t2_gray4_lut_code[] = {
21+
// const unsigned char lut_vcom[]PROGMEM =
22+
IL0398_LUT1, 42,
23+
0x00, 0x0A, 0x00, 0x00, 0x00, 0x01,
24+
0x60, 0x14, 0x14, 0x00, 0x00, 0x01,
25+
0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
26+
0x00, 0x13, 0x0A, 0x01, 0x00, 0x01,
27+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30+
31+
// const unsigned char lut_ww[]PROGMEM ={
32+
IL0398_LUTWW, 42,
33+
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
34+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
35+
0x10, 0x14, 0x0A, 0x00, 0x00, 0x01,
36+
0xA0, 0x13, 0x01, 0x00, 0x00, 0x01,
37+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40+
41+
// const unsigned char lut_bw[]PROGMEM ={
42+
IL0398_LUTBW, 42,
43+
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
44+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
45+
0x00, 0x14, 0x0A, 0x00, 0x00, 0x01,
46+
0x99, 0x0C, 0x01, 0x03, 0x04, 0x01,
47+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50+
51+
// const unsigned char lut_wb[]PROGMEM ={
52+
IL0398_LUTWB, 42,
53+
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
54+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
55+
0x00, 0x14, 0x0A, 0x00, 0x00, 0x01,
56+
0x99, 0x0B, 0x04, 0x04, 0x01, 0x01,
57+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60+
61+
// const unsigned char lut_bb[]PROGMEM ={
62+
IL0398_LUTBB, 42,
63+
0x80, 0x0A, 0x00, 0x00, 0x00, 0x01,
64+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
65+
0x20, 0x14, 0x0A, 0x00, 0x00, 0x01,
66+
0x50, 0x13, 0x01, 0x00, 0x00, 0x01,
67+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70+
};
71+
72+
// clang-format on
73+
674
class ThinkInk_420_Grayscale4_T2 : public Adafruit_IL0398 {
775
private:
876
public:
@@ -20,6 +88,9 @@ class ThinkInk_420_Grayscale4_T2 : public Adafruit_IL0398 {
2088
setBlackBuffer(1, true); // layer 1 uninverted
2189

2290
if (mode == THINKINK_MONO) {
91+
_epd_init_code = NULL;
92+
_epd_lut_code = NULL;
93+
2394
layer_colors[EPD_WHITE] = 0b00;
2495
layer_colors[EPD_BLACK] = 0b01;
2596
layer_colors[EPD_RED] = 0b01;
@@ -28,6 +99,18 @@ class ThinkInk_420_Grayscale4_T2 : public Adafruit_IL0398 {
2899
layer_colors[EPD_DARK] = 0b01;
29100
}
30101

102+
if (mode == THINKINK_GRAYSCALE4) {
103+
_epd_init_code = ti_420t2_gray4_init_code;
104+
_epd_lut_code = ti_420t2_gray4_lut_code;
105+
106+
layer_colors[EPD_WHITE] = 0b00;
107+
layer_colors[EPD_BLACK] = 0b11;
108+
layer_colors[EPD_RED] = 0b01;
109+
layer_colors[EPD_GRAY] = 0b10;
110+
layer_colors[EPD_LIGHT] = 0b01;
111+
layer_colors[EPD_DARK] = 0b10;
112+
}
113+
31114
default_refresh_delay = 1000;
32115
setRotation(1);
33116
powerDown();

0 commit comments

Comments
 (0)