Skip to content

Commit d8e0911

Browse files
committed
add:add support for 2.13inch BWRY epaper.(JD79676)
1 parent c702db6 commit d8e0911

File tree

9 files changed

+382
-3
lines changed

9 files changed

+382
-3
lines changed

TFT_Drivers/JD79667_Rotation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// JD79686B_Rotation.h
21
rotation = m % 4;
32

43
writecommand(EPD_PNLSET);

TFT_Drivers/JD79676_Defines.h

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#ifndef EPD_WIDTH
2+
#define EPD_WIDTH 128
3+
#endif
4+
5+
#ifndef EPD_HEIGHT
6+
#define EPD_HEIGHT 250
7+
#endif
8+
9+
#ifndef TFT_WIDTH
10+
#define TFT_WIDTH EPD_WIDTH
11+
#endif
12+
13+
#ifndef TFT_HEIGHT
14+
#define TFT_HEIGHT EPD_HEIGHT
15+
#endif
16+
17+
#define EPD_COLOR_DEPTH 4
18+
19+
20+
21+
#define EPD_NOP 0xFF // No operation command (not supported)
22+
#define EPD_PNLSET 0x00 // Panel setting (R00H PSR)
23+
#define EPD_DISPON 0x04 // Power on (R04H PON)
24+
#define EPD_DISPOFF 0x02 // Power off (R02H POF)
25+
#define EPD_SLPIN 0x07 // Enter deep sleep (R07H DSLP)
26+
#define EPD_SLPOUT 0xFF // Exit sleep (not supported, requires wake-up)
27+
#define EPD_PTLIN 0x91 // Partial display in (R91H PTIN)
28+
#define EPD_PTLOUT 0x92 // Partial display out (R92H PTOUT)
29+
#define EPD_PTLW 0x90 // Partial display window setting (R90H PTL)
30+
31+
#define TFT_SWRST 0xFF // Software reset (not supported)
32+
#define TFT_CASET 0xFF // Column address setting (not supported)
33+
#define TFT_PASET 0xFF // Page address setting (not supported)
34+
#define TFT_RAMWR 0x13 // Write RAM (R13H DTM2, red data)
35+
#define TFT_RAMRD 0xFF // Read RAM (not supported)
36+
#define TFT_INVON 0xFF // Display inversion on (not supported)
37+
#define TFT_INVOFF 0xFF // Display inversion off (not supported)
38+
#define TFT_INIT_DELAY 0 // Initialization delay (none)
39+
40+
#ifdef TFT_BUSY
41+
#define CHECK_BUSY() \
42+
do \
43+
{ \
44+
while (!digitalRead(TFT_BUSY)) \
45+
; \
46+
} while (0)
47+
#else
48+
#define CHECK_BUSY()
49+
#endif
50+
51+
#define EPD_INIT() \
52+
do \
53+
{ \
54+
writecommand(0x4D);\
55+
writedata(0x78);\
56+
writecommand(0x00); \
57+
writedata(0x0F);\
58+
writedata(0x29);\
59+
writecommand(0x01); \
60+
writedata(0x07);\
61+
writecommand(0x03); \
62+
writedata(0x10);\
63+
writedata(0x54);\
64+
writedata(0x44);\
65+
writecommand(0x06); \
66+
writedata(0x0F);\
67+
writedata(0x0A);\
68+
writedata(0x2F);\
69+
writedata(0x25);\
70+
writedata(0x22);\
71+
writedata(0x2E);\
72+
writedata(0x21); \
73+
writecommand(0x50);\
74+
writedata(0x37);\
75+
writecommand(0x60); \
76+
writedata(0x02);\
77+
writedata(0x02);\
78+
writecommand(0x61); \
79+
writedata(128/256); \
80+
writedata(128%256); \
81+
writedata(250/256); \
82+
writedata(250%256); \
83+
writecommand(0xE7);\
84+
writedata(0x1C);\
85+
writecommand(0xE3); \
86+
writedata(0x22);\
87+
writecommand(0xB4);\
88+
writedata(0xD0);\
89+
writecommand(0xB5);\
90+
writedata(0x03);\
91+
writecommand(0xE9);\
92+
writedata(0x01); \
93+
writecommand(0x30);\
94+
writedata(0x08); \
95+
writecommand(0x04);\
96+
CHECK_BUSY(); \
97+
} while (0)
98+
99+
#define EPD_UPDATE() \
100+
do \
101+
{ \
102+
writecommand(0x12); \
103+
writedata(0x00); \
104+
CHECK_BUSY(); \
105+
} while (0)
106+
107+
#define EPD_SLEEP() \
108+
do \
109+
{ \
110+
writecommand(0x02); \
111+
CHECK_BUSY(); \
112+
delay(100); \
113+
writecommand(0x07); \
114+
writedata(0xA5); \
115+
} while (0)
116+
117+
#define EPD_WAKEUP() \
118+
do \
119+
{ \
120+
digitalWrite(TFT_RST, LOW); \
121+
delay(20); \
122+
digitalWrite(TFT_RST, HIGH); \
123+
delay(20); \
124+
CHECK_BUSY(); \
125+
EPD_INIT(); \
126+
} while (0)
127+
128+
#define EPD_SET_WINDOW(x1, y1, x2, y2) \
129+
do \
130+
{ \
131+
} while (0)
132+
133+
#define COLOR_GET(color) ( \
134+
(color) == 0x00 ? 0x01 : \
135+
(color) == 0x01 ? 0x02 : \
136+
(color) == 0x02 ? 0x03 : \
137+
(color) == 0x03 ? 0x00 : \
138+
0x00 \
139+
)
140+
141+
#define EPD_PUSH_NEW_COLORS(w, h, colors) \
142+
do \
143+
{ \
144+
uint16_t bytes_per_row = (w) / 2; \
145+
uint8_t temp1, temp2, temp3, temp4; \
146+
writecommand(0x10); \
147+
for (uint16_t row = 0; row < (h) ; row++) \
148+
{ \
149+
for(uint16_t col = 0; col < bytes_per_row; col+=2) \
150+
{ \
151+
uint8_t b = (colors[bytes_per_row *row+col ]) ; \
152+
uint8_t c = (colors[bytes_per_row *row+col + 1]) ; \
153+
temp1 = (b >> 4) & 0x0F;\
154+
temp2 = b & 0x0F;\
155+
temp3 = (c >> 4) & 0x0F;\
156+
temp4 = c & 0x0F;\
157+
writedata(((COLOR_GET(temp1) <<6)|( COLOR_GET(temp2) << 4 ) |( COLOR_GET(temp3) << 2 ) |( COLOR_GET(temp4) << 0 )));\
158+
} \
159+
} \
160+
} while (0)
161+
162+
#define EPD_PUSH_NEW_COLORS_FLIP(w, h, colors) \
163+
do \
164+
{ \
165+
uint16_t bytes_per_row = (w) / 2; \
166+
uint8_t temp1, temp2, temp3, temp4; \
167+
writecommand(0x10); \
168+
for (uint16_t row = 0; row < (h); row++) \
169+
{ \
170+
uint16_t start = row * bytes_per_row; \
171+
for (uint16_t col = 0; col < bytes_per_row; col+=2) \
172+
{ \
173+
uint8_t b = (colors[bytes_per_row *row + (bytes_per_row - 1 - col)]) ;\
174+
uint8_t c = (colors[bytes_per_row *row + (bytes_per_row - 1 - col) - 1]) ;\
175+
temp1 = (b >> 4) & 0x0F;\
176+
temp2 = b & 0x0F;\
177+
temp3 = (c >> 4) & 0x0F;\
178+
temp4 = c & 0x0F;\
179+
writedata(((COLOR_GET(temp1) <<6)|( COLOR_GET(temp2) << 4 ) |( COLOR_GET(temp3) << 2 ) |( COLOR_GET(temp4) << 0 )));\
180+
} \
181+
} \
182+
} while (0)
183+
184+
#define EPD_PUSH_OLD_COLORS(w, h, colors) \
185+
do \
186+
{ \
187+
} while (0)
188+
189+
#define EPD_PUSH_OLD_COLORS_FLIP(w, h, colors) \
190+
do \
191+
{ \
192+
\
193+
} while (0)
194+
195+
#define EPD_SET_TEMP(temp) \
196+
do \
197+
{ \
198+
} while (0)

TFT_Drivers/JD79676_Rotation.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
rotation = m % 4;
2+
3+
writecommand(EPD_PNLSET);
4+
switch (rotation) {
5+
case 0: // Portrait
6+
writedata(0x1F); // 0b00011111
7+
_width = _init_width;
8+
_height = _init_height;
9+
break;
10+
case 1: // Landscape (Portrait + 90)
11+
writedata(0x1B); // 0b00011011
12+
_width = _init_height;
13+
_height = _init_width;
14+
break;
15+
case 2: // Inverted Portrait
16+
writedata(0x13); // 0b00010011
17+
_width = _init_width;
18+
_height = _init_height;
19+
break;
20+
case 3: // Landscape (Portrait + 270)
21+
writedata(0x17); // 0b00010111
22+
_width = _init_height;
23+
_height = _init_width;
24+
break;
25+
}

TFT_Drivers/JD79676_init.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// JD79686B_Init.h
2+
{
3+
#ifdef TFT_BUSY
4+
pinMode(TFT_BUSY, INPUT);
5+
#endif
6+
digitalWrite(TFT_RST, LOW);
7+
delay(20);
8+
digitalWrite(TFT_RST, HIGH);
9+
delay(50);
10+
CHECK_BUSY();
11+
writecommand(0x4D);
12+
writedata(0x78);
13+
14+
writecommand(0x00); //PSR
15+
writedata(0x0F);
16+
writedata(0x29);
17+
18+
writecommand(0x01); //PWRR
19+
writedata(0x07);
20+
21+
22+
writecommand(0x03); //POFS
23+
writedata(0x10);
24+
writedata(0x54);
25+
writedata(0x44);
26+
27+
writecommand(0x06); //BTST_P
28+
writedata(0x0F);
29+
writedata(0x0A);
30+
writedata(0x2F);
31+
writedata(0x25);
32+
writedata(0x22);
33+
writedata(0x2E);
34+
writedata(0x21);
35+
36+
writecommand(0x50); //CDI
37+
writedata(0x37);
38+
39+
writecommand(0x60); //TCON
40+
writedata(0x02);
41+
writedata(0x02);
42+
43+
writecommand(0x61); //TRES
44+
writedata(128/256); // Source_BITS_H
45+
writedata(128%256); // Source_BITS_L
46+
writedata(250/256); // Gate_BITS_H
47+
writedata(250%256); // Gate_BITS_L
48+
49+
writecommand(0xE7);
50+
writedata(0x1C);
51+
52+
writecommand(0xE3);
53+
writedata(0x22);
54+
55+
writecommand(0xB4);
56+
writedata(0xD0);
57+
writecommand(0xB5);
58+
writedata(0x03);
59+
60+
writecommand(0xE9);
61+
writedata(0x01);
62+
63+
writecommand(0x30);
64+
writedata(0x08);
65+
66+
writecommand(0x04);
67+
CHECK_BUSY();
68+
}

TFT_eSPI.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ void TFT_eSPI::init(uint8_t tc)
806806

807807
#elif defined (JD79667_DRIVER)
808808
#include "TFT_Drivers/JD79667_Init.h"
809+
810+
#elif defined (JD79676_DRIVER)
811+
#include "TFT_Drivers/JD79676_Init.h"
809812

810813
#endif
811814

@@ -941,6 +944,9 @@ void TFT_eSPI::setRotation(uint8_t m)
941944
#elif defined (JD79667_DRIVER)
942945
#include "TFT_Drivers/JD79667_Rotation.h"
943946

947+
#elif defined (JD79676_DRIVER)
948+
#include "TFT_Drivers/JD79676_Rotation.h"
949+
944950
#endif
945951

946952
delayMicroseconds(10);

User_Setup_Select.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@
161161
#define TFT_DRIVER 0x1032
162162
#elif defined (JD79667_DRIVER)
163163
#include "TFT_Drivers/JD79667_Defines.h"
164-
#define TFT_DRIVER 0x2904
164+
#define TFT_DRIVER 0x2904
165+
#elif defined (JD79676_DRIVER)
166+
#include "TFT_Drivers/JD79676_Defines.h"
167+
#define TFT_DRIVER 0x2134
168+
165169
// <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE
166170
// XYZZY_init.h and XYZZY_rotation.h must also be added in TFT_eSPI.cpp
167171
#elif defined (XYZZY_DRIVER)

User_Setups/Dynamic_Setup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@
314314
#define USE_BWRY_EPAPER
315315
#define ENABLE_EPAPER_BOARD_PIN_SETUPS
316316
#include <User_Setups/Setup512_Seeed_XIAO_EPaper_2inch9_BWRY.h>
317+
#elif BOARD_SCREEN_COMBO == 513
318+
#define USE_BWRY_EPAPER
319+
#define ENABLE_EPAPER_BOARD_PIN_SETUPS
320+
#include <User_Setups/Setup513_Seeed_XIAO_EPaper_2inch13_BWRY.h>
317321
#elif BOARD_SCREEN_COMBO == 520
318322
#define ENABLE_EPAPER_BOARD_PIN_SETUPS
319323
#include <User_Setups/Setup520_Seeed_reTerminal_E1001.h>

0 commit comments

Comments
 (0)