GxEPD2_420_SE0420NQ04.cpp 17 KB

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