GxEPD2_420.cpp 17 KB

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