3
3
4
4
#define BUSY_WAIT 500
5
5
6
+
7
+ // clang-format off
8
+
9
+ const uint8_t ssd1680_default_init_code[] {
10
+ SSD1680_SW_RESET, 0 , // soft reset
11
+ 0xFF , 20 , // busy wait
12
+ SSD1680_DATA_MODE, 1 , 0x03 , // Ram data entry mode
13
+ SSD1680_WRITE_BORDER, 1 , 0x05 , // border color
14
+
15
+ SSD1680_WRITE_VCOM, 1 , 0x36 , // Vcom Voltage
16
+ SSD1680_GATE_VOLTAGE, 1 , 0x17 , // Set gate voltage
17
+ SSD1680_SOURCE_VOLTAGE, 3 , 0x41 , 0x00 , 0x32 , // Set source voltage
18
+
19
+ SSD1680_SET_RAMXCOUNT, 1 , 1 ,
20
+ SSD1680_SET_RAMYCOUNT, 2 , 0 , 0 ,
21
+ 0xFE };
22
+
23
+ // clang-format on
24
+
25
+
6
26
/* *************************************************************************/
7
27
/* !
8
28
@brief constructor if using external SRAM chip and software SPI
@@ -58,8 +78,8 @@ Adafruit_SSD1680::Adafruit_SSD1680(int width, int height, int8_t SID,
58
78
*/
59
79
/* *************************************************************************/
60
80
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) {
81
+ int8_t CS, int8_t SRCS, int8_t BUSY, SPIClass *spi )
82
+ : Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY, spi ) {
63
83
if ((height % 8 ) != 0 ) {
64
84
height += 8 - (height % 8 );
65
85
}
@@ -140,23 +160,21 @@ void Adafruit_SSD1680::powerUp() {
140
160
delay (100 );
141
161
busy_wait ();
142
162
143
- // soft reset
144
- EPD_command (SSD1680_SW_RESET);
145
- busy_wait ();
163
+ const uint8_t *init_code = ssd1680_default_init_code;
146
164
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 );
165
+ if (_epd_init_code != NULL ) {
166
+ init_code = _epd_init_code;
167
+ }
168
+ EPD_commandList (init_code);
152
169
153
- // Ram data entry mode
154
- buf[0 ] = 0x03 ;
155
- EPD_command (SSD1680_DATA_MODE, buf, 1 );
170
+ uint8_t height = HEIGHT;
171
+ if ((height % 8 ) != 0 ) {
172
+ height += 8 - (height % 8 );
173
+ }
156
174
157
175
// Set ram X start/end postion
158
176
buf[0 ] = 0x01 ;
159
- buf[1 ] = HEIGHT / 8 ;
177
+ buf[1 ] = height / 8 ;
160
178
EPD_command (SSD1680_SET_RAMXPOS, buf, 2 );
161
179
162
180
// Set ram Y start/end postion
@@ -166,23 +184,6 @@ void Adafruit_SSD1680::powerUp() {
166
184
buf[3 ] = (WIDTH - 1 ) >> 8 ;
167
185
EPD_command (SSD1680_SET_RAMYPOS, buf, 4 );
168
186
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
187
188
// Set LUT
188
189
/*
@@ -191,14 +192,13 @@ void Adafruit_SSD1680::powerUp() {
191
192
EPD_command(SSD1680_WRITE_LUT, LUT_DATA, 70);
192
193
*/
193
194
194
- // set RAM x address count
195
- buf[0 ] = 1 ;
196
- EPD_command (SSD1680_SET_RAMXCOUNT, buf, 1 );
197
195
198
- // set RAM y address count
199
- buf[0 ] = 0 ;
200
- buf[1 ] = 0 ;
201
- EPD_command (SSD1680_SET_RAMYCOUNT, buf, 2 );
196
+ // Set display size and driver output control
197
+ buf[0 ] = (WIDTH - 1 );
198
+ buf[1 ] = (WIDTH - 1 ) >> 8 ;
199
+ buf[2 ] = 0x00 ;
200
+ EPD_command (SSD1680_DRIVER_CONTROL, buf, 3 );
201
+
202
202
}
203
203
204
204
/* *************************************************************************/
0 commit comments