Skip to content

Commit a5e25d7

Browse files
committed
add EK79686 initial driver
1 parent 41b9da4 commit a5e25d7

File tree

3 files changed

+290
-0
lines changed

3 files changed

+290
-0
lines changed

src/Adafruit_EPD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class Adafruit_EPD : public Adafruit_GFX {
175175
void dcLow();
176176
};
177177

178+
#include "drivers/Adafruit_EK79686.h"
178179
#include "drivers/Adafruit_IL0373.h"
179180
#include "drivers/Adafruit_IL0398.h"
180181
#include "drivers/Adafruit_IL91874.h"

src/drivers/Adafruit_EK79686.cpp

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
#include "Adafruit_EK79686.h"
2+
#include "Adafruit_EPD.h"
3+
4+
#define BUSY_WAIT 500
5+
6+
// clang-format off
7+
8+
const uint8_t ek79686_default_init_code[] {
9+
EK79686_PSR, 1, 0x0F, // LUT from OTP 128x296
10+
0x4D, 1, 0xAA, // FITI cmd (???)
11+
0x87, 1, 0x28,
12+
0x84, 1, 0x00,
13+
0x83, 1, 0x05,
14+
0xA8, 1, 0xDF,
15+
0xA9, 1, 0x05,
16+
0xB1, 1, 0xE8,
17+
0xAB, 1, 0xA1,
18+
0xB9, 1, 0x10,
19+
0x88, 1, 0x80,
20+
0x90, 1, 0x02,
21+
0x86, 1, 0x15,
22+
0x91, 1, 0x8D,
23+
0xAA, 1, 0x0F,
24+
EK79686_PON, 0,
25+
0xFE};
26+
27+
// clang-format on
28+
29+
/**************************************************************************/
30+
/*!
31+
@brief constructor if using external SRAM chip and software SPI
32+
@param width the width of the display in pixels
33+
@param height the height of the display in pixels
34+
@param SID the SID pin to use
35+
@param SCLK the SCLK pin to use
36+
@param DC the data/command pin to use
37+
@param RST the reset pin to use
38+
@param CS the chip select pin to use
39+
@param SRCS the SRAM chip select pin to use
40+
@param MISO the MISO pin to use
41+
@param BUSY the busy pin to use
42+
*/
43+
/**************************************************************************/
44+
Adafruit_EK79686::Adafruit_EK79686(int width, int height, int8_t SID,
45+
int8_t SCLK, int8_t DC, int8_t RST,
46+
int8_t CS, int8_t SRCS, int8_t MISO,
47+
int8_t BUSY)
48+
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
49+
50+
if ((width % 8) != 0) {
51+
width += 8 - (width % 8);
52+
}
53+
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
54+
buffer2_size = buffer1_size;
55+
56+
if (SRCS >= 0) {
57+
use_sram = true;
58+
buffer1_addr = 0;
59+
buffer2_addr = buffer1_size;
60+
buffer1 = buffer2 = NULL;
61+
} else {
62+
buffer1 = (uint8_t *)malloc(buffer1_size);
63+
buffer2 = (uint8_t *)malloc(buffer2_size);
64+
}
65+
}
66+
67+
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
68+
69+
/**************************************************************************/
70+
/*!
71+
@brief constructor if using on-chip RAM and hardware SPI
72+
@param width the width of the display in pixels
73+
@param height the height of the display in pixels
74+
@param DC the data/command pin to use
75+
@param RST the reset pin to use
76+
@param CS the chip select pin to use
77+
@param SRCS the SRAM chip select pin to use
78+
@param BUSY the busy pin to use
79+
*/
80+
/**************************************************************************/
81+
Adafruit_EK79686::Adafruit_EK79686(int width, int height, int8_t DC, int8_t RST,
82+
int8_t CS, int8_t SRCS, int8_t BUSY,
83+
SPIClass *spi)
84+
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY, spi) {
85+
86+
if ((height % 8) != 0) {
87+
height += 8 - (height % 8);
88+
}
89+
buffer1_size = (uint16_t)width * (uint16_t)height / 8;
90+
buffer2_size = buffer1_size;
91+
92+
if (SRCS >= 0) {
93+
use_sram = true;
94+
buffer1_addr = 0;
95+
buffer2_addr = buffer1_size;
96+
buffer1 = buffer2 = NULL;
97+
} else {
98+
buffer1 = (uint8_t *)malloc(buffer1_size);
99+
buffer2 = (uint8_t *)malloc(buffer2_size);
100+
}
101+
}
102+
103+
/**************************************************************************/
104+
/*!
105+
@brief wait for busy signal to end
106+
*/
107+
/**************************************************************************/
108+
void Adafruit_EK79686::busy_wait(void) {
109+
if (_busy_pin >= 0) {
110+
do {
111+
EPD_command(EK79686_FLG);
112+
delay(10);
113+
} while (!digitalRead(_busy_pin));
114+
} else {
115+
delay(BUSY_WAIT);
116+
}
117+
delay(200); // additional delay
118+
}
119+
120+
/**************************************************************************/
121+
/*!
122+
@brief begin communication with and set up the display.
123+
@param reset if true the reset pin will be toggled.
124+
*/
125+
/**************************************************************************/
126+
void Adafruit_EK79686::begin(bool reset) {
127+
Adafruit_EPD::begin(reset);
128+
setBlackBuffer(1, true); // black defaults to inverted
129+
setColorBuffer(0, false); // red defaults to not-inverted
130+
131+
powerDown();
132+
}
133+
134+
/**************************************************************************/
135+
/*!
136+
@brief signal the display to update
137+
*/
138+
/**************************************************************************/
139+
void Adafruit_EK79686::update() {
140+
EPD_command(EK79686_DRF);
141+
delay(10);
142+
busy_wait();
143+
}
144+
145+
/**************************************************************************/
146+
/*!
147+
@brief start up the display
148+
*/
149+
/**************************************************************************/
150+
void Adafruit_EK79686::powerUp() {
151+
uint8_t buf[5];
152+
153+
hardwareReset();
154+
delay(10);
155+
156+
const uint8_t *init_code = ek79686_default_init_code;
157+
158+
if (_epd_init_code != NULL) {
159+
init_code = _epd_init_code;
160+
}
161+
EPD_commandList(init_code);
162+
163+
if (_epd_lut_code) {
164+
EPD_commandList(_epd_lut_code);
165+
}
166+
busy_wait();
167+
}
168+
169+
/**************************************************************************/
170+
/*!
171+
@brief wind down the display
172+
*/
173+
/**************************************************************************/
174+
175+
void Adafruit_EK79686::powerDown(void) {
176+
uint8_t buf[1];
177+
178+
EPD_command(EK79686_POF); // power off
179+
busy_wait();
180+
181+
buf[0] = 0xA5;
182+
EPD_command(EK79686_DSLP, buf, 1);
183+
}
184+
185+
/**************************************************************************/
186+
/*!
187+
@brief Send the specific command to start writing to EPD display RAM
188+
@param index The index for which buffer to write (0 or 1 or tri-color
189+
displays) Ignored for monochrome displays.
190+
@returns The byte that is read from SPI at the same time as sending the
191+
command
192+
*/
193+
/**************************************************************************/
194+
uint8_t Adafruit_EK79686::writeRAMCommand(uint8_t index) {
195+
if (index == 0) {
196+
return EPD_command(EK79686_DTM1, false);
197+
}
198+
if (index == 1) {
199+
return EPD_command(EK79686_DTM2, false);
200+
}
201+
return 0;
202+
}
203+
204+
/**************************************************************************/
205+
/*!
206+
@brief Some displays require setting the RAM address pointer
207+
@param x X address counter value
208+
@param y Y address counter value
209+
*/
210+
/**************************************************************************/
211+
void Adafruit_EK79686::setRAMAddress(uint16_t x, uint16_t y) {}

src/drivers/Adafruit_EK79686.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#ifndef LIB_ADAFRUIT_EK79686
2+
#define LIB_ADAFRUIT_EK79686
3+
4+
#include "Adafruit_EPD.h"
5+
#include <Arduino.h>
6+
7+
#define EK79686_PSR 0x00
8+
#define EK79686_PWR 0x01
9+
#define EK79686_POF 0x02
10+
#define EK79686_PFS 0x03
11+
#define EK79686_PON 0x04
12+
#define EK79686_PMEAS 0x05
13+
#define EK79686_BTST 0x06
14+
#define EK79686_DSLP 0x07
15+
#define EK79686_DTM1 0x10
16+
#define EK79686_DSP 0x11
17+
#define EK79686_DRF 0x12
18+
#define EK79686_DTM2 0x13
19+
#define EK79686_PDTM1 0x14
20+
#define EK79686_PDTM2 0x15
21+
#define EK79686_PDRF 0x16
22+
#define EK79686_LUT1 0x20
23+
#define EK79686_LUTWW 0x21
24+
#define EK79686_LUTBW 0x22
25+
#define EK79686_LUTWB 0x23
26+
#define EK79686_LUTBB 0x24
27+
#define EK79686_LUTC 0x25
28+
#define EK79686_SETVCOM 0x26
29+
#define EK79686_OSC 0x30
30+
#define EK79686_TSC 0x40
31+
#define EK79686_TSE 0x41
32+
#define EK79686_TSW 0x42
33+
#define EK79686_TSR 0x43
34+
#define EK79686_CDI 0x50
35+
#define EK79686_LPD 0x51
36+
#define EK79686_TCON 0x60
37+
#define EK79686_TRES 0x61
38+
#define EK79686_GSST 0x62
39+
#define EK79686_REV 0x70
40+
#define EK79686_FLG 0x71
41+
#define EK79686_AMV 0x80
42+
#define EK79686_VV 0x81
43+
#define EK79686_VDCS 0x82
44+
#define EK79686_PGM 0xA0
45+
#define EK79686_APG 0xA1
46+
#define EK79686_ROTP 0xA2
47+
#define EK79686_CCSET 0xE0
48+
#define EK79686_TSSET 0xE5
49+
#define EK79686_LVD 0xE6
50+
#define EK79686_PNLBRK 0xE7
51+
#define EK79686_PWRSAV 0xE8
52+
#define EK79686_AUTOSEQ 0xE9
53+
54+
/**************************************************************************/
55+
/*!
56+
@brief Class for interfacing with EK79686 EPD drivers
57+
*/
58+
/**************************************************************************/
59+
class Adafruit_EK79686 : public Adafruit_EPD {
60+
public:
61+
Adafruit_EK79686(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
62+
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
63+
int8_t BUSY = -1);
64+
Adafruit_EK79686(int width, int height, int8_t DC, int8_t RST, int8_t CS,
65+
int8_t SRCS, int8_t BUSY = -1, SPIClass *spi = &SPI);
66+
67+
void begin(bool reset = true);
68+
void powerUp();
69+
void powerDown();
70+
void update();
71+
72+
protected:
73+
uint8_t writeRAMCommand(uint8_t index);
74+
void setRAMAddress(uint16_t x, uint16_t y);
75+
void busy_wait();
76+
};
77+
78+
#endif

0 commit comments

Comments
 (0)