GxEPD2_213_flex.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. // Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
  2. // Requires HW SPI and Adafruit_GFX. Caution: these e-papers require 3.3V supply AND data lines!
  3. //
  4. // based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
  5. // Controller: IL0373 : http://www.e-paper-display.com/download_detail/downloadsId=535.html
  6. //
  7. // Author: Jean-Marc Zingg
  8. //
  9. // Version: see library.properties
  10. //
  11. // Library: https://github.com/ZinggJM/GxEPD2
  12. #include "GxEPD2_213_flex.h"
  13. GxEPD2_213_flex::GxEPD2_213_flex(int16_t cs, int16_t dc, int16_t rst, int16_t busy) :
  14. GxEPD2_EPD(cs, dc, rst, busy, LOW, 10000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
  15. {
  16. }
  17. void GxEPD2_213_flex::clearScreen(uint8_t value)
  18. {
  19. writeScreenBuffer(value);
  20. refresh(true);
  21. writeScreenBuffer(value);
  22. }
  23. void GxEPD2_213_flex::writeScreenBuffer(uint8_t value)
  24. {
  25. _initial_write = false; // initial full screen buffer clean done
  26. if (!_using_partial_mode) _Init_Part();
  27. _writeCommand(0x13); // set current
  28. for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 8; i++)
  29. {
  30. _writeData(value);
  31. }
  32. if (_initial_refresh)
  33. {
  34. _writeCommand(0x10); // preset previous
  35. for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 8; i++)
  36. {
  37. _writeData(0xFF); // 0xFF is white
  38. }
  39. }
  40. }
  41. void GxEPD2_213_flex::writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  42. {
  43. _writeImage(0x13, bitmap, x, y, w, h, invert, mirror_y, pgm);
  44. }
  45. void GxEPD2_213_flex::writeImageToPrevious(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  46. {
  47. _writeImage(0x10, bitmap, x, y, w, h, invert, mirror_y, pgm);
  48. }
  49. void GxEPD2_213_flex::_writeImage(uint8_t command, const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  50. {
  51. if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
  52. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  53. int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
  54. x -= x % 8; // byte boundary
  55. w = wb * 8; // byte boundary
  56. int16_t x1 = x < 0 ? 0 : x; // limit
  57. int16_t y1 = y < 0 ? 0 : y; // limit
  58. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  59. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  60. int16_t dx = x1 - x;
  61. int16_t dy = y1 - y;
  62. w1 -= dx;
  63. h1 -= dy;
  64. if ((w1 <= 0) || (h1 <= 0)) return;
  65. if (!_using_partial_mode) _Init_Part();
  66. _writeCommand(0x91); // partial in
  67. _setPartialRamArea(x1, y1, w1, h1);
  68. _writeCommand(command);
  69. _startTransfer();
  70. for (int16_t i = 0; i < h1; i++)
  71. {
  72. for (int16_t j = 0; j < w1 / 8; j++)
  73. {
  74. uint8_t data;
  75. // use wb, h of bitmap for index!
  76. int16_t idx = mirror_y ? j + dx / 8 + ((h - 1 - (i + dy))) * wb : j + dx / 8 + (i + dy) * wb;
  77. if (pgm)
  78. {
  79. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  80. data = pgm_read_byte(&bitmap[idx]);
  81. #else
  82. data = bitmap[idx];
  83. #endif
  84. }
  85. else
  86. {
  87. data = bitmap[idx];
  88. }
  89. if (invert) data = ~data;
  90. _transfer(data);
  91. }
  92. }
  93. _endTransfer();
  94. _writeCommand(0x92); // partial out
  95. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  96. }
  97. void GxEPD2_213_flex::writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  98. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  99. {
  100. _writeImagePart(0x13, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  101. }
  102. void GxEPD2_213_flex::writeImagePartToPrevious(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  103. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  104. {
  105. _writeImagePart(0x10, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  106. }
  107. void GxEPD2_213_flex::_writeImagePart(uint8_t command, const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  108. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  109. {
  110. if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
  111. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  112. if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
  113. if ((x_part < 0) || (x_part >= w_bitmap)) return;
  114. if ((y_part < 0) || (y_part >= h_bitmap)) return;
  115. int16_t wb_bitmap = (w_bitmap + 7) / 8; // width bytes, bitmaps are padded
  116. x_part -= x_part % 8; // byte boundary
  117. w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
  118. h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
  119. x -= x % 8; // byte boundary
  120. w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
  121. int16_t x1 = x < 0 ? 0 : x; // limit
  122. int16_t y1 = y < 0 ? 0 : y; // limit
  123. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  124. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  125. int16_t dx = x1 - x;
  126. int16_t dy = y1 - y;
  127. w1 -= dx;
  128. h1 -= dy;
  129. if ((w1 <= 0) || (h1 <= 0)) return;
  130. if (!_using_partial_mode) _Init_Part();
  131. _writeCommand(0x91); // partial in
  132. _setPartialRamArea(x1, y1, w1, h1);
  133. _writeCommand(command);
  134. _startTransfer();
  135. for (int16_t i = 0; i < h1; i++)
  136. {
  137. for (int16_t j = 0; j < w1 / 8; j++)
  138. {
  139. uint8_t data;
  140. // use wb_bitmap, h_bitmap of bitmap for index!
  141. int16_t idx = mirror_y ? x_part / 8 + j + dx / 8 + ((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + (y_part + i + dy) * wb_bitmap;
  142. if (pgm)
  143. {
  144. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  145. data = pgm_read_byte(&bitmap[idx]);
  146. #else
  147. data = bitmap[idx];
  148. #endif
  149. }
  150. else
  151. {
  152. data = bitmap[idx];
  153. }
  154. if (invert) data = ~data;
  155. _transfer(data);
  156. }
  157. }
  158. _endTransfer();
  159. _writeCommand(0x92); // partial out
  160. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  161. }
  162. void GxEPD2_213_flex::writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  163. {
  164. if (black)
  165. {
  166. writeImage(black, x, y, w, h, invert, mirror_y, pgm);
  167. }
  168. }
  169. void GxEPD2_213_flex::writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  170. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  171. {
  172. if (black)
  173. {
  174. writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  175. }
  176. }
  177. void GxEPD2_213_flex::writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  178. {
  179. if (data1)
  180. {
  181. writeImage(data1, x, y, w, h, invert, mirror_y, pgm);
  182. }
  183. }
  184. void GxEPD2_213_flex::drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  185. {
  186. writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
  187. refresh(x, y, w, h);
  188. writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
  189. }
  190. void GxEPD2_213_flex::drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  191. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  192. {
  193. writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  194. refresh(x, y, w, h);
  195. writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  196. }
  197. void GxEPD2_213_flex::drawImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  198. {
  199. writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
  200. refresh(x, y, w, h);
  201. writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
  202. }
  203. void GxEPD2_213_flex::drawImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  204. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  205. {
  206. writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  207. refresh(x, y, w, h);
  208. writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  209. }
  210. void GxEPD2_213_flex::drawNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  211. {
  212. writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
  213. refresh(x, y, w, h);
  214. writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
  215. }
  216. void GxEPD2_213_flex::refresh(bool partial_update_mode)
  217. {
  218. if (partial_update_mode) refresh(0, 0, WIDTH, HEIGHT);
  219. else
  220. {
  221. if (_using_partial_mode) _Init_Full();
  222. _Update_Full();
  223. _initial_refresh = false; // initial full update done
  224. }
  225. }
  226. void GxEPD2_213_flex::refresh(int16_t x, int16_t y, int16_t w, int16_t h)
  227. {
  228. if (_initial_refresh) return refresh(false); // initial update needs be full update
  229. // intersection with screen
  230. int16_t w1 = x < 0 ? w + x : w; // reduce
  231. int16_t h1 = y < 0 ? h + y : h; // reduce
  232. int16_t x1 = x < 0 ? 0 : x; // limit
  233. int16_t y1 = y < 0 ? 0 : y; // limit
  234. w1 = x1 + w1 < int16_t(WIDTH) ? w1 : int16_t(WIDTH) - x1; // limit
  235. h1 = y1 + h1 < int16_t(HEIGHT) ? h1 : int16_t(HEIGHT) - y1; // limit
  236. if ((w1 <= 0) || (h1 <= 0)) return;
  237. // make x1, w1 multiple of 8
  238. w1 += x1 % 8;
  239. if (w1 % 8 > 0) w1 += 8 - w1 % 8;
  240. x1 -= x1 % 8;
  241. if (!_using_partial_mode) _Init_Part();
  242. _writeCommand(0x91); // partial in
  243. _setPartialRamArea(x1, y1, w1, h1);
  244. _Update_Part();
  245. _writeCommand(0x92); // partial out
  246. }
  247. void GxEPD2_213_flex::powerOff(void)
  248. {
  249. _PowerOff();
  250. }
  251. void GxEPD2_213_flex::hibernate()
  252. {
  253. _PowerOff();
  254. if (_rst >= 0)
  255. {
  256. _writeCommand(0x07); // deep sleep
  257. _writeData(0xA5); // check code
  258. _hibernating = true;
  259. }
  260. }
  261. void GxEPD2_213_flex::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
  262. {
  263. uint16_t xe = (x + w - 1) | 0x0007; // byte boundary inclusive (last byte)
  264. uint16_t ye = y + h - 1;
  265. x &= 0xFFF8; // byte boundary
  266. _writeCommand(0x90); // partial window
  267. //_writeData(x / 256);
  268. _writeData(x % 256);
  269. //_writeData(xe / 256);
  270. _writeData(xe % 256);
  271. _writeData(y / 256);
  272. _writeData(y % 256);
  273. _writeData(ye / 256);
  274. _writeData(ye % 256);
  275. _writeData(0x01); // don't see any difference
  276. //_writeData(0x00); // don't see any difference
  277. }
  278. void GxEPD2_213_flex::_PowerOn()
  279. {
  280. if (!_power_is_on)
  281. {
  282. _writeCommand(0x04);
  283. _waitWhileBusy("_PowerOn", power_on_time);
  284. }
  285. _power_is_on = true;
  286. }
  287. void GxEPD2_213_flex::_PowerOff()
  288. {
  289. _writeCommand(0x02); // power off
  290. _waitWhileBusy("_PowerOff", power_off_time);
  291. _power_is_on = false;
  292. _using_partial_mode = false;
  293. }
  294. void GxEPD2_213_flex::_InitDisplay()
  295. {
  296. if (_hibernating) _reset();
  297. _writeCommand(0x01); //POWER SETTING
  298. _writeData (0x03);
  299. _writeData (0x00);
  300. _writeData (0x2b);
  301. _writeData (0x2b);
  302. _writeData (0x03);
  303. _writeCommand(0x06); //boost soft start
  304. _writeData (0x17); //A
  305. _writeData (0x17); //B
  306. _writeData (0x17); //C
  307. _writeCommand(0x00); //panel setting
  308. _writeData(0xbf); //LUT from register, 128x296
  309. _writeData(0x0d); //VCOM to 0V fast
  310. _writeCommand(0x30); //PLL setting
  311. _writeData (0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
  312. _writeCommand(0x61); //resolution setting
  313. _writeData (WIDTH);
  314. _writeData (HEIGHT >> 8);
  315. _writeData (HEIGHT & 0xFF);
  316. }
  317. //full screen update LUT
  318. const unsigned char GxEPD2_213_flex::lut_20_vcomDC[] PROGMEM =
  319. {
  320. 0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
  321. 0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
  322. 0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
  323. 0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
  324. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  325. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  326. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  327. 0x00, 0x00,
  328. };
  329. const unsigned char GxEPD2_213_flex::lut_21_ww[] PROGMEM =
  330. {
  331. 0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
  332. 0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  333. 0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
  334. 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
  335. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  336. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  337. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  338. };
  339. const unsigned char GxEPD2_213_flex::lut_22_bw[] PROGMEM =
  340. {
  341. 0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
  342. 0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  343. 0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
  344. 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
  345. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  346. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  347. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  348. };
  349. const unsigned char GxEPD2_213_flex::lut_23_wb[] PROGMEM =
  350. {
  351. 0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
  352. 0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  353. 0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
  354. 0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
  355. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  356. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  357. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  358. };
  359. const unsigned char GxEPD2_213_flex::lut_24_bb[] PROGMEM =
  360. {
  361. 0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
  362. 0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  363. 0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
  364. 0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
  365. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  366. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  367. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  368. };
  369. //partial screen update LUT
  370. //#define Fx19 0x19 // original value is 25 (phase length)
  371. #define Fx19 0x28 // new value for test is 40 (phase length)
  372. const unsigned char GxEPD2_213_flex::lut_20_vcomDC_partial[] PROGMEM =
  373. {
  374. 0x00, Fx19, 0x01, 0x00, 0x00, 0x01,
  375. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  376. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  377. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  378. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  379. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  380. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  381. 0x00, 0x00,
  382. };
  383. const unsigned char GxEPD2_213_flex::lut_21_ww_partial[] PROGMEM =
  384. {
  385. 0x00, Fx19, 0x01, 0x00, 0x00, 0x01,
  386. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  387. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  388. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  389. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  390. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  391. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  392. };
  393. const unsigned char GxEPD2_213_flex::lut_22_bw_partial[] PROGMEM =
  394. {
  395. 0x80, Fx19, 0x01, 0x00, 0x00, 0x01,
  396. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  397. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  398. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  399. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  400. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  401. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  402. };
  403. const unsigned char GxEPD2_213_flex::lut_23_wb_partial[] PROGMEM =
  404. {
  405. 0x40, Fx19, 0x01, 0x00, 0x00, 0x01,
  406. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  407. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  408. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  409. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  410. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  411. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  412. };
  413. const unsigned char GxEPD2_213_flex::lut_24_bb_partial[] PROGMEM =
  414. {
  415. 0x00, Fx19, 0x01, 0x00, 0x00, 0x01,
  416. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  417. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  418. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  419. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  420. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  421. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  422. };
  423. void GxEPD2_213_flex::_Init_Full()
  424. {
  425. _InitDisplay();
  426. _writeCommand(0x82); //vcom_DC setting
  427. _writeData (0x08);
  428. _writeCommand(0X50); //VCOM AND DATA INTERVAL SETTING
  429. _writeData(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
  430. _writeCommand(0x20);
  431. _writeDataPGM(lut_20_vcomDC, sizeof(lut_20_vcomDC));
  432. _writeCommand(0x21);
  433. _writeDataPGM(lut_21_ww, sizeof(lut_21_ww));
  434. _writeCommand(0x22);
  435. _writeDataPGM(lut_22_bw, sizeof(lut_22_bw));
  436. _writeCommand(0x23);
  437. _writeDataPGM(lut_23_wb, sizeof(lut_23_wb));
  438. _writeCommand(0x24);
  439. _writeDataPGM(lut_24_bb, sizeof(lut_24_bb));
  440. _PowerOn();
  441. _using_partial_mode = false;
  442. }
  443. void GxEPD2_213_flex::_Init_Part()
  444. {
  445. _InitDisplay();
  446. _writeCommand(0x82); //vcom_DC setting
  447. _writeData (0x08);
  448. _writeCommand(0X50);
  449. _writeData(0x17); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
  450. _writeCommand(0x20);
  451. _writeDataPGM(lut_20_vcomDC_partial, sizeof(lut_20_vcomDC_partial));
  452. _writeCommand(0x21);
  453. _writeDataPGM(lut_21_ww_partial, sizeof(lut_21_ww_partial));
  454. _writeCommand(0x22);
  455. _writeDataPGM(lut_22_bw_partial, sizeof(lut_22_bw_partial));
  456. _writeCommand(0x23);
  457. _writeDataPGM(lut_23_wb_partial, sizeof(lut_23_wb_partial));
  458. _writeCommand(0x24);
  459. _writeDataPGM(lut_24_bb_partial, sizeof(lut_24_bb_partial));
  460. _PowerOn();
  461. _using_partial_mode = true;
  462. }
  463. void GxEPD2_213_flex::_Update_Full()
  464. {
  465. _writeCommand(0x12); //display refresh
  466. _waitWhileBusy("_Update_Full", full_refresh_time);
  467. }
  468. void GxEPD2_213_flex::_Update_Part()
  469. {
  470. _writeCommand(0x12); //display refresh
  471. _waitWhileBusy("_Update_Part", partial_refresh_time);
  472. }