GxEPD2_154_M09.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. // Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
  2. // Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
  3. //
  4. // based on Demo Example from Good Display, available here: http://www.e-paper-display.com/download_detail/downloadsId=806.html
  5. // Panel: GDEW0154M09 : http://www.e-paper-display.com/products_detail/productId=513.html
  6. // Controller : JD79653A : http://www.e-paper-display.com/download_detail/downloadsId%3d943.html
  7. //
  8. // Author: Jean-Marc Zingg
  9. //
  10. // Version: see library.properties
  11. //
  12. // Library: https://github.com/ZinggJM/GxEPD2
  13. #include "GxEPD2_154_M09.h"
  14. GxEPD2_154_M09::GxEPD2_154_M09(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_154_M09::clearScreen(uint8_t value)
  19. {
  20. writeScreenBuffer(value);
  21. refresh(true);
  22. writeScreenBufferAgain(value);
  23. }
  24. void GxEPD2_154_M09::writeScreenBuffer(uint8_t value)
  25. {
  26. _initial_write = false; // initial full screen buffer clean done
  27. if (!_using_partial_mode) _Init_Part();
  28. _writeScreenBuffer(0x13, value); // set current
  29. if (_initial_refresh) _writeScreenBuffer(0x26, value); // set previous
  30. }
  31. void GxEPD2_154_M09::writeScreenBufferAgain(uint8_t value)
  32. {
  33. if (!_using_partial_mode) _Init_Part();
  34. _writeScreenBuffer(0x10, value); // set previous
  35. }
  36. void GxEPD2_154_M09::_writeScreenBuffer(uint8_t command, uint8_t value)
  37. {
  38. _writeCommand(command);
  39. for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 8; i++)
  40. {
  41. _writeData(value);
  42. }
  43. }
  44. void GxEPD2_154_M09::writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  45. {
  46. _writeImage(0x13, bitmap, x, y, w, h, invert, mirror_y, pgm);
  47. }
  48. void GxEPD2_154_M09::writeImageAgain(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  49. {
  50. _writeImage(0x10, bitmap, x, y, w, h, invert, mirror_y, pgm);
  51. }
  52. void GxEPD2_154_M09::_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)
  53. {
  54. if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
  55. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  56. int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
  57. x -= x % 8; // byte boundary
  58. w = wb * 8; // byte boundary
  59. int16_t x1 = x < 0 ? 0 : x; // limit
  60. int16_t y1 = y < 0 ? 0 : y; // limit
  61. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  62. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  63. int16_t dx = x1 - x;
  64. int16_t dy = y1 - y;
  65. w1 -= dx;
  66. h1 -= dy;
  67. if ((w1 <= 0) || (h1 <= 0)) return;
  68. if (!_using_partial_mode) _Init_Part();
  69. _writeCommand(0x91); // partial in
  70. _setPartialRamArea(x1, y1, w1, h1);
  71. _writeCommand(command);
  72. for (int16_t i = 0; i < h1; i++)
  73. {
  74. for (int16_t j = 0; j < w1 / 8; j++)
  75. {
  76. uint8_t data;
  77. // use wb, h of bitmap for index!
  78. int16_t idx = mirror_y ? j + dx / 8 + ((h - 1 - (i + dy))) * wb : j + dx / 8 + (i + dy) * wb;
  79. if (pgm)
  80. {
  81. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  82. data = pgm_read_byte(&bitmap[idx]);
  83. #else
  84. data = bitmap[idx];
  85. #endif
  86. }
  87. else
  88. {
  89. data = bitmap[idx];
  90. }
  91. if (invert) data = ~data;
  92. _writeData(data);
  93. }
  94. }
  95. _writeCommand(0x92); // partial out
  96. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  97. }
  98. void GxEPD2_154_M09::writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  99. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  100. {
  101. _writeImagePart(0x13, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  102. }
  103. void GxEPD2_154_M09::writeImagePartAgain(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(0x10, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  107. }
  108. void GxEPD2_154_M09::_writeImagePart(uint8_t command, 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. if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
  112. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  113. if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
  114. if ((x_part < 0) || (x_part >= w_bitmap)) return;
  115. if ((y_part < 0) || (y_part >= h_bitmap)) return;
  116. int16_t wb_bitmap = (w_bitmap + 7) / 8; // width bytes, bitmaps are padded
  117. x_part -= x_part % 8; // byte boundary
  118. w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
  119. h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
  120. x -= x % 8; // byte boundary
  121. w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
  122. int16_t x1 = x < 0 ? 0 : x; // limit
  123. int16_t y1 = y < 0 ? 0 : y; // limit
  124. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  125. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  126. int16_t dx = x1 - x;
  127. int16_t dy = y1 - y;
  128. w1 -= dx;
  129. h1 -= dy;
  130. if ((w1 <= 0) || (h1 <= 0)) return;
  131. if (!_using_partial_mode) _Init_Part();
  132. _writeCommand(0x91); // partial in
  133. _setPartialRamArea(x1, y1, w1, h1);
  134. _writeCommand(command);
  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. _writeData(data);
  156. }
  157. }
  158. _writeCommand(0x92); // partial out
  159. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  160. }
  161. void GxEPD2_154_M09::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)
  162. {
  163. if (black)
  164. {
  165. writeImage(black, x, y, w, h, invert, mirror_y, pgm);
  166. }
  167. }
  168. void GxEPD2_154_M09::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,
  169. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  170. {
  171. if (black)
  172. {
  173. writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  174. }
  175. }
  176. void GxEPD2_154_M09::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)
  177. {
  178. if (data1)
  179. {
  180. writeImage(data1, x, y, w, h, invert, mirror_y, pgm);
  181. }
  182. }
  183. void GxEPD2_154_M09::drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  184. {
  185. writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
  186. refresh(x, y, w, h);
  187. writeImageAgain(bitmap, x, y, w, h, invert, mirror_y, pgm);
  188. }
  189. void GxEPD2_154_M09::drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  190. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  191. {
  192. writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  193. refresh(x, y, w, h);
  194. writeImagePartAgain(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  195. }
  196. void GxEPD2_154_M09::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)
  197. {
  198. if (black)
  199. {
  200. drawImage(black, x, y, w, h, invert, mirror_y, pgm);
  201. }
  202. }
  203. void GxEPD2_154_M09::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. if (black)
  207. {
  208. drawImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  209. }
  210. }
  211. void GxEPD2_154_M09::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)
  212. {
  213. if (data1)
  214. {
  215. drawImage(data1, x, y, w, h, invert, mirror_y, pgm);
  216. }
  217. }
  218. void GxEPD2_154_M09::refresh(bool partial_update_mode)
  219. {
  220. if (partial_update_mode) refresh(0, 0, WIDTH, HEIGHT);
  221. else
  222. {
  223. if (_using_partial_mode) _Init_Full();
  224. _Update_Full();
  225. _initial_refresh = false; // initial full update done
  226. }
  227. }
  228. void GxEPD2_154_M09::refresh(int16_t x, int16_t y, int16_t w, int16_t h)
  229. {
  230. if (_initial_refresh) return refresh(false); // initial update needs be full update
  231. // intersection with screen
  232. int16_t w1 = x < 0 ? w + x : w; // reduce
  233. int16_t h1 = y < 0 ? h + y : h; // reduce
  234. int16_t x1 = x < 0 ? 0 : x; // limit
  235. int16_t y1 = y < 0 ? 0 : y; // limit
  236. w1 = x1 + w1 < int16_t(WIDTH) ? w1 : int16_t(WIDTH) - x1; // limit
  237. h1 = y1 + h1 < int16_t(HEIGHT) ? h1 : int16_t(HEIGHT) - y1; // limit
  238. if ((w1 <= 0) || (h1 <= 0)) return;
  239. // make x1, w1 multiple of 8
  240. w1 += x1 % 8;
  241. if (w1 % 8 > 0) w1 += 8 - w1 % 8;
  242. x1 -= x1 % 8;
  243. if (!_using_partial_mode) _Init_Part();
  244. _writeCommand(0x91); // partial in
  245. _setPartialRamArea(x1, y1, w1, h1);
  246. _Update_Part();
  247. _writeCommand(0x92); // partial out
  248. }
  249. void GxEPD2_154_M09::powerOff(void)
  250. {
  251. _PowerOff();
  252. }
  253. void GxEPD2_154_M09::hibernate()
  254. {
  255. _PowerOff();
  256. if (_rst >= 0)
  257. {
  258. _writeCommand(0x07); // deep sleep
  259. _writeData(0xA5); // check code
  260. _hibernating = true;
  261. }
  262. }
  263. void GxEPD2_154_M09::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
  264. {
  265. uint16_t xe = (x + w - 1) | 0x0007; // byte boundary inclusive (last byte)
  266. uint16_t ye = y + h - 1;
  267. x &= 0xFFF8; // byte boundary
  268. _writeCommand(0x90); // partial window
  269. //_writeData(x / 256);
  270. _writeData(x % 256);
  271. //_writeData(xe / 256);
  272. _writeData(xe % 256);
  273. _writeData(y / 256);
  274. _writeData(y % 256);
  275. _writeData(ye / 256);
  276. _writeData(ye % 256);
  277. _writeData(0x01); // don't see any difference
  278. //_writeData(0x00); // don't see any difference
  279. }
  280. void GxEPD2_154_M09::_PowerOn()
  281. {
  282. if (!_power_is_on)
  283. {
  284. _writeCommand(0x04);
  285. _waitWhileBusy("_PowerOn", power_on_time);
  286. }
  287. _power_is_on = true;
  288. }
  289. void GxEPD2_154_M09::_PowerOff()
  290. {
  291. if (_power_is_on)
  292. {
  293. if (_using_partial_mode) _Update_Part(); // would hang on _powerOn() without
  294. _writeCommand(0x02); // power off
  295. _waitWhileBusy("_PowerOff", power_off_time);
  296. _power_is_on = false;
  297. _using_partial_mode = false;
  298. }
  299. }
  300. void GxEPD2_154_M09::_InitDisplay()
  301. {
  302. if (_hibernating) _reset();
  303. _writeCommand(0x00); // panel setting
  304. _writeData (0xff);
  305. _writeData (0x0e);
  306. _writeCommand(0x01); // power setting
  307. _writeData(0x03);
  308. _writeData(0x06); // 16V
  309. _writeData(0x2A);//
  310. _writeData(0x2A);//
  311. _writeCommand(0x4D); // FITIinternal code
  312. _writeData (0x55);
  313. _writeCommand(0xaa);
  314. _writeData (0x0f);
  315. _writeCommand(0xE9);
  316. _writeData (0x02);
  317. _writeCommand(0xb6);
  318. _writeData (0x11);
  319. _writeCommand(0xF3);
  320. _writeData (0x0a);
  321. _writeCommand(0x06); // boost soft start
  322. _writeData (0xc7);
  323. _writeData (0x0c);
  324. _writeData (0x0c);
  325. _writeCommand(0x61); // resolution setting
  326. _writeData (0xc8); // 200
  327. _writeData (0x00);
  328. _writeData (0xc8); // 200
  329. _writeCommand(0x60); // Tcon setting
  330. _writeData (0x00);
  331. _writeCommand(0x82); // VCOM DC setting
  332. _writeData (0x12);
  333. _writeCommand(0x30); // PLL control
  334. _writeData (0x3C); // default 50Hz
  335. _writeCommand(0X50); // VCOM and data interval
  336. _writeData(0x97);//
  337. _writeCommand(0XE3); // power saving register
  338. _writeData(0x00); // default
  339. }
  340. const unsigned char GxEPD2_154_M09::lut_20_vcomDC[] PROGMEM =
  341. {
  342. 0x01, 0x05, 0x05, 0x05, 0x05, 0x01, 0x01,
  343. 0x01, 0x05, 0x05, 0x05, 0x05, 0x01, 0x01,
  344. 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
  345. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  346. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  347. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  348. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  349. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  350. };
  351. const unsigned char GxEPD2_154_M09::lut_21_ww[] PROGMEM =
  352. {
  353. 0x01, 0x45, 0x45, 0x43, 0x44, 0x01, 0x01,
  354. 0x01, 0x87, 0x83, 0x87, 0x06, 0x01, 0x01,
  355. 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
  356. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  357. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  358. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  359. };
  360. const unsigned char GxEPD2_154_M09::lut_22_bw[] PROGMEM =
  361. {
  362. 0x01, 0x05, 0x05, 0x45, 0x42, 0x01, 0x01,
  363. 0x01, 0x87, 0x85, 0x85, 0x85, 0x01, 0x01,
  364. 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00,
  365. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  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_154_M09::lut_23_wb[] PROGMEM =
  372. {
  373. 0x01, 0x08, 0x08, 0x82, 0x42, 0x01, 0x01,
  374. 0x01, 0x45, 0x45, 0x45, 0x45, 0x01, 0x01,
  375. 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 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. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  380. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  381. };
  382. const unsigned char GxEPD2_154_M09::lut_24_bb[] PROGMEM =
  383. {
  384. 0x01, 0x85, 0x85, 0x85, 0x83, 0x01, 0x01,
  385. 0x01, 0x45, 0x45, 0x04, 0x48, 0x01, 0x01,
  386. 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
  387. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  388. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  389. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  390. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  391. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  392. };
  393. const unsigned char GxEPD2_154_M09::lut_20_vcomDC_partial[] PROGMEM =
  394. {
  395. 0x01, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01,
  396. 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 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. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  401. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  402. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  403. };
  404. const unsigned char GxEPD2_154_M09::lut_21_ww_partial[] PROGMEM =
  405. {
  406. 0x01, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01,
  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. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  412. };
  413. const unsigned char GxEPD2_154_M09::lut_22_bw_partial[] PROGMEM =
  414. {
  415. 0x01, 0x84, 0x84, 0x83, 0x01, 0x01, 0x01,
  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. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  423. };
  424. const unsigned char GxEPD2_154_M09::lut_23_wb_partial[] PROGMEM =
  425. {
  426. 0x01, 0x44, 0x44, 0x43, 0x01, 0x01, 0x01,
  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. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  432. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  433. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  434. };
  435. const unsigned char GxEPD2_154_M09::lut_24_bb_partial[] PROGMEM =
  436. {
  437. 0x01, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01,
  438. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  439. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  440. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  441. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  442. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  443. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  444. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  445. };
  446. void GxEPD2_154_M09::_Init_Full()
  447. {
  448. _InitDisplay();
  449. _writeCommand(0x20);
  450. _writeDataPGM(lut_20_vcomDC, sizeof(lut_20_vcomDC));
  451. _writeCommand(0x21);
  452. _writeDataPGM(lut_21_ww, sizeof(lut_21_ww));
  453. _writeCommand(0x22);
  454. _writeDataPGM(lut_22_bw, sizeof(lut_22_bw));
  455. _writeCommand(0x23);
  456. _writeDataPGM(lut_23_wb, sizeof(lut_23_wb));
  457. _writeCommand(0x24);
  458. _writeDataPGM(lut_24_bb, sizeof(lut_24_bb));
  459. _PowerOn();
  460. _using_partial_mode = false;
  461. }
  462. void GxEPD2_154_M09::_Init_Part()
  463. {
  464. _InitDisplay();
  465. _writeCommand(0x20);
  466. _writeDataPGM(lut_20_vcomDC_partial, sizeof(lut_20_vcomDC_partial));
  467. _writeCommand(0x21);
  468. _writeDataPGM(lut_21_ww_partial, sizeof(lut_21_ww_partial));
  469. _writeCommand(0x22);
  470. _writeDataPGM(lut_22_bw_partial, sizeof(lut_22_bw_partial));
  471. _writeCommand(0x23);
  472. _writeDataPGM(lut_23_wb_partial, sizeof(lut_23_wb_partial));
  473. _writeCommand(0x24);
  474. _writeDataPGM(lut_24_bb_partial, sizeof(lut_24_bb_partial));
  475. _PowerOn();
  476. _using_partial_mode = true;
  477. }
  478. void GxEPD2_154_M09::_Update_Full()
  479. {
  480. _writeCommand(0x12); //display refresh
  481. _waitWhileBusy("_Update_Full", full_refresh_time);
  482. }
  483. void GxEPD2_154_M09::_Update_Part()
  484. {
  485. _writeCommand(0x12); //display refresh
  486. _waitWhileBusy("_Update_Part", partial_refresh_time);
  487. }