EPD_3in52.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /*****************************************************************************
  2. * | File : EPD_3IN52.C
  3. * | Author : Waveshare team
  4. * | Function : 3.52inch e-paper
  5. * | Info :
  6. *----------------
  7. * | This version: V1.0
  8. * | Date : 2022-05-07
  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_3in52.h"
  32. #include "Debug.h"
  33. //GC 0.9S
  34. static const UBYTE EPD_3IN52_lut_R20_GC[] =
  35. {
  36. 0x01,0x0f,0x0f,0x0f,0x01,0x01,0x01,
  37. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  38. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  39. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  40. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  41. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  42. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  43. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  44. };
  45. static const UBYTE EPD_3IN52_lut_R21_GC[] =
  46. {
  47. 0x01,0x4f,0x8f,0x0f,0x01,0x01,0x01,
  48. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  49. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  50. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  51. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  52. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  53. };
  54. static const UBYTE EPD_3IN52_lut_R22_GC[] =
  55. {
  56. 0x01,0x0f,0x8f,0x0f,0x01,0x01,0x01,
  57. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  58. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  59. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  60. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  61. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  62. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  63. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  64. };
  65. static const UBYTE EPD_3IN52_lut_R23_GC[] =
  66. {
  67. 0x01,0x4f,0x8f,0x4f,0x01,0x01,0x01,
  68. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  69. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  70. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  71. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  72. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  73. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  74. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  75. };
  76. static const UBYTE EPD_3IN52_lut_R24_GC[] =
  77. {
  78. 0x01,0x0f,0x8f,0x4f,0x01,0x01,0x01,
  79. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  80. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  81. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  82. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  83. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  84. };
  85. // DU 0.3s
  86. static const UBYTE EPD_3IN52_lut_R20_DU[] =
  87. {
  88. 0x01,0x0f,0x01,0x00,0x00,0x01,0x01,
  89. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  90. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  91. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  92. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  93. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  94. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  95. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  96. };
  97. static const UBYTE EPD_3IN52_lut_R21_DU[] =
  98. {
  99. 0x01,0x0f,0x01,0x00,0x00,0x01,0x01,
  100. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  101. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  102. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  103. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  104. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  105. };
  106. static const UBYTE EPD_3IN52_lut_R22_DU[] =
  107. {
  108. 0x01,0x8f,0x01,0x00,0x00,0x01,0x01,
  109. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  110. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  111. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  112. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  113. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  114. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  115. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  116. };
  117. static const UBYTE EPD_3IN52_lut_R23_DU[] =
  118. {
  119. 0x01,0x4f,0x01,0x00,0x00,0x01,0x01,
  120. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  121. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  122. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  123. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  124. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  125. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  126. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  127. };
  128. static const UBYTE EPD_3IN52_lut_R24_DU[] =
  129. {
  130. 0x01,0x0f,0x01,0x00,0x00,0x01,0x01,
  131. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  132. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  133. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  134. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  135. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  136. };
  137. //
  138. static const UBYTE EPD_3IN52_lut_vcom[] =
  139. {
  140. 0x01,0x19,0x19,0x19,0x19,0x01,0x01,
  141. 0x01,0x19,0x19,0x19,0x01,0x01,0x01,
  142. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  143. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  144. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  145. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  146. };
  147. static const UBYTE EPD_3IN52_lut_ww[] =
  148. {
  149. 0x01,0x59,0x99,0x59,0x99,0x01,0x01,
  150. 0x01,0x59,0x99,0x19,0x01,0x01,0x01,
  151. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  152. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  153. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  154. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  155. };
  156. static const UBYTE EPD_3IN52_lut_bw[] =
  157. {
  158. 0x01,0x59,0x99,0x59,0x99,0x01,0x01,
  159. 0x01,0x59,0x99,0x19,0x01,0x01,0x01,
  160. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  161. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  162. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  163. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  164. };
  165. static const UBYTE EPD_3IN52_lut_wb[] =
  166. {
  167. 0x01,0x19,0x99,0x59,0x99,0x01,0x01,
  168. 0x01,0x59,0x99,0x59,0x01,0x01,0x01,
  169. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  170. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  171. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  172. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  173. };
  174. static const UBYTE EPD_3IN52_lut_bb[] =
  175. {
  176. 0x01,0x19,0x99,0x59,0x99,0x01,0x01,
  177. 0x01,0x59,0x99,0x59,0x01,0x01,0x01,
  178. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  179. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  180. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  181. 0x00,0x00,0x00,0x00,0x00,0x00,0x00
  182. };
  183. unsigned char EPD_3IN52_Flag = 0;
  184. /******************************************************************************
  185. function : Software reset
  186. parameter:
  187. ******************************************************************************/
  188. void EPD_3IN52_Reset(void)
  189. {
  190. DEV_Digital_Write(EPD_RST_PIN, 1);
  191. DEV_Delay_ms(200);
  192. DEV_Digital_Write(EPD_RST_PIN, 0);
  193. DEV_Delay_ms(2);
  194. DEV_Digital_Write(EPD_RST_PIN, 1);
  195. DEV_Delay_ms(200);
  196. }
  197. /******************************************************************************
  198. function : send command
  199. parameter:
  200. Reg : Command register
  201. ******************************************************************************/
  202. void EPD_3IN52_SendCommand(UBYTE Reg)
  203. {
  204. DEV_Digital_Write(EPD_DC_PIN, 0);
  205. DEV_Digital_Write(EPD_CS_PIN, 0);
  206. DEV_SPI_WriteByte(Reg);
  207. DEV_Digital_Write(EPD_CS_PIN, 1);
  208. }
  209. /******************************************************************************
  210. function : send data
  211. parameter:
  212. Data : Write data
  213. ******************************************************************************/
  214. void EPD_3IN52_SendData(UBYTE Data)
  215. {
  216. DEV_Digital_Write(EPD_DC_PIN, 1);
  217. DEV_Digital_Write(EPD_CS_PIN, 0);
  218. DEV_SPI_WriteByte(Data);
  219. DEV_Digital_Write(EPD_CS_PIN, 1);
  220. }
  221. /******************************************************************************
  222. function : Read Busy
  223. parameter:
  224. ******************************************************************************/
  225. void EPD_3IN52_ReadBusy(void)
  226. {
  227. EPD_Busy_WaitUntil(1,0);
  228. // Debug("e-Paper busy\r\n");
  229. // UBYTE busy;
  230. // do {
  231. // busy = DEV_Digital_Read(EPD_BUSY_PIN);
  232. // } while(!busy);
  233. // DEV_Delay_ms(200);
  234. // Debug("e-Paper busy release\r\n");
  235. }
  236. /**
  237. * @brief
  238. *
  239. */
  240. void EPD_3IN52_lut(void)
  241. {
  242. UBYTE count;
  243. EPD_3IN52_SendCommand(0x20); // vcom
  244. for(count = 0; count < 42 ; count++)
  245. {
  246. EPD_3IN52_SendData(EPD_3IN52_lut_vcom[count]);
  247. }
  248. EPD_3IN52_SendCommand(0x21); // ww --
  249. for(count = 0; count < 42 ; count++)
  250. {
  251. EPD_3IN52_SendData(EPD_3IN52_lut_ww[count]);
  252. }
  253. EPD_3IN52_SendCommand(0x22); // bw r
  254. for(count = 0; count < 42 ; count++)
  255. {
  256. EPD_3IN52_SendData(EPD_3IN52_lut_bw[count]);
  257. }
  258. EPD_3IN52_SendCommand(0x23); // wb w
  259. for(count = 0; count < 42 ; count++)
  260. {
  261. EPD_3IN52_SendData(EPD_3IN52_lut_bb[count]);
  262. }
  263. EPD_3IN52_SendCommand(0x24); // bb b
  264. for(count = 0; count < 42 ; count++)
  265. {
  266. EPD_3IN52_SendData(EPD_3IN52_lut_wb[count]);
  267. }
  268. }
  269. /**
  270. * @brief
  271. *
  272. */
  273. void EPD_3IN52_refresh(void)
  274. {
  275. EPD_3IN52_SendCommand(0x17);
  276. EPD_3IN52_SendData(0xA5);
  277. EPD_3IN52_ReadBusy();
  278. DEV_Delay_ms(200);
  279. }
  280. // LUT download
  281. void EPD_3IN52_lut_GC(void)
  282. {
  283. UBYTE count;
  284. EPD_3IN52_SendCommand(0x20); // vcom
  285. for(count = 0; count < 56 ; count++)
  286. {
  287. EPD_3IN52_SendData(EPD_3IN52_lut_R20_GC[count]);
  288. }
  289. EPD_3IN52_SendCommand(0x21); // red not use
  290. for(count = 0; count < 42 ; count++)
  291. {
  292. EPD_3IN52_SendData(EPD_3IN52_lut_R21_GC[count]);
  293. }
  294. EPD_3IN52_SendCommand(0x24); // bb b
  295. for(count = 0; count < 42 ; count++)
  296. {
  297. EPD_3IN52_SendData(EPD_3IN52_lut_R24_GC[count]);
  298. }
  299. if(EPD_3IN52_Flag == 0)
  300. {
  301. EPD_3IN52_SendCommand(0x22); // bw r
  302. for(count = 0; count < 56 ; count++)
  303. {
  304. EPD_3IN52_SendData(EPD_3IN52_lut_R22_GC[count]);
  305. }
  306. EPD_3IN52_SendCommand(0x23); // wb w
  307. for(count = 0; count < 42 ; count++)
  308. {
  309. EPD_3IN52_SendData(EPD_3IN52_lut_R23_GC[count]);
  310. }
  311. EPD_3IN52_Flag = 1;
  312. }
  313. else
  314. {
  315. EPD_3IN52_SendCommand(0x22); // bw r
  316. for(count = 0; count < 56 ; count++)
  317. {
  318. EPD_3IN52_SendData(EPD_3IN52_lut_R23_GC[count]);
  319. }
  320. EPD_3IN52_SendCommand(0x23); // wb w
  321. for(count = 0; count < 42 ; count++)
  322. {
  323. EPD_3IN52_SendData(EPD_3IN52_lut_R22_GC[count]);
  324. }
  325. EPD_3IN52_Flag = 0;
  326. }
  327. }
  328. // LUT download
  329. void EPD_3IN52_lut_DU(void)
  330. {
  331. UBYTE count;
  332. EPD_3IN52_SendCommand(0x20); // vcom
  333. for(count = 0; count < 56 ; count++)
  334. {
  335. EPD_3IN52_SendData(EPD_3IN52_lut_R20_DU[count]);
  336. }
  337. EPD_3IN52_SendCommand(0x21); // red not use
  338. for(count = 0; count < 42 ; count++)
  339. {
  340. EPD_3IN52_SendData(EPD_3IN52_lut_R21_DU[count]);
  341. }
  342. EPD_3IN52_SendCommand(0x24); // bb b
  343. for(count = 0; count < 42 ; count++)
  344. {
  345. EPD_3IN52_SendData(EPD_3IN52_lut_R24_DU[count]);
  346. }
  347. if(EPD_3IN52_Flag == 0)
  348. {
  349. EPD_3IN52_SendCommand(0x22); // bw r
  350. for(count = 0; count < 56 ; count++)
  351. {
  352. EPD_3IN52_SendData(EPD_3IN52_lut_R22_DU[count]);
  353. }
  354. EPD_3IN52_SendCommand(0x23); // wb w
  355. for(count = 0; count < 42 ; count++)
  356. {
  357. EPD_3IN52_SendData(EPD_3IN52_lut_R23_DU[count]);
  358. }
  359. EPD_3IN52_Flag = 1;
  360. }
  361. else
  362. {
  363. EPD_3IN52_SendCommand(0x22); // bw r
  364. for(count = 0; count < 56 ; count++)
  365. {
  366. EPD_3IN52_SendData(EPD_3IN52_lut_R23_DU[count]);
  367. }
  368. EPD_3IN52_SendCommand(0x23); // wb w
  369. for(count = 0; count < 42 ; count++)
  370. {
  371. EPD_3IN52_SendData(EPD_3IN52_lut_R22_DU[count]);
  372. }
  373. EPD_3IN52_Flag = 0;
  374. }
  375. }
  376. /******************************************************************************
  377. function : Initialize the e-Paper register
  378. parameter:
  379. ******************************************************************************/
  380. void EPD_3IN52_Init(UBYTE mode)
  381. {
  382. EPD_3IN52_Flag = 0;
  383. EPD_3IN52_Reset();
  384. EPD_3IN52_SendCommand(0x00); // panel setting PSR
  385. EPD_3IN52_SendData(0xFF); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N
  386. EPD_3IN52_SendData(0x01); // x x x VCMZ TS_AUTO TIGE NORG VC_LUTZ
  387. EPD_3IN52_SendCommand(0x01); // POWER SETTING PWR
  388. EPD_3IN52_SendData(0x03); // x x x x x x VDS_EN VDG_EN
  389. EPD_3IN52_SendData(0x10); // x x x VCOM_SLWE VGH[3:0] VGH=20V, VGL=-20V
  390. EPD_3IN52_SendData(0x3F); // x x VSH[5:0] VSH = 15V
  391. EPD_3IN52_SendData(0x3F); // x x VSL[5:0] VSL=-15V
  392. EPD_3IN52_SendData(0x03); // OPTEN VDHR[6:0] VHDR=6.4V
  393. // T_VDS_OFF[1:0] 00=1 frame; 01=2 frame; 10=3 frame; 11=4 frame
  394. EPD_3IN52_SendCommand(0x06); // booster soft start BTST
  395. EPD_3IN52_SendData(0x37); // BT_PHA[7:0]
  396. EPD_3IN52_SendData(0x3D); // BT_PHB[7:0]
  397. EPD_3IN52_SendData(0x3D); // x x BT_PHC[5:0]
  398. EPD_3IN52_SendCommand(0x60); // TCON setting TCON
  399. EPD_3IN52_SendData(0x22); // S2G[3:0] G2S[3:0] non-overlap = 12
  400. EPD_3IN52_SendCommand(0x82); // VCOM_DC setting VDCS
  401. EPD_3IN52_SendData(0x07); // x VDCS[6:0] VCOM_DC value= -1.9v 00~3f,0x12=-1.9v
  402. EPD_3IN52_SendCommand(0x30);
  403. EPD_3IN52_SendData(0x09);
  404. EPD_3IN52_SendCommand(0xe3); // power saving PWS
  405. EPD_3IN52_SendData(0x88); // VCOM_W[3:0] SD_W[3:0]
  406. EPD_3IN52_SendCommand(0x61); // resoultion setting
  407. EPD_3IN52_SendData(0xf0); // HRES[7:3] 0 0 0
  408. EPD_3IN52_SendData(0x01); // x x x x x x x VRES[8]
  409. EPD_3IN52_SendData(0x68); // VRES[7:0]
  410. EPD_3IN52_SendCommand(0x50);
  411. EPD_3IN52_SendData(0xB7);
  412. // add for luatos
  413. EPD_3IN52_display_NUM(EPD_3IN52_WHITE);
  414. EPD_3IN52_lut_GC();
  415. EPD_3IN52_refresh();
  416. EPD_3IN52_SendCommand(0x50);
  417. EPD_3IN52_SendData(0x17);
  418. }
  419. void EPD_3IN52_display(UBYTE *Image, UBYTE *Image2)
  420. {
  421. UWORD i;
  422. EPD_3IN52_SendCommand(0x13); //Transfer new data
  423. for(i=0;i<(EPD_3IN52_WIDTH*EPD_3IN52_HEIGHT/8);i++)
  424. {
  425. EPD_3IN52_SendData(*Image);
  426. Image++;
  427. }
  428. // add for luatos
  429. EPD_3IN52_lut_GC();
  430. EPD_3IN52_refresh();
  431. }
  432. void EPD_3IN52_display_NUM(UBYTE NUM)
  433. {
  434. UWORD row, column;
  435. // UWORD pcnt = 0;
  436. EPD_3IN52_SendCommand(0x13); //Transfer new data
  437. for(column=0; column<EPD_3IN52_HEIGHT; column++)
  438. {
  439. for(row=0; row<EPD_3IN52_WIDTH/8; row++)
  440. {
  441. switch (NUM)
  442. {
  443. case EPD_3IN52_WHITE:
  444. EPD_3IN52_SendData(0xFF);
  445. break;
  446. case EPD_3IN52_BLACK:
  447. EPD_3IN52_SendData(0x00);
  448. break;
  449. case EPD_3IN52_Source_Line:
  450. EPD_3IN52_SendData(0xAA);
  451. break;
  452. case EPD_3IN52_Gate_Line:
  453. if(column%2)
  454. EPD_3IN52_SendData(0xff); //An odd number of Gate line
  455. else
  456. EPD_3IN52_SendData(0x00); //The even line Gate
  457. break;
  458. case EPD_3IN52_Chessboard:
  459. if(row>=(EPD_3IN52_WIDTH/8/2)&&column>=(EPD_3IN52_HEIGHT/2))
  460. EPD_3IN52_SendData(0xff);
  461. else if(row<(EPD_3IN52_WIDTH/8/2)&&column<(EPD_3IN52_HEIGHT/2))
  462. EPD_3IN52_SendData(0xff);
  463. else
  464. EPD_3IN52_SendData(0x00);
  465. break;
  466. case EPD_3IN52_LEFT_BLACK_RIGHT_WHITE:
  467. if(row>=(EPD_3IN52_WIDTH/8/2))
  468. EPD_3IN52_SendData(0xff);
  469. else
  470. EPD_3IN52_SendData(0x00);
  471. break;
  472. case EPD_3IN52_UP_BLACK_DOWN_WHITE:
  473. if(column>=(EPD_3IN52_HEIGHT/2))
  474. EPD_3IN52_SendData(0xFF);
  475. else
  476. EPD_3IN52_SendData(0x00);
  477. break;
  478. case EPD_3IN52_Frame:
  479. if(column==0||column==(EPD_3IN52_HEIGHT-1))
  480. EPD_3IN52_SendData(0x00);
  481. else if(row==0)
  482. EPD_3IN52_SendData(0x7F);
  483. else if(row==(EPD_3IN52_WIDTH/8-1))
  484. EPD_3IN52_SendData(0xFE);
  485. else
  486. EPD_3IN52_SendData(0xFF);
  487. break;
  488. case EPD_3IN52_Crosstalk:
  489. if((row>=(EPD_3IN52_WIDTH/8/3)&&row<=(EPD_3IN52_WIDTH/8/3*2)&&column<=(EPD_3IN52_HEIGHT/3))||(row>=(EPD_3IN52_WIDTH/8/3)&&row<=(EPD_3IN52_WIDTH/8/3*2)&&column>=(EPD_3IN52_HEIGHT/3*2)))
  490. EPD_3IN52_SendData(0x00);
  491. else
  492. EPD_3IN52_SendData(0xFF);
  493. break;
  494. case EPD_3IN52_Image:
  495. //EPD_3IN52_SendData(gImage_1[pcnt++]);
  496. break;
  497. default:
  498. break;
  499. }
  500. }
  501. }
  502. }
  503. /******************************************************************************
  504. function : Clear screen
  505. parameter:
  506. ******************************************************************************/
  507. void EPD_3IN52_Clear(void)
  508. {
  509. UWORD i;
  510. EPD_3IN52_SendCommand(0x13); //Transfer new data
  511. for(i=0;i<(EPD_3IN52_WIDTH*EPD_3IN52_HEIGHT/8);i++)
  512. {
  513. EPD_3IN52_SendData(0xFF);
  514. }
  515. EPD_3IN52_lut_GC();
  516. EPD_3IN52_refresh();
  517. }
  518. /******************************************************************************
  519. function : Enter sleep mode
  520. parameter:
  521. ******************************************************************************/
  522. void EPD_3IN52_sleep(void)
  523. {
  524. EPD_3IN52_SendCommand(0X07); //deep sleep
  525. EPD_3IN52_SendData(0xA5);
  526. }