EPD_3in7.c (18087B)
1 /***************************************************************************** 2 * | File : EPD_3IN7.C 3 * | Author : Waveshare team 4 * | Function : 3.7inch e-paper 5 * | Info : 6 *---------------- 7 * | This version: V1.0 8 * | Date : 2020-07-16 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_3in7.h" 32 #include "Debug.h" 33 34 static const UBYTE lut_4Gray_GC[] = 35 { 36 0x2A,0x06,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1 37 0x28,0x06,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2 38 0x20,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3 39 0x14,0x06,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4 40 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5 41 0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x08,0x08,0x02,//6 42 0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,//7 43 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8 44 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9 45 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10 46 0x22,0x22,0x22,0x22,0x22 47 }; 48 49 static const UBYTE lut_1Gray_GC[] = 50 { 51 0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1 52 0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2 53 0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3 54 0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4 55 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5 56 0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6 57 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7 58 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8 59 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9 60 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10 61 0x22,0x22,0x22,0x22,0x22 62 }; 63 64 static const UBYTE lut_1Gray_DU[] = 65 { 66 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1 67 0x01,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 68 0x0A,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3 69 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 70 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5 71 0x00,0x00,0x05,0x05,0x00,0x05,0x03,0x05,0x05,0x00, 72 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7 73 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 74 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9 75 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 76 0x22,0x22,0x22,0x22,0x22 77 }; 78 79 static const UBYTE lut_1Gray_A2[] = 80 { 81 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //1 82 0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //2 83 0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //3 84 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //4 85 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //5 86 0x00,0x00,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00, //6 87 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //7 88 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //8 89 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //9 90 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //10 91 0x22,0x22,0x22,0x22,0x22 92 }; 93 94 /****************************************************************************** 95 function : Software reset 96 parameter: 97 ******************************************************************************/ 98 static void EPD_3IN7_Reset(void) 99 { 100 DEV_Digital_Write(EPD_RST_PIN, 1); 101 DEV_Delay_ms(300); 102 DEV_Digital_Write(EPD_RST_PIN, 0); 103 DEV_Delay_ms(3); 104 DEV_Digital_Write(EPD_RST_PIN, 1); 105 DEV_Delay_ms(300); 106 } 107 108 /****************************************************************************** 109 function : send command 110 parameter: 111 Reg : Command register 112 ******************************************************************************/ 113 static void EPD_3IN7_SendCommand(UBYTE Reg) 114 { 115 DEV_Digital_Write(EPD_DC_PIN, 0); 116 DEV_Digital_Write(EPD_CS_PIN, 0); 117 DEV_SPI_WriteByte(Reg); 118 DEV_Digital_Write(EPD_CS_PIN, 1); 119 } 120 121 /****************************************************************************** 122 function : send data 123 parameter: 124 Data : Write data 125 ******************************************************************************/ 126 static void EPD_3IN7_SendData(UBYTE Data) 127 { 128 DEV_Digital_Write(EPD_DC_PIN, 1); 129 DEV_Digital_Write(EPD_CS_PIN, 0); 130 DEV_SPI_WriteByte(Data); 131 DEV_Digital_Write(EPD_CS_PIN, 1); 132 } 133 134 static void EPD_3IN7_ReadBusy_HIGH(void) 135 { 136 Debug("e-Paper busy\r\n"); 137 UBYTE busy; 138 do { 139 busy = DEV_Digital_Read(EPD_BUSY_PIN); 140 } while(busy); 141 DEV_Delay_ms(200); 142 Debug("e-Paper busy release\r\n"); 143 } 144 145 /****************************************************************************** 146 function : set the look-up tables 147 parameter: 148 ******************************************************************************/ 149 void EPD_3IN7_Load_LUT(UBYTE lut) 150 { 151 UWORD i; 152 EPD_3IN7_SendCommand(0x32); 153 for (i = 0; i < 105; i++) 154 { 155 if(lut == 0) 156 EPD_3IN7_SendData(lut_4Gray_GC[i]); 157 else if(lut == 1) 158 EPD_3IN7_SendData(lut_1Gray_GC[i]); 159 else if(lut == 2) 160 EPD_3IN7_SendData(lut_1Gray_DU[i]); 161 else if(lut == 3) 162 EPD_3IN7_SendData(lut_1Gray_A2[i]); 163 else 164 Debug("There is no such lut \r\n"); 165 } 166 } 167 168 /****************************************************************************** 169 function : Initialize the e-Paper register 170 parameter: 171 ******************************************************************************/ 172 void EPD_3IN7_4Gray_Init(void) 173 { 174 EPD_3IN7_Reset(); 175 176 EPD_3IN7_SendCommand(0x12); 177 DEV_Delay_ms(300); 178 179 EPD_3IN7_SendCommand(0x46); 180 EPD_3IN7_SendData(0xF7); 181 EPD_3IN7_ReadBusy_HIGH(); 182 EPD_3IN7_SendCommand(0x47); 183 EPD_3IN7_SendData(0xF7); 184 EPD_3IN7_ReadBusy_HIGH(); 185 186 EPD_3IN7_SendCommand(0x01); // setting gaet number 187 EPD_3IN7_SendData(0xDF); 188 EPD_3IN7_SendData(0x01); 189 EPD_3IN7_SendData(0x00); 190 191 EPD_3IN7_SendCommand(0x03); // set gate voltage 192 EPD_3IN7_SendData(0x00); 193 194 EPD_3IN7_SendCommand(0x04); // set source voltage 195 EPD_3IN7_SendData(0x41); 196 EPD_3IN7_SendData(0xA8); 197 EPD_3IN7_SendData(0x32); 198 199 EPD_3IN7_SendCommand(0x11); // set data entry sequence 200 EPD_3IN7_SendData(0x03); 201 202 EPD_3IN7_SendCommand(0x3C); // set border 203 EPD_3IN7_SendData(0x00); 204 205 EPD_3IN7_SendCommand(0x0C); // set booster strength 206 EPD_3IN7_SendData(0xAE); 207 EPD_3IN7_SendData(0xC7); 208 EPD_3IN7_SendData(0xC3); 209 EPD_3IN7_SendData(0xC0); 210 EPD_3IN7_SendData(0xC0); 211 212 EPD_3IN7_SendCommand(0x18); // set internal sensor on 213 EPD_3IN7_SendData(0x80); 214 215 EPD_3IN7_SendCommand(0x2C); // set vcom value 216 EPD_3IN7_SendData(0x44); 217 218 EPD_3IN7_SendCommand(0x37); // set display option, these setting turn on previous function 219 EPD_3IN7_SendData(0x00); 220 EPD_3IN7_SendData(0x00); 221 EPD_3IN7_SendData(0x00); 222 EPD_3IN7_SendData(0x00); 223 EPD_3IN7_SendData(0x00); 224 EPD_3IN7_SendData(0x00); 225 EPD_3IN7_SendData(0x00); 226 EPD_3IN7_SendData(0x00); 227 EPD_3IN7_SendData(0x00); 228 EPD_3IN7_SendData(0x00); 229 230 EPD_3IN7_SendCommand(0x44); // setting X direction start/end position of RAM 231 EPD_3IN7_SendData(0x00); 232 EPD_3IN7_SendData(0x00); 233 EPD_3IN7_SendData(0x17); 234 EPD_3IN7_SendData(0x01); 235 236 EPD_3IN7_SendCommand(0x45); // setting Y direction start/end position of RAM 237 EPD_3IN7_SendData(0x00); 238 EPD_3IN7_SendData(0x00); 239 EPD_3IN7_SendData(0xDF); 240 EPD_3IN7_SendData(0x01); 241 242 EPD_3IN7_SendCommand(0x22); // Display Update Control 2 243 EPD_3IN7_SendData(0xCF); 244 } 245 246 /****************************************************************************** 247 function : Initialize the e-Paper register 248 parameter: 249 ******************************************************************************/ 250 void EPD_3IN7_1Gray_Init(void) 251 { 252 EPD_3IN7_Reset(); 253 254 EPD_3IN7_SendCommand(0x12); 255 DEV_Delay_ms(300); 256 257 EPD_3IN7_SendCommand(0x46); 258 EPD_3IN7_SendData(0xF7); 259 EPD_3IN7_ReadBusy_HIGH(); 260 EPD_3IN7_SendCommand(0x47); 261 EPD_3IN7_SendData(0xF7); 262 EPD_3IN7_ReadBusy_HIGH(); 263 264 EPD_3IN7_SendCommand(0x01); // setting gaet number 265 EPD_3IN7_SendData(0xDF); 266 EPD_3IN7_SendData(0x01); 267 EPD_3IN7_SendData(0x00); 268 269 EPD_3IN7_SendCommand(0x03); // set gate voltage 270 EPD_3IN7_SendData(0x00); 271 272 EPD_3IN7_SendCommand(0x04); // set source voltage 273 EPD_3IN7_SendData(0x41); 274 EPD_3IN7_SendData(0xA8); 275 EPD_3IN7_SendData(0x32); 276 277 EPD_3IN7_SendCommand(0x11); // set data entry sequence 278 EPD_3IN7_SendData(0x03); 279 280 EPD_3IN7_SendCommand(0x3C); // set border 281 EPD_3IN7_SendData(0x00); 282 283 EPD_3IN7_SendCommand(0x0C); // set booster strength 284 EPD_3IN7_SendData(0xAE); 285 EPD_3IN7_SendData(0xC7); 286 EPD_3IN7_SendData(0xC3); 287 EPD_3IN7_SendData(0xC0); 288 EPD_3IN7_SendData(0xC0); 289 290 EPD_3IN7_SendCommand(0x18); // set internal sensor on 291 EPD_3IN7_SendData(0x80); 292 293 EPD_3IN7_SendCommand(0x2C); // set vcom value 294 EPD_3IN7_SendData(0x44); 295 296 EPD_3IN7_SendCommand(0x37); // set display option, these setting turn on previous function 297 EPD_3IN7_SendData(0x00); //can switch 1 gray or 4 gray 298 EPD_3IN7_SendData(0xFF); 299 EPD_3IN7_SendData(0xFF); 300 EPD_3IN7_SendData(0xFF); 301 EPD_3IN7_SendData(0xFF); 302 EPD_3IN7_SendData(0x4F); 303 EPD_3IN7_SendData(0xFF); 304 EPD_3IN7_SendData(0xFF); 305 EPD_3IN7_SendData(0xFF); 306 EPD_3IN7_SendData(0xFF); 307 308 EPD_3IN7_SendCommand(0x44); // setting X direction start/end position of RAM 309 EPD_3IN7_SendData(0x00); 310 EPD_3IN7_SendData(0x00); 311 EPD_3IN7_SendData(0x17); 312 EPD_3IN7_SendData(0x01); 313 314 EPD_3IN7_SendCommand(0x45); // setting Y direction start/end position of RAM 315 EPD_3IN7_SendData(0x00); 316 EPD_3IN7_SendData(0x00); 317 EPD_3IN7_SendData(0xDF); 318 EPD_3IN7_SendData(0x01); 319 320 EPD_3IN7_SendCommand(0x22); // Display Update Control 2 321 EPD_3IN7_SendData(0xCF); 322 } 323 324 /****************************************************************************** 325 function : Clear screen 326 parameter: 327 ******************************************************************************/ 328 void EPD_3IN7_4Gray_Clear(void) 329 { 330 UWORD Width, Height; 331 Width = (EPD_3IN7_WIDTH % 8 == 0)? (EPD_3IN7_WIDTH / 8 ): (EPD_3IN7_WIDTH / 8 + 1); 332 Height = EPD_3IN7_HEIGHT; 333 334 EPD_3IN7_SendCommand(0x49); 335 EPD_3IN7_SendData(0x00); 336 EPD_3IN7_SendCommand(0x4E); 337 EPD_3IN7_SendData(0x00); 338 EPD_3IN7_SendData(0x00); 339 EPD_3IN7_SendCommand(0x4F); 340 EPD_3IN7_SendData(0x00); 341 EPD_3IN7_SendData(0x00); 342 343 EPD_3IN7_SendCommand(0x24); 344 for (UWORD j = 0; j < Height; j++) { 345 for (UWORD i = 0; i < Width; i++) { 346 EPD_3IN7_SendData(0xff); 347 } 348 } 349 350 EPD_3IN7_SendCommand(0x4E); 351 EPD_3IN7_SendData(0x00); 352 EPD_3IN7_SendData(0x00); 353 354 EPD_3IN7_SendCommand(0x4F); 355 EPD_3IN7_SendData(0x00); 356 EPD_3IN7_SendData(0x00); 357 358 EPD_3IN7_SendCommand(0x26); 359 for (UWORD j = 0; j < Height; j++) { 360 for (UWORD i = 0; i < Width; i++) { 361 EPD_3IN7_SendData(0xff); 362 } 363 } 364 365 EPD_3IN7_Load_LUT(0); 366 EPD_3IN7_SendCommand(0x22); 367 EPD_3IN7_SendData(0xC7); 368 369 EPD_3IN7_SendCommand(0x20); 370 EPD_3IN7_ReadBusy_HIGH(); 371 } 372 373 /****************************************************************************** 374 function : Clear screen 375 parameter: 376 ******************************************************************************/ 377 void EPD_3IN7_1Gray_Clear(void) 378 { 379 UWORD i; 380 UWORD IMAGE_COUNTER = EPD_3IN7_WIDTH * EPD_3IN7_HEIGHT / 8; 381 382 EPD_3IN7_SendCommand(0x4E); 383 EPD_3IN7_SendData(0x00); 384 EPD_3IN7_SendData(0x00); 385 EPD_3IN7_SendCommand(0x4F); 386 EPD_3IN7_SendData(0x00); 387 EPD_3IN7_SendData(0x00); 388 389 EPD_3IN7_SendCommand(0x24); 390 for (i = 0; i < IMAGE_COUNTER; i++) 391 { 392 EPD_3IN7_SendData(0xff); 393 } 394 395 EPD_3IN7_Load_LUT(2); 396 397 EPD_3IN7_SendCommand(0x20); 398 EPD_3IN7_ReadBusy_HIGH(); 399 } 400 401 /****************************************************************************** 402 function : Sends the image buffer in RAM to e-Paper and displays 403 parameter: 404 ******************************************************************************/ 405 void EPD_3IN7_4Gray_Display(const UBYTE *Image) 406 { 407 UDOUBLE i,j,k; 408 UBYTE temp1,temp2,temp3; 409 410 EPD_3IN7_SendCommand(0x49); 411 EPD_3IN7_SendData(0x00); 412 413 414 EPD_3IN7_SendCommand(0x4E); 415 EPD_3IN7_SendData(0x00); 416 EPD_3IN7_SendData(0x00); 417 418 419 EPD_3IN7_SendCommand(0x4F); 420 EPD_3IN7_SendData(0x00); 421 EPD_3IN7_SendData(0x00); 422 423 EPD_3IN7_SendCommand(0x24); 424 for(i=0;i<16800;i++){ 425 temp3=0; 426 for(j=0; j<2; j++) { 427 temp1 = Image[i*2+j]; 428 for(k=0; k<2; k++) { 429 temp2 = temp1&0xC0; 430 if(temp2 == 0xC0) 431 temp3 |= 0x01;//white 432 else if(temp2 == 0x00) 433 temp3 |= 0x00; //black 434 else if(temp2 == 0x80) 435 temp3 |= 0x00; //gray1 436 else //0x40 437 temp3 |= 0x01; //gray2 438 temp3 <<= 1; 439 440 temp1 <<= 2; 441 temp2 = temp1&0xC0 ; 442 if(temp2 == 0xC0) //white 443 temp3 |= 0x01; 444 else if(temp2 == 0x00) //black 445 temp3 |= 0x00; 446 else if(temp2 == 0x80) 447 temp3 |= 0x00; //gray1 448 else //0x40 449 temp3 |= 0x01; //gray2 450 if(j!=1 || k!=1) 451 temp3 <<= 1; 452 453 temp1 <<= 2; 454 } 455 456 } 457 EPD_3IN7_SendData(temp3); 458 } 459 // new data 460 EPD_3IN7_SendCommand(0x4E); 461 EPD_3IN7_SendData(0x00); 462 EPD_3IN7_SendData(0x00); 463 464 465 EPD_3IN7_SendCommand(0x4F); 466 EPD_3IN7_SendData(0x00); 467 EPD_3IN7_SendData(0x00); 468 469 EPD_3IN7_SendCommand(0x26); 470 for(i=0; i<16800; i++) { 471 temp3=0; 472 for(j=0; j<2; j++) { 473 temp1 = Image[i*2+j]; 474 for(k=0; k<2; k++) { 475 temp2 = temp1&0xC0 ; 476 if(temp2 == 0xC0) 477 temp3 |= 0x01;//white 478 else if(temp2 == 0x00) 479 temp3 |= 0x00; //black 480 else if(temp2 == 0x80) 481 temp3 |= 0x01; //gray1 482 else //0x40 483 temp3 |= 0x00; //gray2 484 temp3 <<= 1; 485 486 temp1 <<= 2; 487 temp2 = temp1&0xC0 ; 488 if(temp2 == 0xC0) //white 489 temp3 |= 0x01; 490 else if(temp2 == 0x00) //black 491 temp3 |= 0x00; 492 else if(temp2 == 0x80) 493 temp3 |= 0x01; //gray1 494 else //0x40 495 temp3 |= 0x00; //gray2 496 if(j!=1 || k!=1) 497 temp3 <<= 1; 498 499 temp1 <<= 2; 500 } 501 } 502 EPD_3IN7_SendData(temp3); 503 } 504 505 EPD_3IN7_Load_LUT(0); 506 507 EPD_3IN7_SendCommand(0x22); 508 EPD_3IN7_SendData(0xC7); 509 510 EPD_3IN7_SendCommand(0x20); 511 512 EPD_3IN7_ReadBusy_HIGH(); 513 } 514 515 /****************************************************************************** 516 function : Sends the image buffer in RAM to e-Paper and displays 517 parameter: 518 ******************************************************************************/ 519 void EPD_3IN7_1Gray_Display(const UBYTE *Image) 520 { 521 UWORD i; 522 UWORD IMAGE_COUNTER = EPD_3IN7_WIDTH * EPD_3IN7_HEIGHT / 8; 523 524 EPD_3IN7_SendCommand(0x4E); 525 EPD_3IN7_SendData(0x00); 526 EPD_3IN7_SendData(0x00); 527 EPD_3IN7_SendCommand(0x4F); 528 EPD_3IN7_SendData(0x00); 529 EPD_3IN7_SendData(0x00); 530 531 EPD_3IN7_SendCommand(0x24); 532 for (i = 0; i < IMAGE_COUNTER; i++) 533 { 534 EPD_3IN7_SendData(Image[i]); 535 } 536 537 EPD_3IN7_Load_LUT(2); 538 EPD_3IN7_SendCommand(0x20); 539 EPD_3IN7_ReadBusy_HIGH(); 540 } 541 542 /****************************************************************************** 543 function : Sends the image buffer in RAM to e-Paper and displays 544 parameter: 545 ******************************************************************************/ 546 void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend) 547 { 548 UWORD i, Width; 549 Width = (Xend-Xstart)%8 == 0 ? (Xend-Xstart)/8 : (Xend-Xstart)/8+1; 550 UWORD IMAGE_COUNTER = Width * (Yend-Ystart); 551 552 EPD_3IN7_SendCommand(0x44); 553 EPD_3IN7_SendData(Xstart & 0xff); 554 EPD_3IN7_SendData((Xstart>>8) & 0x03); 555 EPD_3IN7_SendData(Xend & 0xff); 556 EPD_3IN7_SendData((Xend>>8) & 0x03); 557 EPD_3IN7_SendCommand(0x45); 558 EPD_3IN7_SendData(Ystart & 0xff); 559 EPD_3IN7_SendData((Ystart>>8) & 0x03); 560 EPD_3IN7_SendData(Yend & 0xff); 561 EPD_3IN7_SendData((Yend>>8) & 0x03); 562 563 EPD_3IN7_SendCommand(0x24); 564 for (i = 0; i < IMAGE_COUNTER; i++) 565 { 566 EPD_3IN7_SendData(Image[i]); 567 } 568 569 EPD_3IN7_Load_LUT(2); 570 EPD_3IN7_SendCommand(0x20); 571 EPD_3IN7_ReadBusy_HIGH(); 572 } 573 574 /****************************************************************************** 575 function : Enter sleep mode 576 parameter: 577 ******************************************************************************/ 578 void EPD_3IN7_Sleep(void) 579 { 580 EPD_3IN7_SendCommand(0X50); 581 EPD_3IN7_SendData(0xf7); 582 EPD_3IN7_SendCommand(0X02); //power off 583 EPD_3IN7_SendCommand(0X07); //deep sleep 584 EPD_3IN7_SendData(0xA5); 585 }