Skip to content

Commit e5d0c41

Browse files
committed
add 4.2 driver
1 parent d325a99 commit e5d0c41

File tree

6 files changed

+344
-15
lines changed

6 files changed

+344
-15
lines changed

src/Adafruit_EPD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class Adafruit_EPD : public Adafruit_GFX {
179179
#include "drivers/Adafruit_IL0398.h"
180180
#include "drivers/Adafruit_IL91874.h"
181181
#include "drivers/Adafruit_SSD1608.h"
182+
#include "drivers/Adafruit_SSD1619.h"
182183
#include "drivers/Adafruit_SSD1675.h"
183184
#include "drivers/Adafruit_SSD1675B.h"
184185
#include "drivers/Adafruit_SSD1680.h"

src/Adafruit_ThinkInk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ typedef enum {
66

77
#include "panels/ThinkInk_154_Tricolor_Z17.h"
88
#include "panels/ThinkInk_213_Tricolor_Z16.h"
9-
#include "panels/ThinkInk_213_Tricolor_RH.h"
9+
#include "panels/ThinkInk_213_Tricolor_RW.h"
1010
#include "panels/ThinkInk_270_Tricolor_C44.h"
1111
#include "panels/ThinkInk_290_Tricolor_Z10.h"
1212

src/drivers/Adafruit_SSD1619.cpp

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
#include "Adafruit_SSD1619.h"
2+
#include "Adafruit_EPD.h"
3+
4+
#define BUSY_WAIT 500
5+
6+
// clang-format off
7+
8+
const uint8_t ssd1619_default_init_code[] {
9+
SSD1619_SW_RESET, 0, // soft reset
10+
0xFF, 20, // busy wait
11+
12+
SSD1619_SET_ANALOGBLOCK, 1, 0x54, // set analog block control
13+
SSD1619_SET_DIGITALBLOCK, 1, 0x3B, // set digital block control
14+
15+
SSD1608_DRIVER_CONTROL, 3, 0x2B, 0x01, 0x00,
16+
SSD1619_DATA_MODE, 1, 0x01, // Ram data entry mode
17+
18+
SSD1608_SET_RAMXPOS, 2, 0x0, 0x31,
19+
SSD1608_SET_RAMYPOS, 4, 0x2B, 0x1, 0x00, 0x00,
20+
21+
SSD1619_WRITE_BORDER, 1, 0x01, // border color
22+
SSD1619_TEMP_CONTROL, 1, 0x80, // Temp control
23+
SSD1619_DISP_CTRL2, 1, 0xB1,
24+
25+
SSD1619_MASTER_ACTIVATE, 0,
26+
0xFF, 20, // busy wait
27+
28+
0xFE};
29+
30+
// clang-format on
31+
32+
33+
/**************************************************************************/
34+
/*!
35+
@brief constructor if using external SRAM chip and software SPI
36+
@param width the width of the display in pixels
37+
@param height the height of the display in pixels
38+
@param SID the SID pin to use
39+
@param SCLK the SCLK pin to use
40+
@param DC the data/command pin to use
41+
@param RST the reset pin to use
42+
@param CS the chip select pin to use
43+
@param SRCS the SRAM chip select pin to use
44+
@param MISO the MISO pin to use
45+
@param BUSY the busy pin to use
46+
*/
47+
/**************************************************************************/
48+
Adafruit_SSD1619::Adafruit_SSD1619(int width, int height, int8_t SID,
49+
int8_t SCLK, int8_t DC, int8_t RST,
50+
int8_t CS, int8_t SRCS, int8_t MISO,
51+
int8_t BUSY)
52+
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
53+
if ((height % 8) != 0) {
54+
height += 8 - (height % 8);
55+
}
56+
57+
buffer1_size = width * height / 8;
58+
buffer2_size = buffer1_size;
59+
60+
if (SRCS >= 0) {
61+
use_sram = true;
62+
buffer1_addr = 0;
63+
buffer2_addr = buffer1_size;
64+
buffer1 = buffer2 = NULL;
65+
} else {
66+
buffer1 = (uint8_t *)malloc(buffer1_size);
67+
buffer2 = (uint8_t *)malloc(buffer2_size);
68+
}
69+
70+
singleByteTxns = true;
71+
}
72+
73+
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
74+
75+
/**************************************************************************/
76+
/*!
77+
@brief constructor if using on-chip RAM and hardware SPI
78+
@param width the width of the display in pixels
79+
@param height the height of the display in pixels
80+
@param DC the data/command pin to use
81+
@param RST the reset pin to use
82+
@param CS the chip select pin to use
83+
@param SRCS the SRAM chip select pin to use
84+
@param BUSY the busy pin to use
85+
*/
86+
/**************************************************************************/
87+
Adafruit_SSD1619::Adafruit_SSD1619(int width, int height, int8_t DC, int8_t RST,
88+
int8_t CS, int8_t SRCS, int8_t BUSY,
89+
SPIClass *spi)
90+
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY, spi) {
91+
if ((height % 8) != 0) {
92+
height += 8 - (height % 8);
93+
}
94+
95+
buffer1_size = width * height / 8;
96+
buffer2_size = buffer1_size;
97+
98+
if (SRCS >= 0) {
99+
use_sram = true;
100+
buffer1_addr = 0;
101+
buffer2_addr = buffer1_size;
102+
buffer1 = buffer2 = NULL;
103+
} else {
104+
buffer1 = (uint8_t *)malloc(buffer1_size);
105+
buffer2 = (uint8_t *)malloc(buffer2_size);
106+
}
107+
108+
singleByteTxns = true;
109+
}
110+
111+
/**************************************************************************/
112+
/*!
113+
@brief wait for busy signal to end
114+
*/
115+
/**************************************************************************/
116+
void Adafruit_SSD1619::busy_wait(void) {
117+
if (_busy_pin >= 0) {
118+
while (digitalRead(_busy_pin)) { // wait for busy low
119+
delay(10);
120+
}
121+
} else {
122+
delay(BUSY_WAIT);
123+
}
124+
}
125+
126+
/**************************************************************************/
127+
/*!
128+
@brief begin communication with and set up the display.
129+
@param reset if true the reset pin will be toggled.
130+
*/
131+
/**************************************************************************/
132+
void Adafruit_SSD1619::begin(bool reset) {
133+
Adafruit_EPD::begin(reset);
134+
setBlackBuffer(0, true); // black defaults to inverted
135+
setColorBuffer(1, false); // red defaults to un inverted
136+
powerDown();
137+
}
138+
139+
/**************************************************************************/
140+
/*!
141+
@brief signal the display to update
142+
*/
143+
/**************************************************************************/
144+
void Adafruit_SSD1619::update() {
145+
uint8_t buf[1];
146+
147+
// display update sequence
148+
buf[0] = 0x40;
149+
EPD_command(SSD1619_DISP_CTRL1, buf, 1);
150+
buf[0] = 0xC7;
151+
EPD_command(SSD1619_DISP_CTRL2, buf, 1);
152+
153+
EPD_command(SSD1619_MASTER_ACTIVATE);
154+
busy_wait();
155+
156+
if (_busy_pin <= -1) {
157+
delay(1000);
158+
}
159+
}
160+
161+
162+
/**************************************************************************/
163+
/*!
164+
@brief start up the display
165+
*/
166+
/**************************************************************************/
167+
void Adafruit_SSD1619::powerUp() {
168+
uint8_t buf[5];
169+
170+
hardwareReset();
171+
delay(100);
172+
busy_wait();
173+
174+
const uint8_t *init_code = ssd1619_default_init_code;
175+
176+
if (_epd_init_code != NULL) {
177+
init_code = _epd_init_code;
178+
}
179+
EPD_commandList(init_code);
180+
181+
/*
182+
// Set display size and driver output control
183+
buf[0] = (WIDTH - 1);
184+
buf[1] = (WIDTH - 1) >> 8;
185+
buf[2] = 0x00;
186+
EPD_command(SSD1619_DRIVER_CONTROL, buf, 3);
187+
188+
189+
setRAMWindow(0, 0, (HEIGHT / 8) - 1, WIDTH - 1);
190+
*/
191+
}
192+
193+
/**************************************************************************/
194+
/*!
195+
@brief wind down the display
196+
*/
197+
/**************************************************************************/
198+
void Adafruit_SSD1619::powerDown() {
199+
uint8_t buf[1];
200+
// Only deep sleep if we can get out of it
201+
if (_reset_pin >= 0) {
202+
// deep sleep
203+
buf[0] = 0x01;
204+
EPD_command(SSD1619_DEEP_SLEEP, buf, 1);
205+
delay(100);
206+
} else {
207+
EPD_command(SSD1619_SW_RESET);
208+
busy_wait();
209+
}
210+
}
211+
212+
/**************************************************************************/
213+
/*!
214+
@brief Send the specific command to start writing to EPD display RAM
215+
@param index The index for which buffer to write (0 or 1 or tri-color
216+
displays) Ignored for monochrome displays.
217+
@returns The byte that is read from SPI at the same time as sending the
218+
command
219+
*/
220+
/**************************************************************************/
221+
uint8_t Adafruit_SSD1619::writeRAMCommand(uint8_t index) {
222+
if (index == 0) {
223+
return EPD_command(SSD1619_WRITE_RAM1, false);
224+
}
225+
if (index == 1) {
226+
return EPD_command(SSD1619_WRITE_RAM2, false);
227+
}
228+
return 0;
229+
}
230+
231+
/**************************************************************************/
232+
/*!
233+
@brief Some displays require setting the RAM address pointer
234+
@param x X address counter value
235+
@param y Y address counter value
236+
*/
237+
/**************************************************************************/
238+
void Adafruit_SSD1619::setRAMAddress(uint16_t x, uint16_t y) {
239+
uint8_t buf[2];
240+
241+
// set RAM x address count
242+
buf[0] = 0x00;
243+
EPD_command(SSD1619_SET_RAMXCOUNT, buf, 1);
244+
245+
// set RAM y address count
246+
buf[0] = 0x2B;
247+
buf[1] = 0x01;
248+
EPD_command(SSD1619_SET_RAMYCOUNT, buf, 2);
249+
}
250+
251+
252+
/**************************************************************************/
253+
/*!
254+
@brief Some displays require setting the RAM address pointer
255+
@param x X address counter value
256+
@param y Y address counter value
257+
*/
258+
/**************************************************************************/
259+
void Adafruit_SSD1619::setRAMWindow(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
260+
uint8_t buf[5];
261+
262+
// Set ram X start/end postion
263+
buf[0] = x1/8;
264+
buf[1] = x2/8;
265+
EPD_command(SSD1619_SET_RAMXPOS, buf, 2);
266+
267+
// Set ram Y start/end postion
268+
buf[0] = y1;
269+
buf[1] = y1 >> 8;
270+
buf[2] = y2;
271+
buf[3] = y2 >> 8;
272+
EPD_command(SSD1619_SET_RAMYPOS, buf, 4);
273+
}

src/drivers/Adafruit_SSD1619.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#ifndef LIB_ADAFRUIT_SSD1619
2+
#define LIB_ADAFRUIT_SSD1619
3+
4+
#include "Adafruit_EPD.h"
5+
#include <Arduino.h>
6+
7+
#define EPD_RAM_BW 0x10
8+
#define EPD_RAM_RED 0x13
9+
10+
#define SSD1619_DRIVER_CONTROL 0x01
11+
#define SSD1619_GATE_VOLTAGE 0x03
12+
#define SSD1619_SOURCE_VOLTAGE 0x04
13+
#define SSD1619_PROGOTP_INITIAL 0x08
14+
#define SSD1619_PROGREG_INITIAL 0x09
15+
#define SSD1619_READREG_INITIAL 0x0A
16+
#define SSD1619_BOOST_SOFTSTART 0x0C
17+
#define SSD1619_DEEP_SLEEP 0x10
18+
#define SSD1619_DATA_MODE 0x11
19+
#define SSD1619_SW_RESET 0x12
20+
#define SSD1619_TEMP_CONTROL 0x18
21+
#define SSD1619_TEMP_WRITE 0x1A
22+
#define SSD1619_MASTER_ACTIVATE 0x20
23+
#define SSD1619_DISP_CTRL1 0x21
24+
#define SSD1619_DISP_CTRL2 0x22
25+
#define SSD1619_WRITE_RAM1 0x24
26+
#define SSD1619_WRITE_RAM2 0x26
27+
#define SSD1619_WRITE_VCOM 0x2C
28+
#define SSD1619_READ_OTP 0x2D
29+
#define SSD1619_READ_STATUS 0x2F
30+
#define SSD1619_WRITE_LUT 0x32
31+
#define SSD1619_WRITE_BORDER 0x3C
32+
#define SSD1619_SET_RAMXPOS 0x44
33+
#define SSD1619_SET_RAMYPOS 0x45
34+
#define SSD1619_SET_RAMXCOUNT 0x4E
35+
#define SSD1619_SET_RAMYCOUNT 0x4F
36+
#define SSD1619_SET_ANALOGBLOCK 0x74
37+
#define SSD1619_SET_DIGITALBLOCK 0x7E
38+
39+
/**************************************************************************/
40+
/*!
41+
@brief Class for interfacing with SSD1619 EPD drivers
42+
*/
43+
/**************************************************************************/
44+
class Adafruit_SSD1619 : public Adafruit_EPD {
45+
public:
46+
Adafruit_SSD1619(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
47+
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
48+
int8_t BUSY = -1);
49+
Adafruit_SSD1619(int width, int height, int8_t DC, int8_t RST, int8_t CS,
50+
int8_t SRCS, int8_t BUSY = -1, SPIClass *spi = &SPI);
51+
52+
void begin(bool reset = true);
53+
void powerUp();
54+
void update(void);
55+
void powerDown();
56+
57+
protected:
58+
uint8_t writeRAMCommand(uint8_t index);
59+
void setRAMAddress(uint16_t x, uint16_t y);
60+
void setRAMWindow(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
61+
void busy_wait();
62+
};
63+
64+
#endif

src/drivers/Adafruit_SSD1680.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,4 @@ class Adafruit_SSD1680 : public Adafruit_EPD {
5858
void busy_wait();
5959
};
6060

61-
/*******************************************************************************/
62-
#define MAX_LINE_BYTES 16
63-
#define MAX_COLUMN_BYTES 296
64-
#define ALLSCREEN_BYTES 4736
65-
#define SPI_OUT 0
66-
#define SPI_IN 1
67-
#define MONO 0
68-
#define RED 1
69-
7061
#endif

src/panels/ThinkInk_213_Tricolor_RH.h renamed to src/panels/ThinkInk_213_Tricolor_RW.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#ifndef _THINKINK_213_TRICOLOR_RH_H
2-
#define _THINKINK_213_TRICOLOR_RH_H
1+
#ifndef _THINKINK_213_TRICOLOR_RW_H
2+
#define _THINKINK_213_TRICOLOR_RW_H
33

44
#include "Adafruit_EPD.h"
55

6-
class ThinkInk_213_Tricolor_RH : public Adafruit_SSD1680 {
6+
class ThinkInk_213_Tricolor_RW : public Adafruit_SSD1680 {
77
private:
88
public:
9-
ThinkInk_213_Tricolor_RH(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
9+
ThinkInk_213_Tricolor_RW(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)
1111
: Adafruit_SSD1680(250, 122, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY){};
1212

13-
ThinkInk_213_Tricolor_RH(int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
13+
ThinkInk_213_Tricolor_RW(int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
1414
int8_t BUSY = -1, SPIClass *spi = &SPI)
1515
: Adafruit_SSD1680(250, 122, DC, RST, CS, SRCS, BUSY, spi){};
1616

0 commit comments

Comments
 (0)