6
6
// clang-format off
7
7
8
8
const uint8_t acep_default_init_code[] {
9
+ 0xFF , 10 , // wait a lil bit
9
10
ACEP_PANEL_SETTING, 2 , 0xEF , 0x08 , // LUT from OTP
10
11
ACEP_POWER_SETTING, 4 , 0x37 , 0x00 , 0x23 , 0x23 , // 0x05&0x05?
11
12
ACEP_POWER_OFF_SEQUENCE, 1 , 0x00 ,
@@ -16,6 +17,8 @@ const uint8_t acep_default_init_code[] {
16
17
ACEP_TCON, 1 , 0x22 ,
17
18
ACEP_RESOLUTION, 4 , 0x02 , 0x58 , 0x01 , 0xC0 ,
18
19
ACEP_PWS, 1 , 0xAA ,
20
+ 0xFF , 100 , // 100 ms delay
21
+ ACEP_CDI, 1 , 0x37 ,
19
22
0xFE };
20
23
21
24
// clang-format on
@@ -119,7 +122,7 @@ void Adafruit_ACEP::begin(bool reset) {
119
122
Adafruit_EPD::begin (reset);
120
123
121
124
delay (100 );
122
- powerDown ();
125
+ // powerDown();
123
126
}
124
127
125
128
/* *************************************************************************/
@@ -128,20 +131,25 @@ void Adafruit_ACEP::begin(bool reset) {
128
131
*/
129
132
/* *************************************************************************/
130
133
void Adafruit_ACEP::update () {
134
+
131
135
uint8_t buf[4 ];
132
- /*
133
- // clear data
136
+ /* **************** clear data first */
134
137
buf[0 ] = 0x02 ;
135
138
buf[1 ] = 0x58 ;
136
139
buf[2 ] = 0x01 ;
137
140
buf[3 ] = 0xC0 ;
138
141
EPD_command (ACEP_RESOLUTION, buf, 4 );
142
+
139
143
EPD_command (ACEP_DTM);
140
- for (int i=0; i< 134400/256; i++) {
144
+ uint32_t remaining = (600UL * 448UL / 2 );
145
+ while (remaining) {
141
146
uint8_t block[256 ];
142
- memset(block, 0x77, 256);
143
- EPD_data(block, 256);
147
+ uint32_t numbytes = min (remaining, sizeof (block));
148
+ memset (block, 0x77 , numbytes);
149
+ EPD_data (block, numbytes);
150
+ remaining -= numbytes;
144
151
}
152
+
145
153
EPD_command (ACEP_POWER_ON);
146
154
busy_wait ();
147
155
EPD_command (ACEP_DISPLAY_REFRESH);
@@ -154,26 +162,40 @@ void Adafruit_ACEP::update() {
154
162
}
155
163
} else {
156
164
delay (BUSY_WAIT);
157
- }*/
165
+ }
166
+
167
+ delay (500 );
158
168
159
169
// actual data
160
- // clear data
170
+ // setresolution, write data
161
171
buf[0 ] = 0x02 ;
162
172
buf[1 ] = 0x58 ;
163
173
buf[2 ] = 0x01 ;
164
174
buf[3 ] = 0xC0 ;
165
175
EPD_command (ACEP_RESOLUTION, buf, 4 );
166
176
EPD_command (ACEP_DTM);
167
- for (int i = 0 ; i < 134400 / 256 ; i++) {
177
+
178
+ remaining = (600UL * 448UL / 2 );
179
+ while (remaining) {
168
180
uint8_t block[256 ];
169
- memset (block, ((i % 6 ) << 4 ) | (i % 6 ), 256 );
170
- EPD_data (block, 256 );
181
+ uint32_t numbytes = min (remaining, sizeof (block));
182
+ memset (block, 0x44 , numbytes);
183
+ EPD_data (block, numbytes);
184
+ remaining -= numbytes;
171
185
}
186
+
172
187
EPD_command (ACEP_POWER_ON);
173
188
busy_wait ();
174
189
EPD_command (ACEP_DISPLAY_REFRESH);
175
190
busy_wait ();
176
191
EPD_command (ACEP_POWER_OFF);
192
+ if (_busy_pin >= 0 ) {
193
+ while (digitalRead (_busy_pin)) { // wait for busy LOW
194
+ delay (10 );
195
+ }
196
+ } else {
197
+ delay (BUSY_WAIT);
198
+ }
177
199
}
178
200
179
201
/* *************************************************************************/
@@ -193,11 +215,11 @@ void Adafruit_ACEP::powerUp() {
193
215
init_code = _epd_init_code;
194
216
}
195
217
EPD_commandList (init_code);
196
- delay (1000 );
197
- buf[0 ] = 0x37 ;
198
- EPD_command (ACEP_CDI, buf, 1 );
218
+ delay (100 );
199
219
}
200
220
221
+
222
+
201
223
/* *************************************************************************/
202
224
/* !
203
225
@brief wind down the display
0 commit comments