Skip to content

Commit 0b3d7e7

Browse files
committed
adapt il91874 to support mono
1 parent 4019f7e commit 0b3d7e7

File tree

3 files changed

+75
-4
lines changed

3 files changed

+75
-4
lines changed

src/Adafruit_ThinkInk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ typedef enum {
1515

1616
#include "panels/ThinkInk_154_Grayscale4_T8.h"
1717
#include "panels/ThinkInk_213_Grayscale4_T5.h"
18+
#include "panels/ThinkInk_270_Grayscale4_W3.h"
1819
#include "panels/ThinkInk_290_Grayscale4_T5.h"
1920
#include "panels/ThinkInk_420_Grayscale4_T2.h"
2021

src/drivers/Adafruit_IL91874.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33

44
#define BUSY_WAIT 500
55

6+
// clang-format off
7+
8+
const uint8_t il91874_default_init_code[] {
9+
IL91874_BOOSTER_SOFT_START, 3, 0x07, 0x07, 0x17,
10+
IL91874_POWER_ON, 0,
11+
0xFF, 20, // busy wait
12+
IL91874_PANEL_SETTING, 1, 0x1f, // LUT from OTP
13+
IL91874_PDRF, 1, 0x00,
14+
0xF8, 2, 0x60, 0xA5, // boost
15+
0xF8, 2, 0x73, 0x23, // boost
16+
0xF8, 2, 0x7C, 0x00, // boost
17+
IL91874_CDI, 1, 0x97,
18+
0xFE};
19+
20+
// clang-format on
21+
22+
23+
624
const unsigned char lut_vcomDC[] = {
725
0x00, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A,
826
0x00, 0x00, 0x08, 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x00, 0x0A,
@@ -130,7 +148,7 @@ void Adafruit_IL91874::begin(bool reset) {
130148
Adafruit_EPD::begin(reset);
131149

132150
setBlackBuffer(0, true); // black defaults to inverted
133-
setColorBuffer(1, false); // red defaults to not inverted
151+
setColorBuffer(1, true); // red defaults to not inverted
134152

135153
powerDown();
136154
}
@@ -142,10 +160,10 @@ void Adafruit_IL91874::begin(bool reset) {
142160
/**************************************************************************/
143161
void Adafruit_IL91874::update() {
144162
EPD_command(IL91874_DISPLAY_REFRESH);
145-
163+
delay(100);
146164
busy_wait();
147165
if (_busy_pin <= -1) {
148-
delay(16000);
166+
delay(default_refresh_delay);
149167
}
150168
}
151169

@@ -159,7 +177,14 @@ void Adafruit_IL91874::powerUp() {
159177

160178
hardwareReset();
161179
delay(200);
180+
const uint8_t *init_code = il91874_default_init_code;
162181

182+
if (_epd_init_code != NULL) {
183+
init_code = _epd_init_code;
184+
}
185+
EPD_commandList(init_code);
186+
187+
/*
163188
EPD_command(IL91874_POWER_ON);
164189
busy_wait();
165190
@@ -213,6 +238,8 @@ void Adafruit_IL91874::powerUp() {
213238
EPD_command(IL91874_LUTWB, lut_wb, 42);
214239
EPD_command(IL91874_LUTBB, lut_bb, 42);
215240
241+
*/
242+
216243
buf[0] = (HEIGHT >> 8) & 0xFF;
217244
buf[1] = HEIGHT & 0xFF;
218245
buf[2] = (WIDTH >> 8) & 0xFF;
@@ -229,9 +256,12 @@ void Adafruit_IL91874::powerUp() {
229256
*/
230257
/**************************************************************************/
231258
void Adafruit_IL91874::powerDown() {
232-
// power off
233259
uint8_t buf[1];
234260

261+
buf[0] = 0xF7;
262+
EPD_command(IL91874_CDI, buf, 1);
263+
264+
// power off
235265
EPD_command(IL91874_POWER_OFF);
236266
busy_wait();
237267

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef _THINKINK_270_GRAY4_W3_H
2+
#define _THINKINK_270_GRAY4_W3_H
3+
4+
#include "Adafruit_EPD.h"
5+
6+
class ThinkInk_270_Grayscale4_W3 : public Adafruit_IL91874 {
7+
private:
8+
public:
9+
ThinkInk_270_Grayscale4_W3(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
10+
int8_t CS, int8_t SRCS, int8_t MISO,
11+
int8_t BUSY = -1)
12+
: Adafruit_IL91874(264, 176, SID, SCLK, DC, RST, CS, SRCS, MISO, -1){};
13+
14+
ThinkInk_270_Grayscale4_W3(int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
15+
int8_t BUSY = -1, SPIClass *spi = &SPI)
16+
: Adafruit_IL91874(264, 176, DC, RST, CS, SRCS, -1, spi){};
17+
18+
void begin(thinkinkmode_t mode = THINKINK_MONO) {
19+
Adafruit_IL91874::begin(true);
20+
21+
setBlackBuffer(0, true); // black defaults to inverted
22+
setColorBuffer(1, true); // red defaults to not inverted
23+
24+
if (mode == THINKINK_MONO) {
25+
_epd_init_code = NULL;
26+
_epd_lut_code = NULL;
27+
layer_colors[EPD_WHITE] = 0b00;
28+
layer_colors[EPD_BLACK] = 0b10;
29+
layer_colors[EPD_RED] = 0b10;
30+
layer_colors[EPD_GRAY] = 0b10;
31+
layer_colors[EPD_LIGHT] = 0b00;
32+
layer_colors[EPD_DARK] = 0b10;
33+
}
34+
35+
default_refresh_delay = 1000;
36+
powerDown();
37+
};
38+
};
39+
40+
#endif // _THINKINK_270_GRAY4_W3_H

0 commit comments

Comments
 (0)