Skip to content

Commit a8d0613

Browse files
authored
Merge pull request #31 from adafruit/pb-modes
Add “ink mode” to ThinkInk classes (needed for ImageReader)
2 parents 75aae57 + 0813e6b commit a8d0613

17 files changed

+237
-119
lines changed

src/Adafruit_ThinkInk.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#ifndef _ADAFRUIT_THINKINK_H_
2+
#define _ADAFRUIT_THINKINK_H_
3+
4+
#include "Adafruit_EPD.h"
5+
16
typedef enum {
27
THINKINK_MONO,
38
THINKINK_TRICOLOR,
@@ -22,3 +27,5 @@ typedef enum {
2227
#include "panels/ThinkInk_213_Mono_B73.h"
2328
#include "panels/ThinkInk_213_Mono_BN.h"
2429
#include "panels/ThinkInk_420_Mono_BN.h"
30+
31+
#endif // _ADAFRUIT_THINKINK_H_

src/panels/ThinkInk_154_Grayscale4_T8.h

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
#ifndef _THINKINK_154_GRAYSCALE4_T8_H
22
#define _THINKINK_154_GRAYSCALE4_T8_H
33

4+
// This file is #included by Adafruit_ThinkInk.h and does not need to
5+
// #include anything else to pick up the EPD header or ink mode enum.
6+
47
// clang-format off
58

69
static const uint8_t ti_154t8_gray4_init_code[] {
710
IL0373_POWER_SETTING, 5, 0x03, 0x00, 0x2b, 0x2b, 0x13,
8-
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
9-
IL0373_POWER_ON, 0,
10-
0xFF, 200,
11-
IL0373_PANEL_SETTING, 1, 0x3F,
12-
IL0373_PLL, 1, 0x3C,
13-
IL0373_VCM_DC_SETTING, 1, 0x12,
14-
IL0373_CDI, 1, 0x97,
15-
0xFE // EOM
11+
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
12+
IL0373_POWER_ON, 0,
13+
0xFF, 200,
14+
IL0373_PANEL_SETTING, 1, 0x3F,
15+
IL0373_PLL, 1, 0x3C,
16+
IL0373_VCM_DC_SETTING, 1, 0x12,
17+
IL0373_CDI, 1, 0x97,
18+
0xFE // EOM
1619
};
1720

1821
static const uint8_t ti_154t8_monopart_init_code[] {
1922
IL0373_POWER_SETTING, 5, 0x03, 0x00, 0x2b, 0x2b, 0x03,
20-
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
21-
IL0373_POWER_ON, 0,
22-
0xFF, 200,
23-
IL0373_PANEL_SETTING, 2, 0xbF, 0x0d,
24-
IL0373_PLL, 1, 0x3C,
25-
IL0373_VCM_DC_SETTING, 1, 0x12,
26-
IL0373_CDI, 1, 0x47,
27-
0xFE // EOM
23+
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
24+
IL0373_POWER_ON, 0,
25+
0xFF, 200,
26+
IL0373_PANEL_SETTING, 2, 0xbF, 0x0d,
27+
IL0373_PLL, 1, 0x3C,
28+
IL0373_VCM_DC_SETTING, 1, 0x12,
29+
IL0373_CDI, 1, 0x47,
30+
0xFE // EOM
2831
};
2932

3033
static const uint8_t ti_154t8_monofull_init_code[] {
31-
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
32-
IL0373_POWER_ON, 0,
33-
0xFF, 200,
34-
IL0373_PANEL_SETTING, 2, 0x1f, 0x0d,
35-
IL0373_CDI, 1, 0x97,
36-
0xFE // EOM
34+
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
35+
IL0373_POWER_ON, 0,
36+
0xFF, 200,
37+
IL0373_PANEL_SETTING, 2, 0x1f, 0x0d,
38+
IL0373_CDI, 1, 0x97,
39+
0xFE // EOM
3740
};
3841

3942
static const uint8_t ti_154t8_monopart_lut_code[] = {
@@ -144,7 +147,6 @@ static const uint8_t ti_154t8_gray4_lut_code[] = {
144147
// clang-format on
145148

146149
class ThinkInk_154_Grayscale4_T8 : public Adafruit_IL0373 {
147-
private:
148150
public:
149151
ThinkInk_154_Grayscale4_T8(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
150152
int8_t CS, int8_t SRCS, int8_t MISO,
@@ -160,6 +162,8 @@ class ThinkInk_154_Grayscale4_T8 : public Adafruit_IL0373 {
160162
setColorBuffer(0, true); // layer 0 uninverted
161163
setBlackBuffer(1, true); // layer 1 uninverted
162164

165+
inkmode = mode; // Preserve ink mode for ImageReader or others
166+
163167
if (mode == THINKINK_GRAYSCALE4) {
164168
_epd_init_code = ti_154t8_gray4_init_code;
165169
_epd_lut_code = ti_154t8_gray4_lut_code;
@@ -170,8 +174,7 @@ class ThinkInk_154_Grayscale4_T8 : public Adafruit_IL0373 {
170174
layer_colors[EPD_GRAY] = 0b10;
171175
layer_colors[EPD_LIGHT] = 0b01;
172176
layer_colors[EPD_DARK] = 0b10;
173-
}
174-
if (mode == THINKINK_MONO) {
177+
} else if (mode == THINKINK_MONO) {
175178
_epd_init_code = ti_154t8_monofull_init_code;
176179
_epd_partial_init_code = ti_154t8_monopart_init_code;
177180
_epd_partial_lut_code = ti_154t8_monopart_lut_code;
@@ -187,7 +190,12 @@ class ThinkInk_154_Grayscale4_T8 : public Adafruit_IL0373 {
187190
default_refresh_delay = 1000;
188191
setRotation(3);
189192
powerDown();
190-
};
193+
}
194+
195+
thinkinkmode_t getMode(void) { return inkmode; }
196+
197+
private:
198+
thinkinkmode_t inkmode; // Ink mode passed to begin()
191199
};
192200

193201
#endif // _THINKINK_154_GRAYSCALE4_T8_H

src/panels/ThinkInk_154_Mono_D27.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef _THINKINK_154_MONO_D27_H
22
#define _THINKINK_154_MONO_D27_H
33

4-
#include "Adafruit_EPD.h"
4+
// This file is #included by Adafruit_ThinkInk.h and does not need to
5+
// #include anything else to pick up the EPD header or ink mode enum.
56

67
class ThinkInk_154_Mono_D27 : public Adafruit_SSD1608 {
7-
private:
88
public:
99
ThinkInk_154_Mono_D27(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
1010
int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1)
@@ -19,6 +19,8 @@ class ThinkInk_154_Mono_D27 : public Adafruit_SSD1608 {
1919
setColorBuffer(0, true); // layer 0 uninverted
2020
setBlackBuffer(0, true); // only one buffer
2121

22+
inkmode = mode; // Preserve ink mode for ImageReader or others
23+
2224
layer_colors[EPD_WHITE] = 0b00;
2325
layer_colors[EPD_BLACK] = 0b01;
2426
layer_colors[EPD_RED] = 0b01;
@@ -29,7 +31,12 @@ class ThinkInk_154_Mono_D27 : public Adafruit_SSD1608 {
2931
default_refresh_delay = 1000;
3032
setRotation(3);
3133
powerDown();
32-
};
34+
}
35+
36+
thinkinkmode_t getMode(void) { return inkmode; }
37+
38+
private:
39+
thinkinkmode_t inkmode; // Ink mode passed to begin()
3340
};
3441

3542
#endif // _THINKINK_154_MONO_D27_H

src/panels/ThinkInk_154_Mono_D67.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef _THINKINK_154_MONO_D67_H
22
#define _THINKINK_154_MONO_D67_H
33

4-
#include "Adafruit_EPD.h"
4+
// This file is #included by Adafruit_ThinkInk.h and does not need to
5+
// #include anything else to pick up the EPD header or ink mode enum.
56

67
class ThinkInk_154_Mono_D67 : public Adafruit_SSD1681 {
7-
private:
88
public:
99
ThinkInk_154_Mono_D67(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
1010
int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1)
@@ -19,6 +19,8 @@ class ThinkInk_154_Mono_D67 : public Adafruit_SSD1681 {
1919
setColorBuffer(0, true); // layer 0 uninverted
2020
setBlackBuffer(0, true); // only one buffer
2121

22+
inkmode = mode; // Preserve ink mode for ImageReader or others
23+
2224
layer_colors[EPD_WHITE] = 0b00;
2325
layer_colors[EPD_BLACK] = 0b01;
2426
layer_colors[EPD_RED] = 0b01;
@@ -29,7 +31,12 @@ class ThinkInk_154_Mono_D67 : public Adafruit_SSD1681 {
2931
default_refresh_delay = 1000;
3032
setRotation(3);
3133
powerDown();
32-
};
34+
}
35+
36+
thinkinkmode_t getMode(void) { return inkmode; }
37+
38+
private:
39+
thinkinkmode_t inkmode; // Ink mode passed to begin()
3340
};
3441

3542
#endif // _THINKINK_154_MONO_D67_H

src/panels/ThinkInk_154_Tricolor_RW.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef _THINKINK_154_TRICOLOR_RW_H
22
#define _THINKINK_154_TRICOLOR_RW_H
33

4-
#include "Adafruit_EPD.h"
4+
// This file is #included by Adafruit_ThinkInk.h and does not need to
5+
// #include anything else to pick up the EPD header or ink mode enum.
56

67
class ThinkInk_154_Tricolor_RW : public Adafruit_SSD1680 {
7-
private:
88
public:
99
ThinkInk_154_Tricolor_RW(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
1010
int8_t CS, int8_t SRCS, int8_t MISO,
@@ -20,6 +20,8 @@ class ThinkInk_154_Tricolor_RW : public Adafruit_SSD1680 {
2020
setBlackBuffer(0, true);
2121
setColorBuffer(1, false);
2222

23+
inkmode = mode; // Preserve ink mode for ImageReader or others
24+
2325
layer_colors[EPD_WHITE] = 0b00;
2426
layer_colors[EPD_BLACK] = 0b01;
2527
layer_colors[EPD_RED] = 0b10;
@@ -30,7 +32,12 @@ class ThinkInk_154_Tricolor_RW : public Adafruit_SSD1680 {
3032
default_refresh_delay = 13000;
3133
setRotation(3);
3234
powerDown();
33-
};
35+
}
36+
37+
thinkinkmode_t getMode(void) { return inkmode; }
38+
39+
private:
40+
thinkinkmode_t inkmode; // Ink mode passed to begin()
3441
};
3542

3643
#endif // _THINKINK_154_TRI

src/panels/ThinkInk_154_Tricolor_Z17.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef _THINKINK_154_TRICOLOR_Z17_H
22
#define _THINKINK_154_TRICOLOR_Z17_H
33

4-
#include "Adafruit_EPD.h"
4+
// This file is #included by Adafruit_ThinkInk.h and does not need to
5+
// #include anything else to pick up the EPD header or ink mode enum.
56

67
class ThinkInk_154_Tricolor_Z17 : public Adafruit_IL0373 {
7-
private:
88
public:
99
ThinkInk_154_Tricolor_Z17(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
1010
int8_t CS, int8_t SRCS, int8_t MISO,
@@ -20,6 +20,8 @@ class ThinkInk_154_Tricolor_Z17 : public Adafruit_IL0373 {
2020
setColorBuffer(0, true); // layer 0 uninverted
2121
setBlackBuffer(1, true); // layer 1 uninverted
2222

23+
inkmode = mode; // Preserve ink mode for ImageReader or others
24+
2325
layer_colors[EPD_WHITE] = 0b00;
2426
layer_colors[EPD_BLACK] = 0b10;
2527
layer_colors[EPD_RED] = 0b01;
@@ -31,7 +33,12 @@ class ThinkInk_154_Tricolor_Z17 : public Adafruit_IL0373 {
3133

3234
setRotation(3);
3335
powerDown();
34-
};
36+
}
37+
38+
thinkinkmode_t getMode(void) { return inkmode; }
39+
40+
private:
41+
thinkinkmode_t inkmode; // Ink mode passed to begin()
3542
};
3643

3744
#endif // _THINKINK_154_TRICOLOR_Z17_H

src/panels/ThinkInk_213_Grayscale4_T5.h

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
#ifndef _THINKINK_213_GRAYSCALE4_T5_H
22
#define _THINKINK_213_GRAYSCALE4_T5_H
33

4-
#include "Adafruit_EPD.h"
4+
// This file is #included by Adafruit_ThinkInk.h and does not need to
5+
// #include anything else to pick up the EPD header or ink mode enum.
56

67
// clang-format off
78

89
static const uint8_t ti_213t5_gray4_init_code[] {
910
IL0373_POWER_SETTING, 5, 0x03, 0x00, 0x2b, 0x2b, 0x13,
10-
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
11-
IL0373_POWER_ON, 0,
12-
0xFF, 200,
13-
IL0373_PANEL_SETTING, 1, 0x3F,
14-
IL0373_PLL, 1, 0x3C,
15-
IL0373_VCM_DC_SETTING, 1, 0x12,
16-
IL0373_CDI, 1, 0x97,
17-
0xFE // EOM
11+
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
12+
IL0373_POWER_ON, 0,
13+
0xFF, 200,
14+
IL0373_PANEL_SETTING, 1, 0x3F,
15+
IL0373_PLL, 1, 0x3C,
16+
IL0373_VCM_DC_SETTING, 1, 0x12,
17+
IL0373_CDI, 1, 0x97,
18+
0xFE // EOM
1819
};
1920

2021
static const uint8_t ti_213t5_monopart_init_code[] {
2122
IL0373_POWER_SETTING, 5, 0x03, 0x00, 0x2b, 0x2b, 0x03,
22-
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
23-
IL0373_POWER_ON, 0,
24-
0xFF, 200,
25-
IL0373_PANEL_SETTING, 2, 0xbF, 0x0d,
26-
IL0373_PLL, 1, 0x3C,
27-
IL0373_VCM_DC_SETTING, 1, 0x12,
28-
IL0373_CDI, 1, 0x47,
29-
0xFE // EOM
23+
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
24+
IL0373_POWER_ON, 0,
25+
0xFF, 200,
26+
IL0373_PANEL_SETTING, 2, 0xbF, 0x0d,
27+
IL0373_PLL, 1, 0x3C,
28+
IL0373_VCM_DC_SETTING, 1, 0x12,
29+
IL0373_CDI, 1, 0x47,
30+
0xFE // EOM
3031
};
3132

3233
static const uint8_t ti_213t5_monofull_init_code[] {
33-
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
34-
IL0373_POWER_ON, 0,
35-
0xFF, 200,
36-
IL0373_PANEL_SETTING, 2, 0x1f, 0x0d,
37-
IL0373_CDI, 1, 0x97,
38-
0xFE // EOM
34+
IL0373_BOOSTER_SOFT_START, 3, 0x17, 0x17, 0x17,
35+
IL0373_POWER_ON, 0,
36+
0xFF, 200,
37+
IL0373_PANEL_SETTING, 2, 0x1f, 0x0d,
38+
IL0373_CDI, 1, 0x97,
39+
0xFE // EOM
3940
};
4041

4142
static const uint8_t ti_213t5_monopart_lut_code[] = {
@@ -146,7 +147,6 @@ static const uint8_t ti_213t5_gray4_lut_code[] = {
146147
// clang-format on
147148

148149
class ThinkInk_213_Grayscale4_T5 : public Adafruit_IL0373 {
149-
private:
150150
public:
151151
ThinkInk_213_Grayscale4_T5(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
152152
int8_t CS, int8_t SRCS, int8_t MISO,
@@ -162,6 +162,8 @@ class ThinkInk_213_Grayscale4_T5 : public Adafruit_IL0373 {
162162
setColorBuffer(0, true); // layer 0 uninverted
163163
setBlackBuffer(1, true); // layer 1 uninverted
164164

165+
inkmode = mode; // Preserve ink mode for ImageReader or others
166+
165167
if (mode == THINKINK_GRAYSCALE4) {
166168
_epd_init_code = ti_213t5_gray4_init_code;
167169
_epd_lut_code = ti_213t5_gray4_lut_code;
@@ -172,8 +174,7 @@ class ThinkInk_213_Grayscale4_T5 : public Adafruit_IL0373 {
172174
layer_colors[EPD_GRAY] = 0b10;
173175
layer_colors[EPD_LIGHT] = 0b01;
174176
layer_colors[EPD_DARK] = 0b10;
175-
}
176-
if (mode == THINKINK_MONO) {
177+
} else if (mode == THINKINK_MONO) {
177178
_epd_init_code = ti_213t5_monofull_init_code;
178179
_epd_partial_init_code = ti_213t5_monopart_init_code;
179180
_epd_partial_lut_code = ti_213t5_monopart_lut_code;
@@ -189,7 +190,12 @@ class ThinkInk_213_Grayscale4_T5 : public Adafruit_IL0373 {
189190
default_refresh_delay = 1000;
190191

191192
powerDown();
192-
};
193+
}
194+
195+
thinkinkmode_t getMode(void) { return inkmode; }
196+
197+
private:
198+
thinkinkmode_t inkmode; // Ink mode passed to begin()
193199
};
194200

195201
#endif // _THINKINK_213_GRAYSCALE4_T5_H

0 commit comments

Comments
 (0)