Skip to content

Commit a5f204e

Browse files
committed
Merge remote-tracking branch 'origin/master' into 4bpp_rotation
2 parents 0984992 + 7b38252 commit a5f204e

File tree

32 files changed

+1423
-974
lines changed

32 files changed

+1423
-974
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ To simplify the hardware setup, we provide an online tool that helps you quickly
3737
- ED103TC2-based displays
3838
- T133A01-based displays
3939
- JD79667_based displays
40-
> Note: When using a large-sized screen, please make sure to enable the PSRAM option in time. Otherwise, you will receive a prompt indicating a memory error!
40+
> Note: When using a large-sized screen(larger than or equal to 10.3inch), please make sure to enable the PSRAM option in time. Otherwise, you will receive a prompt indicating a memory error!
4141
## E-Paper Implementation
4242

4343
The library includes a comprehensive implementation for E-Paper displays, providing:

TFT_Drivers/SSD1680_Defines.h

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// Define color depth (1 bit for e-ink display)
2222
#define EPD_COLOR_DEPTH 1
2323

24+
#define USE_MUTIGRAY_EPAPER
25+
#define GRAY_LEVEL4 4
26+
2427
// Define no operation command
2528
#define EPD_NOP 0xFF
2629

@@ -66,6 +69,17 @@
6669
CHECK_BUSY(); \
6770
} while (0)
6871

72+
#define EPD_UPDATE_FAST() \
73+
do \
74+
{ \
75+
writecommand(0x22); \
76+
writedata(0xC7); \
77+
writecommand(0x20); \
78+
CHECK_BUSY(); \
79+
} while (0)
80+
81+
#define EPD_UPDATE_GRAY() EPD_UPDATE_FAST()
82+
6983
// Macro to enter deep sleep
7084
#define EPD_SLEEP() \
7185
do \
@@ -114,8 +128,44 @@
114128
CHECK_BUSY(); \
115129
} while (0)
116130

131+
#define EPD_INIT_GRAY() \
132+
do \
133+
{ \
134+
digitalWrite(TFT_RST, LOW); \
135+
delay(10); \
136+
digitalWrite(TFT_RST, HIGH); \
137+
delay(10); \
138+
writecommand(0x12); \
139+
CHECK_BUSY(); \
140+
writecommand(0x18); \
141+
writedata(0x80); \
142+
writecommand(0x22); \
143+
writedata(0xB1); \
144+
writecommand(0x20); \
145+
CHECK_BUSY(); \
146+
writecommand(0x1A); \
147+
writedata(0x5A); \
148+
writedata(0x00); \
149+
writecommand(0x22); \
150+
writedata(0x91); \
151+
writecommand(0x20); \
152+
CHECK_BUSY(); \
153+
} while (0)
154+
117155
// Macro to wake up device
118-
#define EPD_WAKEUP() EPD_INIT()
156+
#define EPD_WAKEUP() \
157+
do \
158+
{ \
159+
digitalWrite(TFT_RST, LOW); \
160+
delay(10); \
161+
digitalWrite(TFT_RST, HIGH); \
162+
delay(10); \
163+
writecommand(0x12); \
164+
delay(10); \
165+
CHECK_BUSY(); \
166+
} while (0)
167+
168+
#define EPD_WAKEUP_GRAY() EPD_WAKEUP()
119169

120170
// Macro to set display window
121171
#define EPD_SET_WINDOW(x1, y1, x2, y2) \
@@ -153,6 +203,110 @@
153203
} \
154204
} while (0)
155205

206+
207+
#define EPD_PUSH_NEW_GRAY_COLORS_FLIP(w, h, colors) \
208+
do \
209+
{ \
210+
EPD_INIT_GRAY(); \
211+
uint16_t i, j, k; \
212+
uint8_t temp1, temp2, temp3; \
213+
writecommand(0x24); \
214+
for(i = 0; i < (TFT_WIDTH * TFT_HEIGHT) / 8; i++) \
215+
{ \
216+
/* Read 4 input bytes = 8 pixels */ \
217+
uint8_t c0 = colors[i * 4 + 0]; \
218+
uint8_t c1 = colors[i * 4 + 1]; \
219+
uint8_t c2 = colors[i * 4 + 2]; \
220+
uint8_t c3 = colors[i * 4 + 3]; \
221+
/* Extract 8 pixels from bit5-4 and bit1-0 of each byte */ \
222+
uint8_t p0 = (c0 >> 4) & 0x03; \
223+
uint8_t p1 = (c0 >> 0) & 0x03; \
224+
uint8_t p2 = (c1 >> 4) & 0x03; \
225+
uint8_t p3 = (c1 >> 0) & 0x03; \
226+
uint8_t p4 = (c2 >> 4) & 0x03; \
227+
uint8_t p5 = (c2 >> 0) & 0x03; \
228+
uint8_t p6 = (c3 >> 4) & 0x03; \
229+
uint8_t p7 = (c3 >> 0) & 0x03; \
230+
/* Pack into original-style packed bytes (high 2-bit per pixel) */ \
231+
uint8_t packed_byte0 = (p0 << 6) | (p1 << 4) | (p2 << 2) | p3; \
232+
uint8_t packed_byte1 = (p4 << 6) | (p5 << 4) | (p6 << 2) | p7; \
233+
\
234+
temp3 = 0; \
235+
for(j = 0; j < 2; j++) \
236+
{ \
237+
temp1 = (j == 0) ? packed_byte0 : packed_byte1; \
238+
for(k = 0; k < 4; k++) \
239+
{ \
240+
temp2 = temp1 & 0xC0; \
241+
if(temp2 == 0xC0) \
242+
temp3 |= 0x01; \
243+
else if(temp2 == 0x00) \
244+
temp3 |= 0x00; \
245+
else if((temp2 >= 0x80) && (temp2 < 0xC0)) \
246+
temp3 |= 0x00; \
247+
else if(temp2 == 0x40) \
248+
temp3 |= 0x01; \
249+
if((j == 0 && k <= 3) || (j == 1 && k <= 2)) \
250+
{ \
251+
temp3 <<= 1; \
252+
temp1 <<= 2; \
253+
} \
254+
} \
255+
} \
256+
writedata(~temp3); \
257+
} \
258+
\
259+
writecommand(0x26); \
260+
for(i = 0; i < (TFT_WIDTH * TFT_HEIGHT) / 8; i++) \
261+
{ \
262+
uint8_t c0 = colors[i * 4 + 0]; \
263+
uint8_t c1 = colors[i * 4 + 1]; \
264+
uint8_t c2 = colors[i * 4 + 2]; \
265+
uint8_t c3 = colors[i * 4 + 3]; \
266+
uint8_t p0 = (c0 >> 4) & 0x03; \
267+
uint8_t p1 = (c0 >> 0) & 0x03; \
268+
uint8_t p2 = (c1 >> 4) & 0x03; \
269+
uint8_t p3 = (c1 >> 0) & 0x03; \
270+
uint8_t p4 = (c2 >> 4) & 0x03; \
271+
uint8_t p5 = (c2 >> 0) & 0x03; \
272+
uint8_t p6 = (c3 >> 4) & 0x03; \
273+
uint8_t p7 = (c3 >> 0) & 0x03; \
274+
uint8_t packed_byte0 = (p0 << 6) | (p1 << 4) | (p2 << 2) | p3; \
275+
uint8_t packed_byte1 = (p4 << 6) | (p5 << 4) | (p6 << 2) | p7; \
276+
\
277+
temp3 = 0; \
278+
for(j = 0; j < 2; j++) \
279+
{ \
280+
temp1 = (j == 0) ? packed_byte0 : packed_byte1; \
281+
for(k = 0; k < 4; k++) \
282+
{ \
283+
temp2 = temp1 & 0xC0; \
284+
if(temp2 == 0xC0) \
285+
temp3 |= 0x01; \
286+
else if(temp2 == 0x00) \
287+
temp3 |= 0x00; \
288+
else if((temp2 >= 0x80) && (temp2 < 0xC0)) \
289+
temp3 |= 0x01; \
290+
else if(temp2 == 0x40) \
291+
temp3 |= 0x00; \
292+
if((j == 0 && k <= 3) || (j == 1 && k <= 2)) \
293+
{ \
294+
temp3 <<= 1; \
295+
temp1 <<= 2; \
296+
} \
297+
} \
298+
} \
299+
writedata(~temp3); \
300+
} \
301+
} while (0)
302+
303+
#define EPD_PUSH_NEW_GRAY_COLORS(w, h, colors) \
304+
do \
305+
{ \
306+
EPD_INIT_GRAY(); \
307+
} while (0)
308+
309+
156310
// Macro to push old color data
157311
#define EPD_PUSH_OLD_COLORS(w, h, colors) \
158312
do \

TFT_Drivers/SSD1680_Init.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@
6464

6565
//set ic offset
6666
setViewport(COL_OFFSET ,ROW_OFFSET ,EPD_WIDTH ,EPD_HEIGHT);
67+
68+
setRotation(2);
6769
}

TFT_Drivers/SSD1681_Defines.h

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// Define color depth (1 bit for e-ink display, supports red/black/white)
2222
#define EPD_COLOR_DEPTH 1
2323

24+
#define USE_MUTIGRAY_EPAPER
25+
#define GRAY_LEVEL4 4
26+
2427
// Define no operation command
2528
#define EPD_NOP 0xFF
2629

@@ -66,6 +69,20 @@
6669
CHECK_BUSY(); \
6770
} while (0)
6871

72+
#define EPD_UPDATE_FAST() \
73+
do \
74+
{ \
75+
writecommand(0x22); \
76+
writedata(0xC7); \
77+
writecommand(0x20); \
78+
CHECK_BUSY(); \
79+
} while (0)
80+
81+
#define EPD_UPDATE_GRAY() EPD_UPDATE_FAST()
82+
83+
84+
85+
6986
// Macro to update display (partial refresh)
7087
#define EPD_PART_UPDATE() \
7188
do \
@@ -85,6 +102,31 @@
85102
delay(100); \
86103
} while (0)
87104

105+
#define EPD_INIT_GRAY() \
106+
do \
107+
{ \
108+
digitalWrite(TFT_RST, LOW); \
109+
delay(10); \
110+
digitalWrite(TFT_RST, HIGH); \
111+
delay(10); \
112+
writecommand(0x12);\
113+
CHECK_BUSY(); \
114+
writecommand(0x18); \
115+
writedata(0x80); \
116+
writecommand(0x22); \
117+
writedata(0xB1); \
118+
writecommand(0x20); \
119+
CHECK_BUSY(); \
120+
writecommand(0x1A); \
121+
writedata(0x5A); \
122+
writedata(0x00); \
123+
writecommand(0x22); \
124+
writedata(0x91); \
125+
writecommand(0x20); \
126+
CHECK_BUSY(); \
127+
} while (0)
128+
129+
88130
// Macro to wake up device
89131
#define EPD_WAKEUP() \
90132
do \
@@ -94,15 +136,121 @@
94136
digitalWrite(TFT_RST, HIGH); \
95137
delay(10); \
96138
writecommand(0x12); \
139+
delay(10); \
97140
CHECK_BUSY(); \
98141
} while (0)
99142

100-
// Macro to set display window (for partial refresh)
143+
#define EPD_WAKEUP_GRAY() EPD_WAKEUP()
144+
// Macro to set display window (for partial refresh)
101145
#define EPD_SET_WINDOW(x1, y1, x2, y2) \
102146
do \
103147
{ \
104148
} while (0)
105149

150+
151+
#define EPD_PUSH_NEW_GRAY_COLORS_FLIP(w, h, colors) \
152+
do \
153+
{ \
154+
EPD_INIT_GRAY(); \
155+
uint16_t i, j, k; \
156+
uint8_t temp1, temp2, temp3; \
157+
writecommand(0x24); \
158+
for(i = 0; i < (TFT_WIDTH * TFT_HEIGHT) / 8; i++) \
159+
{ \
160+
/* Read 4 input bytes = 8 pixels */ \
161+
uint8_t c0 = colors[i * 4 + 0]; \
162+
uint8_t c1 = colors[i * 4 + 1]; \
163+
uint8_t c2 = colors[i * 4 + 2]; \
164+
uint8_t c3 = colors[i * 4 + 3]; \
165+
/* Extract 8 pixels from bit5-4 and bit1-0 of each byte */ \
166+
uint8_t p0 = (c0 >> 4) & 0x03; \
167+
uint8_t p1 = (c0 >> 0) & 0x03; \
168+
uint8_t p2 = (c1 >> 4) & 0x03; \
169+
uint8_t p3 = (c1 >> 0) & 0x03; \
170+
uint8_t p4 = (c2 >> 4) & 0x03; \
171+
uint8_t p5 = (c2 >> 0) & 0x03; \
172+
uint8_t p6 = (c3 >> 4) & 0x03; \
173+
uint8_t p7 = (c3 >> 0) & 0x03; \
174+
/* Pack into original-style packed bytes (high 2-bit per pixel) */ \
175+
uint8_t packed_byte0 = (p0 << 6) | (p1 << 4) | (p2 << 2) | p3; \
176+
uint8_t packed_byte1 = (p4 << 6) | (p5 << 4) | (p6 << 2) | p7; \
177+
\
178+
temp3 = 0; \
179+
for(j = 0; j < 2; j++) \
180+
{ \
181+
temp1 = (j == 0) ? packed_byte0 : packed_byte1; \
182+
for(k = 0; k < 4; k++) \
183+
{ \
184+
temp2 = temp1 & 0xC0; \
185+
if(temp2 == 0xC0) \
186+
temp3 |= 0x01; \
187+
else if(temp2 == 0x00) \
188+
temp3 |= 0x00; \
189+
else if((temp2 >= 0x80) && (temp2 < 0xC0)) \
190+
temp3 |= 0x00; \
191+
else if(temp2 == 0x40) \
192+
temp3 |= 0x01; \
193+
if((j == 0 && k <= 3) || (j == 1 && k <= 2)) \
194+
{ \
195+
temp3 <<= 1; \
196+
temp1 <<= 2; \
197+
} \
198+
} \
199+
} \
200+
writedata(~temp3); \
201+
} \
202+
\
203+
writecommand(0x26); \
204+
for(i = 0; i < (TFT_WIDTH * TFT_HEIGHT) / 8; i++) \
205+
{ \
206+
uint8_t c0 = colors[i * 4 + 0]; \
207+
uint8_t c1 = colors[i * 4 + 1]; \
208+
uint8_t c2 = colors[i * 4 + 2]; \
209+
uint8_t c3 = colors[i * 4 + 3]; \
210+
uint8_t p0 = (c0 >> 4) & 0x03; \
211+
uint8_t p1 = (c0 >> 0) & 0x03; \
212+
uint8_t p2 = (c1 >> 4) & 0x03; \
213+
uint8_t p3 = (c1 >> 0) & 0x03; \
214+
uint8_t p4 = (c2 >> 4) & 0x03; \
215+
uint8_t p5 = (c2 >> 0) & 0x03; \
216+
uint8_t p6 = (c3 >> 4) & 0x03; \
217+
uint8_t p7 = (c3 >> 0) & 0x03; \
218+
uint8_t packed_byte0 = (p0 << 6) | (p1 << 4) | (p2 << 2) | p3; \
219+
uint8_t packed_byte1 = (p4 << 6) | (p5 << 4) | (p6 << 2) | p7; \
220+
\
221+
temp3 = 0; \
222+
for(j = 0; j < 2; j++) \
223+
{ \
224+
temp1 = (j == 0) ? packed_byte0 : packed_byte1; \
225+
for(k = 0; k < 4; k++) \
226+
{ \
227+
temp2 = temp1 & 0xC0; \
228+
if(temp2 == 0xC0) \
229+
temp3 |= 0x01; \
230+
else if(temp2 == 0x00) \
231+
temp3 |= 0x00; \
232+
else if((temp2 >= 0x80) && (temp2 < 0xC0)) \
233+
temp3 |= 0x01; \
234+
else if(temp2 == 0x40) \
235+
temp3 |= 0x00; \
236+
if((j == 0 && k <= 3) || (j == 1 && k <= 2)) \
237+
{ \
238+
temp3 <<= 1; \
239+
temp1 <<= 2; \
240+
} \
241+
} \
242+
} \
243+
writedata(~temp3); \
244+
} \
245+
} while (0)
246+
247+
#define EPD_PUSH_NEW_GRAY_COLORS(w, h, colors) \
248+
do \
249+
{ \
250+
EPD_INIT_GRAY(); \
251+
} while (0)
252+
253+
106254
// Macro to push new color data (black/white RAM)
107255
#define EPD_PUSH_NEW_COLORS(w, h, colors) \
108256
do \

0 commit comments

Comments
 (0)