1
+ #include <stdint.h>
2
+ #include "tl_common.h"
3
+ #include "main.h"
4
+ #include "epd.h"
5
+ #include "epd_spi.h"
6
+ #include "epd_bwr_350.h"
7
+ #include "drivers.h"
8
+ #include "stack/ble/ble.h"
9
+
10
+ // SSD1675 mixed with SSD1680 EPD Controller
11
+
12
+ #define BWR_350_Len 50
13
+ uint8_t LUT_bwr_350_part [] = {
14
+
15
+ 0x01 , 0x10 , 0x18 , 0x01 , 0x32 , 0x02 , 0x01 , 0x10 , 0x08 , 0x01 , 0x03 , 0x02 ,
16
+ 0x01 , 0x01 , 0x01 , 0x0A , 0x05 , 0x0A , 0x0F , 0x01 , 0x01 , 0x01 , 0x14 , 0x0F ,
17
+ 0x02 , 0x02 , 0x01 , 0x14 , 0x01 , 0x02 , 0x02 , 0x04 , 0x02 , 0x14 , 0x12 , 0x01 ,
18
+ 0x0A , 0x0F , 0x01 , 0x02 , 0x01 , 0x01 , 0x07 , 0x05 , 0x00 , 0x22 , 0x02 , 0x01 ,
19
+ 0x01 , 0x00 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x50 , 0x18 , 0x01 ,
20
+ 0x72 , 0x02 , 0x01 , 0x10 , 0x88 , 0x01 , 0x43 ,
21
+ 0x02 , 0x01 , 0x01 , 0x01 , 0x4A , 0x85 , 0x4A ,
22
+ 0x8F , 0x01 , 0x01 , 0x01 , 0x94 , 0x8F , 0x82 ,
23
+ 0x42 , 0x01 , 0x14 , 0x01 , 0x82 , 0x42 , 0x84 ,
24
+ 0x42 , 0x14 , 0x12 , 0x01 , 0x4A , 0x4F , 0x01 ,
25
+ 0x02 , 0x01 , 0x01 , 0x07 , 0x85 , 0x00 , 0xE2 ,
26
+ 0x02 , 0x01 , 0x01 , 0x00 , 0x01 , 0x01 , 0x01 ,
27
+ 0x01 , 0x01 , 0x01 , 0x01 , 0x50 , 0x58 , 0x81 ,
28
+ 0x72 , 0x02 , 0x01 , 0x10 , 0x88 , 0x01 , 0x43 ,
29
+ 0x42 , 0x01 , 0x01 , 0x01 , 0x4A , 0x85 , 0x4A ,
30
+ 0x8F , 0x01 , 0x01 , 0x01 , 0x94 , 0x8F , 0x82 ,
31
+ 0x42 , 0x01 , 0x14 , 0x01 , 0x82 , 0x42 , 0x84 ,
32
+ 0x42 , 0x14 , 0x12 , 0x01 , 0x4A , 0x4F , 0x01 ,
33
+ 0x02 , 0x01 , 0x01 , 0x07 , 0x85 , 0x00 , 0x22 ,
34
+ 0x02 , 0x01 , 0x01 , 0x00 , 0x01 , 0x01 , 0x01 ,
35
+ 0x01 , 0x01 , 0x01 , 0x01 , 0x50 , 0x58 , 0x01 ,
36
+ 0x72 , 0x02 , 0x01 , 0x10 , 0x88 , 0x81 , 0x43 ,
37
+ 0x02 , 0x01 , 0x01 , 0x01 , 0x4A , 0x85 , 0x4A ,
38
+ 0x8F , 0x01 , 0x01 , 0x01 , 0x94 , 0x8F , 0x82 ,
39
+ 0x42 , 0x01 , 0x14 , 0x01 , 0x82 , 0x42 , 0x84 ,
40
+ 0x42 , 0x14 , 0x12 , 0x01 , 0x4A , 0x4F , 0x01 ,
41
+ 0x82 , 0x01 , 0x01 , 0x07 , 0x05 , 0x00 , 0x22 ,
42
+ 0x42 , 0x01 , 0x01 , 0x00 , 0x01 , 0x01 , 0x01 ,
43
+ 0x01 , 0x01 , 0x01 ,
44
+ 0x02 , 0x00 , 0x00 ,
45
+ 0x22 , 0x17 , 0x41 , 0xA8 , 0x32 , 0x50
46
+ };
47
+
48
+ #define EPD_BWR_350_test_pattern 0xA5
49
+ _attribute_ram_code_ uint8_t EPD_BWR_350_detect (void )
50
+ {
51
+ // SW Reset
52
+ EPD_WriteCmd (0x12 );
53
+ WaitMs (10 );
54
+
55
+ EPD_WriteCmd (0x32 );
56
+ int i ;
57
+ for (i = 0 ; i < 153 ; i ++ )// This model has a 159 bytes LUT storage so we test for that
58
+ {
59
+ EPD_WriteData (EPD_BWR_350_test_pattern );
60
+ }
61
+ EPD_WriteCmd (0x33 );
62
+ for (i = 0 ; i < 153 ; i ++ )
63
+ {
64
+ if (EPD_SPI_read () != EPD_BWR_350_test_pattern )
65
+ return 0 ;
66
+ }
67
+ return 1 ;
68
+ }
69
+
70
+ _attribute_ram_code_ uint8_t EPD_BWR_350_read_temp (void )
71
+ {
72
+ uint8_t epd_temperature = 0 ;
73
+
74
+ // SW Reset
75
+ EPD_WriteCmd (0x12 );
76
+
77
+ EPD_CheckStatus_inverted (100 );
78
+
79
+ // Set Analog Block control
80
+ EPD_WriteCmd (0x74 );
81
+ EPD_WriteData (0x54 );
82
+ // Set Digital Block control
83
+ EPD_WriteCmd (0x7E );
84
+ EPD_WriteData (0x3B );
85
+
86
+ // Booster soft start
87
+ EPD_WriteCmd (0x0C );
88
+ EPD_WriteData (0x8B );
89
+ EPD_WriteData (0x9C );
90
+ EPD_WriteData (0x96 );
91
+ EPD_WriteData (0x0F );
92
+
93
+ // Driver output control
94
+ EPD_WriteCmd (0x01 );
95
+ EPD_WriteData (0x28 );
96
+ EPD_WriteData (0x01 );
97
+ EPD_WriteData (0x01 );
98
+
99
+ // Data entry mode setting
100
+ EPD_WriteCmd (0x11 );
101
+ EPD_WriteData (0x01 );
102
+
103
+ // Set RAM X- Address Start/End
104
+ EPD_WriteCmd (0x44 );
105
+ EPD_WriteData (0x00 );
106
+ EPD_WriteData (0x0F );
107
+
108
+ // Set RAM Y- Address Start/End
109
+ EPD_WriteCmd (0x45 );
110
+ EPD_WriteData (0x28 );
111
+ EPD_WriteData (0x01 );
112
+ EPD_WriteData (0x2E );
113
+ EPD_WriteData (0x00 );
114
+
115
+ // Border waveform control
116
+ EPD_WriteCmd (0x3C );
117
+ EPD_WriteData (0x05 );
118
+
119
+ // Display update control
120
+ EPD_WriteCmd (0x21 );
121
+ EPD_WriteData (0x00 );
122
+ EPD_WriteData (0x80 );
123
+
124
+ // Temperature sensor control
125
+ EPD_WriteCmd (0x18 );
126
+ EPD_WriteData (0x80 );
127
+
128
+ // Display update control
129
+ EPD_WriteCmd (0x22 );
130
+ EPD_WriteData (0xB1 );
131
+
132
+ // Master Activation
133
+ EPD_WriteCmd (0x20 );
134
+
135
+ EPD_CheckStatus_inverted (100 );
136
+
137
+ // Temperature sensor read from register
138
+ EPD_WriteCmd (0x1B );
139
+ epd_temperature = EPD_SPI_read ();
140
+ EPD_SPI_read ();
141
+
142
+ WaitMs (5 );
143
+
144
+ // deep sleep
145
+ EPD_WriteCmd (0x10 );
146
+ EPD_WriteData (0x01 );
147
+
148
+ return epd_temperature ;
149
+ }
150
+
151
+ _attribute_ram_code_ uint8_t EPD_BWR_350_Display (unsigned char * image , int size , uint8_t full_or_partial )
152
+ {
153
+ uint8_t epd_temperature = 0 ;
154
+
155
+ // SW Reset
156
+ EPD_WriteCmd (0x12 );
157
+
158
+ EPD_CheckStatus_inverted (100 );
159
+
160
+ // Set Analog Block control
161
+ EPD_WriteCmd (0x74 );
162
+ EPD_WriteData (0x54 );
163
+ // Set Digital Block control
164
+ EPD_WriteCmd (0x7E );
165
+ EPD_WriteData (0x3B );
166
+
167
+ // Booster soft start
168
+ EPD_WriteCmd (0x0C );
169
+ EPD_WriteData (0x8B );
170
+ EPD_WriteData (0x9C );
171
+ EPD_WriteData (0x96 );
172
+ EPD_WriteData (0x0F );
173
+
174
+ // Driver output control
175
+ EPD_WriteCmd (0x01 );
176
+ EPD_WriteData (0x28 );
177
+ EPD_WriteData (0x01 );
178
+ EPD_WriteData (0x01 );
179
+
180
+ // Data entry mode setting
181
+ EPD_WriteCmd (0x11 );
182
+ EPD_WriteData (0x01 );
183
+
184
+ // Set RAM X- Address Start/End
185
+ EPD_WriteCmd (0x44 );
186
+ EPD_WriteData (0x00 );
187
+ EPD_WriteData (0x0F );
188
+
189
+ // Set RAM Y- Address Start/End
190
+ EPD_WriteCmd (0x45 );
191
+ EPD_WriteData (0x28 );
192
+ EPD_WriteData (0x01 );
193
+ EPD_WriteData (0x2E );
194
+ EPD_WriteData (0x00 );
195
+
196
+ // Border waveform control
197
+ EPD_WriteCmd (0x3C );
198
+ EPD_WriteData (0x05 );
199
+
200
+ // Display update control
201
+ EPD_WriteCmd (0x21 );
202
+ EPD_WriteData (0x00 );
203
+ EPD_WriteData (0x80 );
204
+
205
+ // Temperature sensor control
206
+ EPD_WriteCmd (0x18 );
207
+ EPD_WriteData (0x80 );
208
+
209
+ // Display update control
210
+ EPD_WriteCmd (0x22 );
211
+ EPD_WriteData (0xB1 );
212
+
213
+ // Master Activation
214
+ EPD_WriteCmd (0x20 );
215
+
216
+ EPD_CheckStatus_inverted (100 );
217
+
218
+ // Temperature sensor read from register
219
+ EPD_WriteCmd (0x1B );
220
+ epd_temperature = EPD_SPI_read ();
221
+ EPD_SPI_read ();
222
+
223
+ WaitMs (5 );
224
+
225
+ // Set RAM X address
226
+ EPD_WriteCmd (0x4E );
227
+ EPD_WriteData (0x00 );
228
+
229
+ // Set RAM Y address
230
+ EPD_WriteCmd (0x4F );
231
+ EPD_WriteData (0x28 );
232
+ EPD_WriteData (0x01 );
233
+
234
+ EPD_LoadImage (image , size , 0x24 );
235
+
236
+ // Set RAM X address
237
+ EPD_WriteCmd (0x4E );
238
+ EPD_WriteData (0x00 );
239
+
240
+ // Set RAM Y address
241
+ EPD_WriteCmd (0x4F );
242
+ EPD_WriteData (0x28 );
243
+ EPD_WriteData (0x01 );
244
+
245
+ EPD_WriteCmd (0x26 );// RED Color TODO make something out of it :)
246
+ int i ;
247
+ for (i = 0 ; i < size ; i ++ )
248
+ {
249
+ EPD_WriteData (0x00 );
250
+ }
251
+
252
+ if (!full_or_partial )
253
+ {
254
+ EPD_WriteCmd (0x32 );
255
+ for (i = 0 ; i < sizeof (LUT_bwr_350_part ); i ++ )
256
+ {
257
+ EPD_WriteData (LUT_bwr_350_part [i ]);
258
+ }
259
+ }
260
+
261
+ // Display update control
262
+ EPD_WriteCmd (0x22 );
263
+ EPD_WriteData (0xC7 );
264
+
265
+ // Master Activation
266
+ EPD_WriteCmd (0x20 );
267
+
268
+ return epd_temperature ;
269
+ }
270
+
271
+ _attribute_ram_code_ void EPD_BWR_350_set_sleep (void )
272
+ {
273
+ // deep sleep
274
+ EPD_WriteCmd (0x10 );
275
+ EPD_WriteData (0x01 );
276
+
277
+ }
0 commit comments