Skip to content

Commit 69038bd

Browse files
authored
Merge pull request #25 from adafruit/shiny
Add SSD1680 (?)
2 parents 0caa53e + f5a9222 commit 69038bd

File tree

4 files changed

+336
-0
lines changed

4 files changed

+336
-0
lines changed

Adafruit_EPD.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ void Adafruit_EPD::begin(bool reset) {
159159
sram.write8(0, K640_SEQUENTIAL_MODE, MCPSRAM_WRSR);
160160
}
161161

162+
Serial.println("set pins");
162163
// set pin directions
163164
pinMode(_dc_pin, OUTPUT);
164165
pinMode(_cs_pin, OUTPUT);
@@ -172,6 +173,7 @@ void Adafruit_EPD::begin(bool reset) {
172173
csHigh();
173174

174175
if (!hwSPI) {
176+
Serial.println("softserial");
175177
// set pins for software-SPI
176178
pinMode(_sid_pin, OUTPUT);
177179
pinMode(_sclk_pin, OUTPUT);
@@ -188,13 +190,16 @@ void Adafruit_EPD::begin(bool reset) {
188190
#endif
189191
}
190192

193+
Serial.println("hard reset");
191194
if (reset) {
192195
hardwareReset();
193196
}
194197

198+
Serial.println("busy");
195199
if (_busy_pin >= 0) {
196200
pinMode(_busy_pin, INPUT);
197201
}
202+
Serial.println("done!");
198203
}
199204

200205
/**************************************************************************/

Adafruit_EPD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,5 @@ class Adafruit_EPD : public Adafruit_GFX {
205205
#include "Adafruit_SSD1608.h"
206206
#include "Adafruit_SSD1675.h"
207207
#include "Adafruit_SSD1675B.h"
208+
#include "Adafruit_SSD1680.h"
208209
#endif /* _Adafruit_EPD_H_ */

Adafruit_SSD1680.cpp

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

Adafruit_SSD1680.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ifndef LIB_ADAFRUIT_SSD1680
2+
#define LIB_ADAFRUIT_SSD1680
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 SSD1680_DRIVER_CONTROL 0x01
11+
#define SSD1680_GATE_VOLTAGE 0x03
12+
#define SSD1680_SOURCE_VOLTAGE 0x04
13+
#define SSD1680_PROGOTP_INITIAL 0x08
14+
#define SSD1680_PROGREG_INITIAL 0x09
15+
#define SSD1680_READREG_INITIAL 0x0A
16+
#define SSD1680_BOOST_SOFTSTART 0x0C
17+
#define SSD1680_DEEP_SLEEP 0x10
18+
#define SSD1680_DATA_MODE 0x11
19+
#define SSD1680_SW_RESET 0x12
20+
#define SSD1680_TEMP_CONTROL 0x18
21+
#define SSD1680_TEMP_WRITE 0x1A
22+
#define SSD1680_MASTER_ACTIVATE 0x20
23+
#define SSD1680_DISP_CTRL1 0x21
24+
#define SSD1680_DISP_CTRL2 0x22
25+
#define SSD1680_WRITE_RAM1 0x24
26+
#define SSD1680_WRITE_RAM2 0x26
27+
#define SSD1680_WRITE_VCOM 0x2C
28+
#define SSD1680_READ_OTP 0x2D
29+
#define SSD1680_READ_STATUS 0x2F
30+
#define SSD1680_WRITE_LUT 0x32
31+
#define SSD1680_WRITE_BORDER 0x3C
32+
#define SSD1680_SET_RAMXPOS 0x44
33+
#define SSD1680_SET_RAMYPOS 0x45
34+
#define SSD1680_SET_RAMXCOUNT 0x4E
35+
#define SSD1680_SET_RAMYCOUNT 0x4F
36+
37+
/**************************************************************************/
38+
/*!
39+
@brief Class for interfacing with SSD1680 EPD drivers
40+
*/
41+
/**************************************************************************/
42+
class Adafruit_SSD1680 : public Adafruit_EPD {
43+
public:
44+
Adafruit_SSD1680(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
45+
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
46+
int8_t BUSY = -1);
47+
Adafruit_SSD1680(int width, int height, int8_t DC, int8_t RST, int8_t CS,
48+
int8_t SRCS, int8_t BUSY = -1);
49+
50+
void begin(bool reset = true);
51+
void powerUp();
52+
void update();
53+
void powerDown();
54+
55+
protected:
56+
uint8_t writeRAMCommand(uint8_t index);
57+
void setRAMAddress(uint16_t x, uint16_t y);
58+
void busy_wait();
59+
};
60+
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+
70+
#endif

0 commit comments

Comments
 (0)