Skip to content

Commit 41f2164

Browse files
committed
add (nonworking) acep
1 parent 9e497c5 commit 41f2164

File tree

3 files changed

+295
-0
lines changed

3 files changed

+295
-0
lines changed

src/Adafruit_EPD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,6 @@ class Adafruit_EPD : public Adafruit_GFX {
185185
#include "drivers/Adafruit_SSD1680.h"
186186
#include "drivers/Adafruit_SSD1681.h"
187187
#include "drivers/Adafruit_UC8276.h"
188+
#include "drivers/Adafruit_ACeP.h"
188189

189190
#endif /* _ADAFRUIT_EPD_H_ */

src/drivers/Adafruit_ACeP.cpp

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
#include "Adafruit_ACeP.h"
2+
#include "Adafruit_EPD.h"
3+
4+
#define BUSY_WAIT 500
5+
6+
7+
// clang-format off
8+
9+
const uint8_t acep_default_init_code[] {
10+
ACEP_PANEL_SETTING, 2, 0xEF, 0x08, // LUT from OTP
11+
ACEP_POWER_SETTING, 4, 0x37, 0x00, 0x23, 0x23, // 0x05&0x05?
12+
ACEP_POWER_OFF_SEQUENCE, 1, 0x00,
13+
ACEP_BOOSTER_SOFT_START, 3, 0xC7, 0xC7, 0x1D,
14+
ACEP_PLL, 1, 0x3C,
15+
ACEP_TSE, 1, 0x00,
16+
ACEP_CDI, 1, 0x37,
17+
ACEP_TCON, 1, 0x22,
18+
ACEP_RESOLUTION, 4, 0x02, 0x58, 0x01, 0xC0,
19+
ACEP_PWS, 1, 0xAA,
20+
0xFE};
21+
22+
// clang-format on
23+
24+
25+
/**************************************************************************/
26+
/*!
27+
@brief constructor if using external SRAM chip and software SPI
28+
@param width the width of the display in pixels
29+
@param height the height of the display in pixels
30+
@param SID the SID pin to use
31+
@param SCLK the SCLK pin to use
32+
@param DC the data/command pin to use
33+
@param RST the reset pin to use
34+
@param CS the chip select pin to use
35+
@param SRCS the SRAM chip select pin to use
36+
@param MISO the MISO pin to use
37+
@param BUSY the busy pin to use
38+
*/
39+
/**************************************************************************/
40+
Adafruit_ACEP::Adafruit_ACEP(int width, int height, int8_t SID,
41+
int8_t SCLK, int8_t DC, int8_t RST,
42+
int8_t CS, int8_t SRCS, int8_t MISO,
43+
int8_t BUSY)
44+
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
45+
46+
if ((width % 8) != 0) {
47+
width += 8 - (width % 8);
48+
}
49+
buffer1_size = (uint16_t)width * (uint16_t)height / 2;
50+
buffer2_size = 0;
51+
52+
if (SRCS >= 0) {
53+
use_sram = true;
54+
buffer1_addr = 0;
55+
buffer2_addr = 0;
56+
} else {
57+
buffer1 = (uint8_t *)malloc(buffer1_size);
58+
buffer2 = NULL;
59+
}
60+
61+
singleByteTxns = true;
62+
63+
}
64+
65+
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
66+
67+
/**************************************************************************/
68+
/*!
69+
@brief constructor if using on-chip RAM and hardware SPI
70+
@param width the width of the display in pixels
71+
@param height the height of the display in pixels
72+
@param DC the data/command pin to use
73+
@param RST the reset pin to use
74+
@param CS the chip select pin to use
75+
@param SRCS the SRAM chip select pin to use
76+
@param BUSY the busy pin to use
77+
*/
78+
/**************************************************************************/
79+
Adafruit_ACEP::Adafruit_ACEP(int width, int height, int8_t DC, int8_t RST,
80+
int8_t CS, int8_t SRCS, int8_t BUSY,
81+
SPIClass *spi)
82+
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY, spi) {
83+
84+
if ((height % 8) != 0) {
85+
height += 8 - (height % 8);
86+
}
87+
buffer1_size = (uint16_t)width * (uint16_t)height / 2;
88+
buffer2_size = 0;
89+
90+
if (SRCS >= 0) {
91+
use_sram = true;
92+
buffer1_addr = 0;
93+
buffer2_addr = 0;
94+
} else {
95+
buffer1 = (uint8_t *)malloc(buffer1_size);
96+
buffer2 = buffer1;
97+
}
98+
99+
singleByteTxns = true;
100+
}
101+
102+
/**************************************************************************/
103+
/*!
104+
@brief wait for busy signal to end
105+
*/
106+
/**************************************************************************/
107+
void Adafruit_ACEP::busy_wait(void) {
108+
if (_busy_pin >= 0) {
109+
while (! digitalRead(_busy_pin)) { // wait for busy high
110+
delay(10);
111+
}
112+
} else {
113+
delay(BUSY_WAIT);
114+
}
115+
}
116+
117+
/**************************************************************************/
118+
/*!
119+
@brief begin communication with and set up the display.
120+
@param reset if true the reset pin will be toggled.
121+
*/
122+
/**************************************************************************/
123+
void Adafruit_ACEP::begin(bool reset) {
124+
Adafruit_EPD::begin(reset);
125+
126+
delay(100);
127+
powerDown();
128+
}
129+
130+
/**************************************************************************/
131+
/*!
132+
@brief signal the display to update
133+
*/
134+
/**************************************************************************/
135+
void Adafruit_ACEP::update() {
136+
uint8_t buf[4];
137+
/*
138+
// clear data
139+
buf[0] = 0x02;
140+
buf[1] = 0x58;
141+
buf[2] = 0x01;
142+
buf[3] = 0xC0;
143+
EPD_command(ACEP_RESOLUTION, buf, 4);
144+
EPD_command(ACEP_DTM);
145+
for (int i=0; i< 134400/256; i++) {
146+
uint8_t block[256];
147+
memset(block, 0x77, 256);
148+
EPD_data(block, 256);
149+
}
150+
EPD_command(ACEP_POWER_ON);
151+
busy_wait();
152+
EPD_command(ACEP_DISPLAY_REFRESH);
153+
busy_wait();
154+
EPD_command(ACEP_POWER_OFF);
155+
156+
if (_busy_pin >= 0) {
157+
while (digitalRead(_busy_pin)) { // wait for busy LOW
158+
delay(10);
159+
}
160+
} else {
161+
delay(BUSY_WAIT);
162+
}*/
163+
164+
// actual data
165+
// clear data
166+
buf[0] = 0x02;
167+
buf[1] = 0x58;
168+
buf[2] = 0x01;
169+
buf[3] = 0xC0;
170+
EPD_command(ACEP_RESOLUTION, buf, 4);
171+
EPD_command(ACEP_DTM);
172+
for (int i=0; i< 134400/256; i++) {
173+
uint8_t block[256];
174+
memset(block, ((i % 6) << 4) | (i %6), 256);
175+
EPD_data(block, 256);
176+
}
177+
EPD_command(ACEP_POWER_ON);
178+
busy_wait();
179+
EPD_command(ACEP_DISPLAY_REFRESH);
180+
busy_wait();
181+
EPD_command(ACEP_POWER_OFF);
182+
}
183+
184+
/**************************************************************************/
185+
/*!
186+
@brief start up the display
187+
*/
188+
/**************************************************************************/
189+
void Adafruit_ACEP::powerUp() {
190+
uint8_t buf[5];
191+
192+
hardwareReset();
193+
delay(200);
194+
busy_wait();
195+
const uint8_t *init_code = acep_default_init_code;
196+
197+
if (_epd_init_code != NULL) {
198+
init_code = _epd_init_code;
199+
}
200+
EPD_commandList(init_code);
201+
delay(1000);
202+
buf[0] = 0x37;
203+
EPD_command(ACEP_CDI, buf, 1);
204+
}
205+
206+
/**************************************************************************/
207+
/*!
208+
@brief wind down the display
209+
*/
210+
/**************************************************************************/
211+
212+
void Adafruit_ACEP::powerDown(void) {
213+
uint8_t buf[1];
214+
215+
delay(1000);
216+
217+
// deep sleep
218+
buf[0] = 0xA5;
219+
EPD_command(ACEP_DEEP_SLEEP, buf, 1);
220+
221+
delay(100);
222+
}
223+
224+
/**************************************************************************/
225+
/*!
226+
@brief Send the specific command to start writing to EPD display RAM
227+
@param index The index for which buffer to write (0 or 1 or tri-color
228+
displays) Ignored for monochrome displays.
229+
@returns The byte that is read from SPI at the same time as sending the
230+
command
231+
*/
232+
/**************************************************************************/
233+
uint8_t Adafruit_ACEP::writeRAMCommand(uint8_t index) {
234+
return EPD_command(ACEP_DTM, false);
235+
}
236+
237+
/**************************************************************************/
238+
/*!
239+
@brief Some displays require setting the RAM address pointer
240+
@param x X address counter value
241+
@param y Y address counter value
242+
*/
243+
/**************************************************************************/
244+
void Adafruit_ACEP::setRAMAddress(uint16_t x, uint16_t y) {
245+
246+
}

src/drivers/Adafruit_ACeP.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#ifndef LIB_ADAFRUIT_ACEP
2+
#define LIB_ADAFRUIT_ACEP
3+
4+
#include "Adafruit_EPD.h"
5+
#include <Arduino.h>
6+
7+
8+
#define ACEP_PANEL_SETTING 0x00
9+
#define ACEP_POWER_SETTING 0x01
10+
#define ACEP_POWER_OFF 0x02
11+
#define ACEP_POWER_OFF_SEQUENCE 0x03
12+
#define ACEP_POWER_ON 0x04
13+
#define ACEP_BOOSTER_SOFT_START 0x06
14+
#define ACEP_DEEP_SLEEP 0x07
15+
#define ACEP_DTM 0x10
16+
#define ACEP_DISPLAY_REFRESH 0x12
17+
#define ACEP_PLL 0x30
18+
#define ACEP_TSE 0x41
19+
#define ACEP_CDI 0x50
20+
#define ACEP_TCON 0x60
21+
#define ACEP_RESOLUTION 0x61
22+
#define ACEP_PWS 0xE3
23+
24+
/**************************************************************************/
25+
/*!
26+
@brief Class for interfacing with ACEP EPD drivers
27+
*/
28+
/**************************************************************************/
29+
class Adafruit_ACEP : public Adafruit_EPD {
30+
public:
31+
Adafruit_ACEP(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
32+
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
33+
int8_t BUSY = -1);
34+
Adafruit_ACEP(int width, int height, int8_t DC, int8_t RST, int8_t CS,
35+
int8_t SRCS, int8_t BUSY = -1, SPIClass *spi = &SPI);
36+
37+
void begin(bool reset = true);
38+
void powerUp();
39+
void powerDown();
40+
void update();
41+
42+
protected:
43+
uint8_t writeRAMCommand(uint8_t index);
44+
void setRAMAddress(uint16_t x, uint16_t y);
45+
void busy_wait();
46+
};
47+
48+
#endif

0 commit comments

Comments
 (0)