EPD_3in52.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. Debug("e-Paper busy\r\n");
  228. UBYTE busy;
  229. do {
  230. busy = DEV_Digital_Read(EPD_BUSY_PIN);
  231. } while(!busy);
  232. DEV_Delay_ms(200);
  233. Debug("e-Paper busy release\r\n");
  234. }
  235. /**
  236. * @brief
  237. *
  238. */
  239. void EPD_3IN52_lut(void)
  240. {
  241. UBYTE count;
  242. EPD_3IN52_SendCommand(0x20); // vcom
  243. for(count = 0; count < 42 ; count++)
  244. {
  245. EPD_3IN52_SendData(EPD_3IN52_lut_vcom[count]);
  246. }
  247. EPD_3IN52_SendCommand(0x21); // ww --
  248. for(count = 0; count < 42 ; count++)
  249. {
  250. EPD_3IN52_SendData(EPD_3IN52_lut_ww[count]);
  251. }
  252. EPD_3IN52_SendCommand(0x22); // bw r
  253. for(count = 0; count < 42 ; count++)
  254. {
  255. EPD_3IN52_SendData(EPD_3IN52_lut_bw[count]);
  256. }
  257. EPD_3IN52_SendCommand(0x23); // wb w
  258. for(count = 0; count < 42 ; count++)
  259. {
  260. EPD_3IN52_SendData(EPD_3IN52_lut_bb[count]);
  261. }
  262. EPD_3IN52_SendCommand(0x24); // bb b
  263. for(count = 0; count < 42 ; count++)
  264. {
  265. EPD_3IN52_SendData(EPD_3IN52_lut_wb[count]);
  266. }
  267. }
  268. /**
  269. * @brief
  270. *
  271. */
  272. void EPD_3IN52_refresh(void)
  273. {
  274. EPD_3IN52_SendCommand(0x17);
  275. EPD_3IN52_SendData(0xA5);
  276. EPD_3IN52_ReadBusy();
  277. DEV_Delay_ms(200);
  278. }
  279. // LUT download
  280. void EPD_3IN52_lut_GC(void)
  281. {
  282. UBYTE count;
  283. EPD_3IN52_SendCommand(0x20); // vcom
  284. for(count = 0; count < 56 ; count++)
  285. {
  286. EPD_3IN52_SendData(EPD_3IN52_lut_R20_GC[count]);
  287. }
  288. EPD_3IN52_SendCommand(0x21); // red not use
  289. for(count = 0; count < 42 ; count++)
  290. {
  291. EPD_3IN52_SendData(EPD_3IN52_lut_R21_GC[count]);
  292. }
  293. EPD_3IN52_SendCommand(0x24); // bb b
  294. for(count = 0; count < 42 ; count++)
  295. {
  296. EPD_3IN52_SendData(EPD_3IN52_lut_R24_GC[count]);
  297. }
  298. if(EPD_3IN52_Flag == 0)
  299. {
  300. EPD_3IN52_SendCommand(0x22); // bw r
  301. for(count = 0; count < 56 ; count++)
  302. {
  303. EPD_3IN52_SendData(EPD_3IN52_lut_R22_GC[count]);
  304. }
  305. EPD_3IN52_SendCommand(0x23); // wb w
  306. for(count = 0; count < 42 ; count++)
  307. {
  308. EPD_3IN52_SendData(EPD_3IN52_lut_R23_GC[count]);
  309. }
  310. EPD_3IN52_Flag = 1;
  311. }
  312. else
  313. {
  314. EPD_3IN52_SendCommand(0x22); // bw r
  315. for(count = 0; count < 56 ; count++)
  316. {
  317. EPD_3IN52_SendData(EPD_3IN52_lut_R23_GC[count]);
  318. }
  319. EPD_3IN52_SendCommand(0x23); // wb w
  320. for(count = 0; count < 42 ; count++)
  321. {
  322. EPD_3IN52_SendData(EPD_3IN52_lut_R22_GC[count]);
  323. }
  324. EPD_3IN52_Flag = 0;
  325. }
  326. }
  327. // LUT download
  328. void EPD_3IN52_lut_DU(void)
  329. {
  330. UBYTE count;
  331. EPD_3IN52_SendCommand(0x20); // vcom
  332. for(count = 0; count < 56 ; count++)
  333. {
  334. EPD_3IN52_SendData(EPD_3IN52_lut_R20_DU[count]);
  335. }
  336. EPD_3IN52_SendCommand(0x21); // red not use
  337. for(count = 0; count < 42 ; count++)
  338. {
  339. EPD_3IN52_SendData(EPD_3IN52_lut_R21_DU[count]);
  340. }
  341. EPD_3IN52_SendCommand(0x24); // bb b
  342. for(count = 0; count < 42 ; count++)
  343. {
  344. EPD_3IN52_SendData(EPD_3IN52_lut_R24_DU[count]);
  345. }
  346. if(EPD_3IN52_Flag == 0)
  347. {
  348. EPD_3IN52_SendCommand(0x22); // bw r
  349. for(count = 0; count < 56 ; count++)
  350. {
  351. EPD_3IN52_SendData(EPD_3IN52_lut_R22_DU[count]);
  352. }
  353. EPD_3IN52_SendCommand(0x23); // wb w
  354. for(count = 0; count < 42 ; count++)
  355. {
  356. EPD_3IN52_SendData(EPD_3IN52_lut_R23_DU[count]);
  357. }
  358. EPD_3IN52_Flag = 1;
  359. }
  360. else
  361. {
  362. EPD_3IN52_SendCommand(0x22); // bw r
  363. for(count = 0; count < 56 ; count++)
  364. {
  365. EPD_3IN52_SendData(EPD_3IN52_lut_R23_DU[count]);
  366. }
  367. EPD_3IN52_SendCommand(0x23); // wb w
  368. for(count = 0; count < 42 ; count++)
  369. {
  370. EPD_3IN52_SendData(EPD_3IN52_lut_R22_DU[count]);
  371. }
  372. EPD_3IN52_Flag = 0;
  373. }
  374. }
  375. /******************************************************************************
  376. function : Initialize the e-Paper register
  377. parameter:
  378. ******************************************************************************/
  379. void EPD_3IN52_Init(void)
  380. {
  381. EPD_3IN52_Flag = 0;
  382. EPD_3IN52_Reset();
  383. EPD_3IN52_SendCommand(0x00); // panel setting PSR
  384. EPD_3IN52_SendData(0xFF); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N
  385. EPD_3IN52_SendData(0x01); // x x x VCMZ TS_AUTO TIGE NORG VC_LUTZ
  386. EPD_3IN52_SendCommand(0x01); // POWER SETTING PWR
  387. EPD_3IN52_SendData(0x03); // x x x x x x VDS_EN VDG_EN
  388. EPD_3IN52_SendData(0x10); // x x x VCOM_SLWE VGH[3:0] VGH=20V, VGL=-20V
  389. EPD_3IN52_SendData(0x3F); // x x VSH[5:0] VSH = 15V
  390. EPD_3IN52_SendData(0x3F); // x x VSL[5:0] VSL=-15V
  391. EPD_3IN52_SendData(0x03); // OPTEN VDHR[6:0] VHDR=6.4V
  392. // T_VDS_OFF[1:0] 00=1 frame; 01=2 frame; 10=3 frame; 11=4 frame
  393. EPD_3IN52_SendCommand(0x06); // booster soft start BTST
  394. EPD_3IN52_SendData(0x37); // BT_PHA[7:0]
  395. EPD_3IN52_SendData(0x3D); // BT_PHB[7:0]
  396. EPD_3IN52_SendData(0x3D); // x x BT_PHC[5:0]
  397. EPD_3IN52_SendCommand(0x60); // TCON setting TCON
  398. EPD_3IN52_SendData(0x22); // S2G[3:0] G2S[3:0] non-overlap = 12
  399. EPD_3IN52_SendCommand(0x82); // VCOM_DC setting VDCS
  400. EPD_3IN52_SendData(0x07); // x VDCS[6:0] VCOM_DC value= -1.9v 00~3f,0x12=-1.9v
  401. EPD_3IN52_SendCommand(0x30);
  402. EPD_3IN52_SendData(0x09);
  403. EPD_3IN52_SendCommand(0xe3); // power saving PWS
  404. EPD_3IN52_SendData(0x88); // VCOM_W[3:0] SD_W[3:0]
  405. EPD_3IN52_SendCommand(0x61); // resoultion setting
  406. EPD_3IN52_SendData(0xf0); // HRES[7:3] 0 0 0
  407. EPD_3IN52_SendData(0x01); // x x x x x x x VRES[8]
  408. EPD_3IN52_SendData(0x68); // VRES[7:0]
  409. EPD_3IN52_SendCommand(0x50);
  410. EPD_3IN52_SendData(0xB7);
  411. }
  412. void EPD_3IN52_display(UBYTE* picData)
  413. {
  414. UWORD i;
  415. EPD_3IN52_SendCommand(0x13); //Transfer new data
  416. for(i=0;i<(EPD_3IN52_WIDTH*EPD_3IN52_HEIGHT/8);i++)
  417. {
  418. EPD_3IN52_SendData(*picData);
  419. picData++;
  420. }
  421. }
  422. void EPD_3IN52_display_NUM(UBYTE NUM)
  423. {
  424. UWORD row, column;
  425. // UWORD pcnt = 0;
  426. EPD_3IN52_SendCommand(0x13); //Transfer new data
  427. for(column=0; column<EPD_3IN52_HEIGHT; column++)
  428. {
  429. for(row=0; row<EPD_3IN52_WIDTH/8; row++)
  430. {
  431. switch (NUM)
  432. {
  433. case EPD_3IN52_WHITE:
  434. EPD_3IN52_SendData(0xFF);
  435. break;
  436. case EPD_3IN52_BLACK:
  437. EPD_3IN52_SendData(0x00);
  438. break;
  439. case EPD_3IN52_Source_Line:
  440. EPD_3IN52_SendData(0xAA);
  441. break;
  442. case EPD_3IN52_Gate_Line:
  443. if(column%2)
  444. EPD_3IN52_SendData(0xff); //An odd number of Gate line
  445. else
  446. EPD_3IN52_SendData(0x00); //The even line Gate
  447. break;
  448. case EPD_3IN52_Chessboard:
  449. if(row>=(EPD_3IN52_WIDTH/8/2)&&column>=(EPD_3IN52_HEIGHT/2))
  450. EPD_3IN52_SendData(0xff);
  451. else if(row<(EPD_3IN52_WIDTH/8/2)&&column<(EPD_3IN52_HEIGHT/2))
  452. EPD_3IN52_SendData(0xff);
  453. else
  454. EPD_3IN52_SendData(0x00);
  455. break;
  456. case EPD_3IN52_LEFT_BLACK_RIGHT_WHITE:
  457. if(row>=(EPD_3IN52_WIDTH/8/2))
  458. EPD_3IN52_SendData(0xff);
  459. else
  460. EPD_3IN52_SendData(0x00);
  461. break;
  462. case EPD_3IN52_UP_BLACK_DOWN_WHITE:
  463. if(column>=(EPD_3IN52_HEIGHT/2))
  464. EPD_3IN52_SendData(0xFF);
  465. else
  466. EPD_3IN52_SendData(0x00);
  467. break;
  468. case EPD_3IN52_Frame:
  469. if(column==0||column==(EPD_3IN52_HEIGHT-1))
  470. EPD_3IN52_SendData(0x00);
  471. else if(row==0)
  472. EPD_3IN52_SendData(0x7F);
  473. else if(row==(EPD_3IN52_WIDTH/8-1))
  474. EPD_3IN52_SendData(0xFE);
  475. else
  476. EPD_3IN52_SendData(0xFF);
  477. break;
  478. case EPD_3IN52_Crosstalk:
  479. 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)))
  480. EPD_3IN52_SendData(0x00);
  481. else
  482. EPD_3IN52_SendData(0xFF);
  483. break;
  484. case EPD_3IN52_Image:
  485. //EPD_3IN52_SendData(gImage_1[pcnt++]);
  486. break;
  487. default:
  488. break;
  489. }
  490. }
  491. }
  492. }
  493. /******************************************************************************
  494. function : Clear screen
  495. parameter:
  496. ******************************************************************************/
  497. void EPD_3IN52_Clear(void)
  498. {
  499. UWORD i;
  500. EPD_3IN52_SendCommand(0x13); //Transfer new data
  501. for(i=0;i<(EPD_3IN52_WIDTH*EPD_3IN52_HEIGHT/8);i++)
  502. {
  503. EPD_3IN52_SendData(0xFF);
  504. }
  505. EPD_3IN52_lut_GC();
  506. EPD_3IN52_refresh();
  507. }
  508. /******************************************************************************
  509. function : Enter sleep mode
  510. parameter:
  511. ******************************************************************************/
  512. void EPD_3IN52_sleep(void)
  513. {
  514. EPD_3IN52_SendCommand(0X07); //deep sleep
  515. EPD_3IN52_SendData(0xA5);
  516. }