GxEPD2_750c_GDEW075Z08.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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: http://www.e-paper-display.com/download_detail/downloadsId=808.html
  5. // Panel: GDEW075Z08 : http://www.e-paper-display.com/products_detail/productId=457.html
  6. // Controller: GD7965 : http://www.e-paper-display.com/download_detail/downloadsId=821.html
  7. //
  8. // Author: Jean-Marc Zingg
  9. //
  10. // Version: see library.properties
  11. //
  12. // Library: https://github.com/ZinggJM/GxEPD2
  13. #include "GxEPD2_750c_GDEW075Z08.h"
  14. GxEPD2_750c_GDEW075Z08::GxEPD2_750c_GDEW075Z08(int16_t cs, int16_t dc, int16_t rst, int16_t busy) :
  15. GxEPD2_EPD(cs, dc, rst, busy, LOW, 20000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
  16. {
  17. }
  18. void GxEPD2_750c_GDEW075Z08::clearScreen(uint8_t value)
  19. {
  20. clearScreen(value, 0xFF);
  21. }
  22. void GxEPD2_750c_GDEW075Z08::clearScreen(uint8_t black_value, uint8_t color_value)
  23. {
  24. writeScreenBuffer(black_value, color_value);
  25. refresh(false);
  26. }
  27. void GxEPD2_750c_GDEW075Z08::writeScreenBuffer(uint8_t value)
  28. {
  29. writeScreenBuffer(value, 0xFF);
  30. }
  31. void GxEPD2_750c_GDEW075Z08::writeScreenBuffer(uint8_t black_value, uint8_t color_value)
  32. {
  33. if (!_init_display_done) _InitDisplay();
  34. _writeScreenBuffer(0x10, black_value); // set black/white
  35. _writeScreenBuffer(0x13, color_value); // set red/white
  36. _initial_write = false; // initial full screen buffer clean done
  37. }
  38. void GxEPD2_750c_GDEW075Z08::_writeScreenBuffer(uint8_t command, uint8_t value)
  39. {
  40. //_writeCommand(0x91); // partial in
  41. _setPartialRamArea(0, 0, WIDTH, HEIGHT);
  42. _writeCommand(command);
  43. _startTransfer();
  44. for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 8; i++)
  45. {
  46. _transfer(value);
  47. }
  48. _endTransfer();
  49. //_writeCommand(0x92); // partial out
  50. }
  51. void GxEPD2_750c_GDEW075Z08::writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  52. {
  53. _writeScreenBuffer(0x13, 0xFF); // set red/white
  54. _writeImage(0x10, bitmap, x, y, w, h, invert, mirror_y, pgm);
  55. }
  56. void GxEPD2_750c_GDEW075Z08::_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)
  57. {
  58. if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
  59. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  60. uint16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
  61. x -= x % 8; // byte boundary
  62. w = wb * 8; // byte boundary
  63. int16_t x1 = x < 0 ? 0 : x; // limit
  64. int16_t y1 = y < 0 ? 0 : y; // limit
  65. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  66. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  67. int16_t dx = x1 - x;
  68. int16_t dy = y1 - y;
  69. w1 -= dx;
  70. h1 -= dy;
  71. if ((w1 <= 0) || (h1 <= 0)) return;
  72. if (!_init_display_done) _InitDisplay();
  73. _writeCommand(0x91); // partial in
  74. _setPartialRamArea(x1, y1, w1, h1);
  75. _writeCommand(command);
  76. _startTransfer();
  77. for (int16_t i = 0; i < h1; i++)
  78. {
  79. for (int16_t j = 0; j < w1 / 8; j++)
  80. {
  81. uint8_t data = 0xFF;
  82. // use wb, h of bitmap for index!
  83. uint16_t idx = mirror_y ? j + dx / 8 + uint16_t((h - 1 - (i + dy))) * wb : j + dx / 8 + uint16_t(i + dy) * wb;
  84. if (pgm)
  85. {
  86. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  87. data = pgm_read_byte(&bitmap[idx]);
  88. #else
  89. data = bitmap[idx];
  90. #endif
  91. }
  92. else
  93. {
  94. data = bitmap[idx];
  95. }
  96. if (invert) data = ~data;
  97. _transfer(data);
  98. }
  99. }
  100. _endTransfer();
  101. _writeCommand(0x92); // partial out
  102. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  103. }
  104. void GxEPD2_750c_GDEW075Z08::writeImageToPrevious(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  105. {
  106. _writeImage(0x13, bitmap, x, y, w, h, invert, mirror_y, pgm);
  107. }
  108. void GxEPD2_750c_GDEW075Z08::writeImageToCurrent(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  109. {
  110. _writeImage(0x10, bitmap, x, y, w, h, invert, mirror_y, pgm);
  111. }
  112. void GxEPD2_750c_GDEW075Z08::writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  113. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  114. {
  115. _writeImagePart(0x10, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  116. }
  117. void GxEPD2_750c_GDEW075Z08::_writeImagePart(uint8_t command, const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  118. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  119. {
  120. if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
  121. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  122. if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
  123. if ((x_part < 0) || (x_part >= w_bitmap)) return;
  124. if ((y_part < 0) || (y_part >= h_bitmap)) return;
  125. uint16_t wb_bitmap = (w_bitmap + 7) / 8; // width bytes, bitmaps are padded
  126. x_part -= x_part % 8; // byte boundary
  127. w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
  128. h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
  129. x -= x % 8; // byte boundary
  130. w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
  131. int16_t x1 = x < 0 ? 0 : x; // limit
  132. int16_t y1 = y < 0 ? 0 : y; // limit
  133. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  134. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  135. int16_t dx = x1 - x;
  136. int16_t dy = y1 - y;
  137. w1 -= dx;
  138. h1 -= dy;
  139. if ((w1 <= 0) || (h1 <= 0)) return;
  140. if (!_init_display_done) _InitDisplay();
  141. _writeCommand(0x91); // partial in
  142. _setPartialRamArea(x1, y1, w1, h1);
  143. _writeCommand(command);
  144. _startTransfer();
  145. for (int16_t i = 0; i < h1; i++)
  146. {
  147. for (int16_t j = 0; j < w1 / 8; j++)
  148. {
  149. uint8_t data;
  150. // use wb_bitmap, h_bitmap of bitmap for index!
  151. uint32_t idx = mirror_y ? x_part / 8 + j + dx / 8 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + uint32_t(y_part + i + dy) * wb_bitmap;
  152. if (pgm)
  153. {
  154. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  155. data = pgm_read_byte(&bitmap[idx]);
  156. #else
  157. data = bitmap[idx];
  158. #endif
  159. }
  160. else
  161. {
  162. data = bitmap[idx];
  163. }
  164. if (invert) data = ~data;
  165. _transfer(data);
  166. }
  167. }
  168. _endTransfer();
  169. _writeCommand(0x92); // partial out
  170. delay(1); // yield() to avoid WDT on ESP8266 and ESP32
  171. }
  172. void GxEPD2_750c_GDEW075Z08::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)
  173. {
  174. if (black) _writeImage(0x10, black, x, y, w, h, invert, mirror_y, pgm);
  175. if (color) _writeImage(0x13, color, x, y, w, h, invert, mirror_y, pgm);
  176. }
  177. void GxEPD2_750c_GDEW075Z08::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,
  178. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  179. {
  180. if (black) _writeImagePart(0x10, black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  181. if (color) _writeImagePart(0x13, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  182. }
  183. void GxEPD2_750c_GDEW075Z08::writeImagePartToPrevious(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  184. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  185. {
  186. _writeImagePart(0x13, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  187. }
  188. void GxEPD2_750c_GDEW075Z08::writeImagePartToCurrent(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  189. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  190. {
  191. _writeImagePart(0x10, bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  192. }
  193. void GxEPD2_750c_GDEW075Z08::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)
  194. {
  195. if (data1)
  196. {
  197. writeImage(data1, x, y, w, h, invert, mirror_y, pgm);
  198. }
  199. }
  200. void GxEPD2_750c_GDEW075Z08::drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  201. {
  202. writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
  203. refresh(x, y, w, h);
  204. }
  205. void GxEPD2_750c_GDEW075Z08::drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  206. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  207. {
  208. writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  209. refresh(x, y, w, h);
  210. }
  211. void GxEPD2_750c_GDEW075Z08::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)
  212. {
  213. writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
  214. refresh(x, y, w, h);
  215. }
  216. void GxEPD2_750c_GDEW075Z08::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,
  217. int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
  218. {
  219. writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  220. refresh(x, y, w, h);
  221. }
  222. void GxEPD2_750c_GDEW075Z08::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)
  223. {
  224. writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
  225. refresh(x, y, w, h);
  226. }
  227. void GxEPD2_750c_GDEW075Z08::refresh(bool partial_update_mode)
  228. {
  229. if (partial_update_mode) refresh(0, 0, WIDTH, HEIGHT);
  230. else _Update_Full();
  231. }
  232. void GxEPD2_750c_GDEW075Z08::refresh(int16_t x, int16_t y, int16_t w, int16_t h)
  233. {
  234. // intersection with screen
  235. int16_t w1 = x < 0 ? w + x : w; // reduce
  236. int16_t h1 = y < 0 ? h + y : h; // reduce
  237. int16_t x1 = x < 0 ? 0 : x; // limit
  238. int16_t y1 = y < 0 ? 0 : y; // limit
  239. w1 = x1 + w1 < int16_t(WIDTH) ? w1 : int16_t(WIDTH) - x1; // limit
  240. h1 = y1 + h1 < int16_t(HEIGHT) ? h1 : int16_t(HEIGHT) - y1; // limit
  241. if ((w1 <= 0) || (h1 <= 0)) return;
  242. // make x1, w1 multiple of 8
  243. w1 += x1 % 8;
  244. if (w1 % 8 > 0) w1 += 8 - w1 % 8;
  245. x1 -= x1 % 8;
  246. if (usePartialUpdate) _writeCommand(0x91); // partial in
  247. _setPartialRamArea(x1, y1, w1, h1);
  248. _Update_Part();
  249. if (usePartialUpdate) _writeCommand(0x92); // partial out
  250. }
  251. void GxEPD2_750c_GDEW075Z08::powerOff()
  252. {
  253. _PowerOff();
  254. }
  255. void GxEPD2_750c_GDEW075Z08::hibernate()
  256. {
  257. _PowerOff();
  258. if (_rst >= 0)
  259. {
  260. _writeCommand(0x07); // deep sleep
  261. _writeData(0xA5); // check code
  262. _hibernating = true;
  263. _init_display_done = false;
  264. }
  265. }
  266. void GxEPD2_750c_GDEW075Z08::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
  267. {
  268. uint16_t xe = (x + w - 1) | 0x0007; // byte boundary inclusive (last byte)
  269. uint16_t ye = y + h - 1;
  270. x &= 0xFFF8; // byte boundary
  271. xe |= 0x0007; // 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(0x00);
  282. }
  283. void GxEPD2_750c_GDEW075Z08::_PowerOn()
  284. {
  285. if (!_power_is_on)
  286. {
  287. _writeCommand(0x04);
  288. _waitWhileBusy("_PowerOn", power_on_time);
  289. }
  290. _power_is_on = true;
  291. }
  292. void GxEPD2_750c_GDEW075Z08::_PowerOff()
  293. {
  294. if (_power_is_on)
  295. {
  296. _writeCommand(0x02); // power off
  297. _waitWhileBusy("_PowerOff", power_off_time);
  298. _power_is_on = false;
  299. }
  300. }
  301. void GxEPD2_750c_GDEW075Z08::_InitDisplay()
  302. {
  303. if (_hibernating) _reset();
  304. _writeCommand(0x01); // POWER SETTING
  305. _writeData (0x07);
  306. _writeData (0x07); // VGH=20V,VGL=-20V
  307. _writeData (0x3f); // VDH=15V
  308. _writeData (0x3f); // VDL=-15V
  309. _writeCommand(0x00); // PANEL SETTING
  310. _writeData(0x0f); // KW: 3f, KWR: 2f, BWROTP: 0f, BWOTP: 1f
  311. _writeCommand(0x61); // resolution setting
  312. _writeData (WIDTH / 256); // source 800
  313. _writeData (WIDTH % 256);
  314. _writeData (HEIGHT / 256); // gate 480
  315. _writeData (HEIGHT % 256);
  316. _writeCommand(0x15);
  317. _writeData(0x00);
  318. _writeCommand(0x50); // VCOM AND DATA INTERVAL SETTING
  319. _writeData(0x13); // 0xFF white for black, 0xFF white for red
  320. _writeData(0x07);
  321. _writeCommand(0x60); // TCON SETTING
  322. _writeData(0x22);
  323. _init_display_done = true;
  324. }
  325. void GxEPD2_750c_GDEW075Z08::_Update_Full()
  326. {
  327. _writeCommand(0x00); // PANEL SETTING
  328. _writeData(0x0f); // KW: 3f, KWR: 2F, BWROTP: 0f, BWOTP: 1f
  329. _writeCommand(0x50); // VCOM AND DATA INTERVAL SETTING
  330. _writeData(0x13); // 0xFF white for black, 0xFF white for red
  331. _writeData(0x07);
  332. _PowerOn();
  333. _writeCommand(0x12); //display refresh
  334. _waitWhileBusy("_Update_Full", full_refresh_time);
  335. _PowerOff();
  336. }
  337. void GxEPD2_750c_GDEW075Z08::_Update_Part()
  338. {
  339. _writeCommand(0x00); // PANEL SETTING
  340. _writeData(0x0f); // KW: 3f, KWR: 2F, BWROTP: 0f, BWOTP: 1f
  341. _writeCommand(0x50); // VCOM AND DATA INTERVAL SETTING
  342. _writeData(0x13); // 0xFF white for black, 0xFF white for red
  343. _writeData(0x07);
  344. _PowerOn();
  345. _writeCommand(0x12); //display refresh
  346. _waitWhileBusy("_Update_Part", partial_refresh_time);
  347. _PowerOff();
  348. }
  349. #define T_BW 40
  350. #define T_WB 40
  351. const unsigned char GxEPD2_750c_GDEW075Z08::lut_20_LUTC_partial[] PROGMEM =
  352. {
  353. //0x00, T_BW, T_WB, 0, 0, 1,
  354. // from GxEPD2_750c_GDEY075Z08: GDEY075Z08 OTP
  355. 0x0, 0x3, 0x5, 0x0, 0x0, 0x2,
  356. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  357. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  358. 0x0, 0x5, 0x5, 0x0, 0x0, 0x3,
  359. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  360. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  361. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  362. };
  363. const unsigned char GxEPD2_750c_GDEW075Z08::lut_21_LUTWW_partial[] PROGMEM =
  364. { // 10 w
  365. //0x00, T_BW, T_WB, 0, 0, 1,
  366. // from GxEPD2_750c_GDEY075Z08: GDEY075Z08 OTP
  367. 0x0, 0x3, 0x5, 0x0, 0x0, 0x2,
  368. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  369. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  370. 0x0, 0x5, 0x5, 0x0, 0x0, 0x3,
  371. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  372. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  373. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  374. };
  375. const unsigned char GxEPD2_750c_GDEW075Z08::lut_22_LUTKW_partial[] PROGMEM =
  376. { // 10 w
  377. //0x80, T_BW, T_WB, 0, 0, 1,
  378. // from GxEPD2_750c_GDEY075Z08: GDEY075Z08 OTP
  379. 0x20, 0x3, 0x5, 0x0, 0x0, 0x2,
  380. 0x20, 0x5, 0x5, 0x0, 0x0, 0x1,
  381. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  382. 0x20, 0x5, 0x5, 0x0, 0x0, 0x3,
  383. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  384. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  385. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  386. };
  387. const unsigned char GxEPD2_750c_GDEW075Z08::lut_23_LUTWK_partial[] PROGMEM =
  388. { // 01 b
  389. //0x40, T_BW, T_WB, 0, 0, 1,
  390. // from GxEPD2_750c_GDEY075Z08: GDEY075Z08 OTP
  391. 0x40, 0x3, 0x5, 0x0, 0x0, 0x2,
  392. 0x40, 0x5, 0x5, 0x0, 0x0, 0x1,
  393. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  394. 0x40, 0x5, 0x5, 0x0, 0x0, 0x3,
  395. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  396. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  397. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  398. };
  399. const unsigned char GxEPD2_750c_GDEW075Z08::lut_24_LUTKK_partial[] PROGMEM =
  400. { // 01 b
  401. //0x00, T_BW, T_WB, 0, 0, 1,
  402. // from GxEPD2_750c_GDEY075Z08: GDEY075Z08 OTP
  403. 0x0, 0x3, 0x5, 0x0, 0x0, 0x2,
  404. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  405. 0x0, 0x5, 0x5, 0x0, 0x0, 0x1,
  406. 0x0, 0x5, 0x5, 0x0, 0x0, 0x3,
  407. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  408. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  409. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  410. };
  411. const unsigned char GxEPD2_750c_GDEW075Z08::lut_25_LUTBD_partial[] PROGMEM =
  412. {
  413. //0x00, T_BW, T_WB, 0, 0, 1,
  414. };
  415. void GxEPD2_750c_GDEW075Z08::refresh_bw(int16_t x, int16_t y, int16_t w, int16_t h)
  416. {
  417. x -= x % 8; // byte boundary
  418. w -= w % 8; // byte boundary
  419. int16_t x1 = x < 0 ? 0 : x; // limit
  420. int16_t y1 = y < 0 ? 0 : y; // limit
  421. int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
  422. int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
  423. w1 -= x1 - x;
  424. h1 -= y1 - y;
  425. _writeCommand(0x00); // panel setting
  426. _writeData(0x3f); // partial update LUT from registers
  427. _writeCommand(0x82); // vcom_DC setting
  428. _writeData (0x2F); // -2.45V same value as in OTP
  429. _writeCommand(0x50); // VCOM AND DATA INTERVAL SETTING
  430. _writeData(0x10);
  431. _writeData(0x07);
  432. _writeCommand(0x20);
  433. _writeDataPGM(lut_20_LUTC_partial, sizeof(lut_20_LUTC_partial), 42 - sizeof(lut_20_LUTC_partial));
  434. _writeCommand(0x21);
  435. _writeDataPGM(lut_21_LUTWW_partial, sizeof(lut_21_LUTWW_partial), 42 - sizeof(lut_21_LUTWW_partial));
  436. _writeCommand(0x22);
  437. _writeDataPGM(lut_22_LUTKW_partial, sizeof(lut_22_LUTKW_partial), 42 - sizeof(lut_22_LUTKW_partial));
  438. _writeCommand(0x23);
  439. _writeDataPGM(lut_23_LUTWK_partial, sizeof(lut_23_LUTWK_partial), 42 - sizeof(lut_23_LUTWK_partial));
  440. _writeCommand(0x24);
  441. _writeDataPGM(lut_24_LUTKK_partial, sizeof(lut_24_LUTKK_partial), 42 - sizeof(lut_24_LUTKK_partial));
  442. _writeCommand(0x25);
  443. _writeDataPGM(lut_25_LUTBD_partial, sizeof(lut_25_LUTBD_partial), 42 - sizeof(lut_25_LUTBD_partial));
  444. _PowerOn();
  445. _writeCommand(0x91); // partial in
  446. _setPartialRamArea(x1, y1, w1, h1);
  447. _writeCommand(0x12); //display refresh
  448. _waitWhileBusy("refresh_bw", full_refresh_time);
  449. _writeCommand(0x92); // partial out
  450. }