epaper 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,321 @@
1
+ /*****************************************************************************
2
+ * | File : EPD_7in5.c
3
+ * | Author : Waveshare team
4
+ * | Function : Electronic paper driver
5
+ * | Info :
6
+ *----------------
7
+ * | This version: V2.0
8
+ * | Date : 2018-11-09
9
+ * | Info :
10
+ *****************************************************************************
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ # of this software and associated documnetation files(the "Software"), to deal
14
+ # in the Software without restriction, including without limitation the rights
15
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ # copies of the Software, and to permit persons to whom the Software is
17
+ # furished to do so, subject to the following conditions:
18
+ #
19
+ # The above copyright notice and this permission notice shall be included in
20
+ # all copies or substantial portions of the Software.
21
+ #
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ # THE SOFTWARE.
29
+ #
30
+ ******************************************************************************/
31
+ #include "EPD_7in5_V2.h"
32
+ #include "Debug.h"
33
+
34
+
35
+ UBYTE Voltage_Frame_7IN5_V2[]={
36
+ 0x6, 0x3F, 0x3F, 0x11, 0x24, 0x7, 0x17,
37
+ };
38
+
39
+ UBYTE LUT_VCOM_7IN5_V2[]={
40
+ 0x0, 0xF, 0xF, 0x0, 0x0, 0x1,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+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
77
+ };
78
+
79
+ UBYTE LUT_BB_7IN5_V2[]={
80
+ 0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
81
+ 0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
82
+ 0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
83
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
84
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
85
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
86
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
87
+ };
88
+
89
+ /******************************************************************************
90
+ function : Software reset
91
+ parameter:
92
+ ******************************************************************************/
93
+ static void EPD_Reset(void)
94
+ {
95
+ DEV_Digital_Write(EPD_RST_PIN, 1);
96
+ DEV_Delay_ms(20);
97
+ DEV_Digital_Write(EPD_RST_PIN, 0);
98
+ DEV_Delay_ms(2);
99
+ DEV_Digital_Write(EPD_RST_PIN, 1);
100
+ DEV_Delay_ms(20);
101
+ }
102
+
103
+ /******************************************************************************
104
+ function : send command
105
+ parameter:
106
+ Reg : Command register
107
+ ******************************************************************************/
108
+ static void EPD_SendCommand(UBYTE Reg)
109
+ {
110
+ DEV_Digital_Write(EPD_DC_PIN, 0);
111
+ DEV_Digital_Write(EPD_CS_PIN, 0);
112
+ DEV_SPI_WriteByte(Reg);
113
+ DEV_Digital_Write(EPD_CS_PIN, 1);
114
+ }
115
+
116
+ /******************************************************************************
117
+ function : send data
118
+ parameter:
119
+ Data : Write data
120
+ ******************************************************************************/
121
+ static void EPD_SendData(UBYTE Data)
122
+ {
123
+ DEV_Digital_Write(EPD_DC_PIN, 1);
124
+ DEV_Digital_Write(EPD_CS_PIN, 0);
125
+ DEV_SPI_WriteByte(Data);
126
+ DEV_Digital_Write(EPD_CS_PIN, 1);
127
+ }
128
+
129
+ /******************************************************************************
130
+ function : Wait until the busy_pin goes LOW
131
+ parameter:
132
+ ******************************************************************************/
133
+ static void EPD_WaitUntilIdle(void)
134
+ {
135
+ Debug("e-Paper busy\r\n");
136
+ do{
137
+ DEV_Delay_ms(5);
138
+ }while(!(DEV_Digital_Read(EPD_BUSY_PIN)));
139
+ DEV_Delay_ms(5);
140
+ Debug("e-Paper busy release\r\n");
141
+ }
142
+
143
+ static void EPD_7IN5_V2_LUT(UBYTE* lut_vcom, UBYTE* lut_ww, UBYTE* lut_bw, UBYTE* lut_wb, UBYTE* lut_bb)
144
+ {
145
+ UBYTE count;
146
+
147
+ EPD_SendCommand(0x20); //VCOM
148
+ for(count=0; count<42; count++)
149
+ EPD_SendData(lut_vcom[count]);
150
+
151
+ EPD_SendCommand(0x21); //LUTBW
152
+ for(count=0; count<42; count++)
153
+ EPD_SendData(lut_ww[count]);
154
+
155
+ EPD_SendCommand(0x22); //LUTBW
156
+ for(count=0; count<42; count++)
157
+ EPD_SendData(lut_bw[count]);
158
+
159
+ EPD_SendCommand(0x23); //LUTWB
160
+ for(count=0; count<42; count++)
161
+ EPD_SendData(lut_wb[count]);
162
+
163
+ EPD_SendCommand(0x24); //LUTBB
164
+ for(count=0; count<42; count++)
165
+ EPD_SendData(lut_bb[count]);
166
+ }
167
+
168
+ /******************************************************************************
169
+ function : Turn On Display
170
+ parameter:
171
+ ******************************************************************************/
172
+ static void EPD_7IN5_V2_TurnOnDisplay(void)
173
+ {
174
+ EPD_SendCommand(0x12); //DISPLAY REFRESH
175
+ DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!!
176
+ EPD_WaitUntilIdle();
177
+ }
178
+
179
+ /******************************************************************************
180
+ function : Initialize the e-Paper register
181
+ parameter:
182
+ ******************************************************************************/
183
+ UBYTE EPD_7IN5_V2_Init(void)
184
+ {
185
+ EPD_Reset();
186
+
187
+ // EPD_SendCommand(0x01); //POWER SETTING
188
+ // EPD_SendData(0x07);
189
+ // EPD_SendData(0x07); //VGH=20V,VGL=-20V
190
+ // EPD_SendData(0x3f); //VDH=15V
191
+ // EPD_SendData(0x3f); //VDL=-15V
192
+
193
+ EPD_SendCommand(0x01); // power setting
194
+ EPD_SendData(0x17); // 1-0=11: internal power
195
+ EPD_SendData(*(Voltage_Frame_7IN5_V2+6)); // VGH&VGL
196
+ EPD_SendData(*(Voltage_Frame_7IN5_V2+1)); // VSH
197
+ EPD_SendData(*(Voltage_Frame_7IN5_V2+2)); // VSL
198
+ EPD_SendData(*(Voltage_Frame_7IN5_V2+3)); // VSHR
199
+
200
+ EPD_SendCommand(0x82); // VCOM DC Setting
201
+ EPD_SendData(*(Voltage_Frame_7IN5_V2+4)); // VCOM
202
+
203
+ EPD_SendCommand(0x06); // Booster Setting
204
+ EPD_SendData(0x27);
205
+ EPD_SendData(0x27);
206
+ EPD_SendData(0x2F);
207
+ EPD_SendData(0x17);
208
+
209
+ EPD_SendCommand(0x30); // OSC Setting
210
+ EPD_SendData(*(Voltage_Frame_7IN5_V2+0)); // 2-0=100: N=4 ; 5-3=111: M=7 ; 3C=50Hz 3A=100HZ
211
+
212
+ EPD_SendCommand(0x04); //POWER ON
213
+ DEV_Delay_ms(100);
214
+ EPD_WaitUntilIdle();
215
+
216
+ EPD_SendCommand(0X00); //PANNEL SETTING
217
+ EPD_SendData(0x3F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
218
+
219
+ EPD_SendCommand(0x61); //tres
220
+ EPD_SendData(0x03); //source 800
221
+ EPD_SendData(0x20);
222
+ EPD_SendData(0x01); //gate 480
223
+ EPD_SendData(0xE0);
224
+
225
+ EPD_SendCommand(0X15);
226
+ EPD_SendData(0x00);
227
+
228
+ EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
229
+ EPD_SendData(0x10);
230
+ EPD_SendData(0x00);
231
+
232
+ EPD_SendCommand(0X60); //TCON SETTING
233
+ EPD_SendData(0x22);
234
+
235
+ EPD_SendCommand(0x65); // Resolution setting
236
+ EPD_SendData(0x00);
237
+ EPD_SendData(0x00);//800*480
238
+ EPD_SendData(0x00);
239
+ EPD_SendData(0x00);
240
+
241
+ EPD_7IN5_V2_LUT(LUT_VCOM_7IN5_V2, LUT_WW_7IN5_V2, LUT_BW_7IN5_V2, LUT_WB_7IN5_V2, LUT_BB_7IN5_V2);
242
+
243
+ return 0;
244
+ }
245
+
246
+ /******************************************************************************
247
+ function : Clear screen
248
+ parameter:
249
+ ******************************************************************************/
250
+ void EPD_7IN5_V2_Clear(void)
251
+ {
252
+ UWORD Width, Height;
253
+ Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
254
+ Height = EPD_7IN5_V2_HEIGHT;
255
+
256
+ UWORD i;
257
+ EPD_SendCommand(0x10);
258
+ for(i=0; i<Height*Width; i++) {
259
+ EPD_SendData(0xFF);
260
+ }
261
+ EPD_SendCommand(0x13);
262
+ for(i=0; i<Height*Width; i++) {
263
+ EPD_SendData(0x00);
264
+ }
265
+ EPD_7IN5_V2_TurnOnDisplay();
266
+ }
267
+
268
+ void EPD_7IN5_V2_ClearBlack(void)
269
+ {
270
+ UWORD Width, Height;
271
+ Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
272
+ Height = EPD_7IN5_V2_HEIGHT;
273
+
274
+ UWORD i;
275
+ EPD_SendCommand(0x10);
276
+ for(i=0; i<Height*Width; i++) {
277
+ EPD_SendData(0x00);
278
+ }
279
+ EPD_SendCommand(0x13);
280
+ for(i=0; i<Height*Width; i++) {
281
+ EPD_SendData(0xFF);
282
+ }
283
+ EPD_7IN5_V2_TurnOnDisplay();
284
+ }
285
+
286
+ /******************************************************************************
287
+ function : Sends the image buffer in RAM to e-Paper and displays
288
+ parameter:
289
+ ******************************************************************************/
290
+ void EPD_7IN5_V2_Display(const UBYTE *blackimage)
291
+ {
292
+ UDOUBLE Width, Height;
293
+ Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
294
+ Height = EPD_7IN5_V2_HEIGHT;
295
+
296
+ // EPD_SendCommand(0x10);
297
+ // for (UDOUBLE j = 0; j < Height; j++) {
298
+ // for (UDOUBLE i = 0; i < Width; i++) {
299
+ // EPD_SendData(blackimage[i + j * Width]);
300
+ // }
301
+ // }
302
+ EPD_SendCommand(0x13);
303
+ for (UDOUBLE j = 0; j < Height; j++) {
304
+ for (UDOUBLE i = 0; i < Width; i++) {
305
+ EPD_SendData(~blackimage[i + j * Width]);
306
+ }
307
+ }
308
+ EPD_7IN5_V2_TurnOnDisplay();
309
+ }
310
+
311
+ /******************************************************************************
312
+ function : Enter sleep mode
313
+ parameter:
314
+ ******************************************************************************/
315
+ void EPD_7IN5_V2_Sleep(void)
316
+ {
317
+ EPD_SendCommand(0X02); //power off
318
+ EPD_WaitUntilIdle();
319
+ EPD_SendCommand(0X07); //deep sleep
320
+ EPD_SendData(0xA5);
321
+ }
@@ -0,0 +1,49 @@
1
+ /*****************************************************************************
2
+ * | File : EPD_7in5_V2.h
3
+ * | Author : Waveshare team
4
+ * | Function : Electronic paper driver
5
+ * | Info :
6
+ *----------------
7
+ * | This version: V2.0
8
+ * | Date : 2018-11-09
9
+ * | Info :
10
+ * 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
11
+ * 2.Change:EPD_Display(UBYTE *Image)
12
+ * Need to pass parameters: pointer to cached data
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documnetation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+ #
32
+ ******************************************************************************/
33
+ #ifndef _EPD_7IN5_V2_H_
34
+ #define _EPD_7IN5_V2_H_
35
+
36
+ #include "DEV_Config.h"
37
+
38
+
39
+ // Display resolution
40
+ #define EPD_7IN5_V2_WIDTH 800
41
+ #define EPD_7IN5_V2_HEIGHT 480
42
+
43
+ UBYTE EPD_7IN5_V2_Init(void);
44
+ void EPD_7IN5_V2_Clear(void);
45
+ void EPD_7IN5_V2_ClearBlack(void);
46
+ void EPD_7IN5_V2_Display(const UBYTE *blackimage);
47
+ void EPD_7IN5_V2_Sleep(void);
48
+
49
+ #endif