GxEPD2_WS_ESP32_Driver.ino 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. // Display Library example 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. // Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
  5. //
  6. // Author: Jean-Marc Zingg
  7. //
  8. // Version: see library.properties
  9. //
  10. // Library: https://github.com/ZinggJM/GxEPD2
  11. // GxEPD2_WS_ESP32_Driver : GxEPD2_Example variant for Universal e-Paper Raw Panel Driver Board, ESP32 WiFi / Bluetooth Wireless
  12. // https://www.waveshare.com/product/e-paper-esp32-driver-board.htm
  13. // Supporting Arduino Forum Topics:
  14. // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
  15. // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
  16. // mapping of Waveshare ESP32 Driver Board
  17. // BUSY -> 25, RST -> 26, DC -> 27, CS-> 15, CLK -> 13, DIN -> 14
  18. // NOTE: this board uses "unusual" SPI pins and requires re-mapping of HW SPI to these pins in SPIClass
  19. // this example shows how this can be done easily
  20. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  21. // enable or disable GxEPD2_GFX base class
  22. #define ENABLE_GxEPD2_GFX 0
  23. #include <GxEPD2_BW.h>
  24. #include <GxEPD2_3C.h>
  25. #include <Fonts/FreeMonoBold9pt7b.h>
  26. #if defined(ESP32)
  27. // ***** for mapping of Waveshare ESP32 Driver Board *****
  28. // use Board "ESP32 Dev Module" to build with Arduino IDE
  29. // select one, can use full buffer size (full HEIGHT)
  30. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEP015OC1 no longer available
  31. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEH0154D67
  32. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDE0213B1, phased out
  33. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEH0213B72
  34. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEW0213I5F
  35. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  36. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEW029T5
  37. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  38. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  39. //GxEPD2_BW<GxEPD2_750, GxEPD2_750::HEIGHT> display(GxEPD2_750(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  40. // 3-color e-papers
  41. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  42. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  43. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  44. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  45. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  46. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT> display(GxEPD2_750c(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  47. #endif
  48. // comment out unused bitmaps to reduce code space used
  49. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  50. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  51. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  52. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  53. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  54. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  55. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  56. // 3-color
  57. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  58. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  59. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  60. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  61. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  62. void setup()
  63. {
  64. Serial.begin(115200);
  65. Serial.println();
  66. Serial.println("setup");
  67. display.init(115200); // uses standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
  68. // *** special handling for Waveshare ESP32 Driver board *** //
  69. // ********************************************************* //
  70. SPI.end(); // release standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
  71. //SPI: void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
  72. SPI.begin(13, 12, 14, 15); // map and init SPI pins SCK(13), MISO(12), MOSI(14), SS(15)
  73. // *** end of special handling for Waveshare ESP32 Driver board *** //
  74. // **************************************************************** //
  75. // first update should be full refresh
  76. helloWorld();
  77. delay(1000);
  78. // partial refresh mode can be used to full screen,
  79. // effective if display panel hasFastPartialUpdate
  80. helloFullScreenPartialMode();
  81. delay(1000);
  82. helloArduino();
  83. delay(1000);
  84. helloEpaper();
  85. delay(1000);
  86. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  87. delay(1000);
  88. drawBitmaps();
  89. if (display.epd2.hasPartialUpdate)
  90. {
  91. showPartialUpdate();
  92. delay(1000);
  93. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  94. //drawCornerTest();
  95. //showBox(16, 16, 48, 32, false);
  96. //showBox(16, 56, 48, 32, true);
  97. display.powerOff();
  98. deepSleepTest();
  99. Serial.println("setup done");
  100. }
  101. void loop()
  102. {
  103. }
  104. // note for partial update window and setPartialWindow() method:
  105. // partial update window size and position is on byte boundary in physical x direction
  106. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  107. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  108. const char HelloWorld[] = "Hello World!";
  109. const char HelloArduino[] = "Hello Arduino!";
  110. const char HelloEpaper[] = "Hello E-Paper!";
  111. void helloWorld()
  112. {
  113. //Serial.println("helloWorld");
  114. display.setRotation(1);
  115. display.setFont(&FreeMonoBold9pt7b);
  116. display.setTextColor(GxEPD_BLACK);
  117. int16_t tbx, tby; uint16_t tbw, tbh;
  118. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  119. // center bounding box by transposition of origin:
  120. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  121. uint16_t y = ((display.height() - tbh) / 2) - tby;
  122. display.setFullWindow();
  123. display.firstPage();
  124. do
  125. {
  126. display.fillScreen(GxEPD_WHITE);
  127. display.setCursor(x, y);
  128. display.print(HelloWorld);
  129. }
  130. while (display.nextPage());
  131. //Serial.println("helloWorld done");
  132. }
  133. void helloWorldForDummies()
  134. {
  135. //Serial.println("helloWorld");
  136. const char text[] = "Hello World!";
  137. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  138. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  139. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  140. display.setRotation(1);
  141. // select a suitable font in Adafruit_GFX
  142. display.setFont(&FreeMonoBold9pt7b);
  143. // on e-papers black on white is more pleasant to read
  144. display.setTextColor(GxEPD_BLACK);
  145. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  146. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  147. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  148. // center bounding box by transposition of origin:
  149. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  150. uint16_t y = ((display.height() - tbh) / 2) - tby;
  151. // full window mode is the initial mode, set it anyway
  152. display.setFullWindow();
  153. // here we use paged drawing, even if the processor has enough RAM for full buffer
  154. // so this can be used with any supported processor board.
  155. // the cost in code overhead and execution time penalty is marginal
  156. // tell the graphics class to use paged drawing mode
  157. display.firstPage();
  158. do
  159. {
  160. // this part of code is executed multiple times, as many as needed,
  161. // in case of full buffer it is executed once
  162. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  163. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  164. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  165. display.setCursor(x, y); // set the postition to start printing text
  166. display.print(text); // print some text
  167. // end of part executed multiple times
  168. }
  169. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  170. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  171. // returns true if more pages need be drawn and transferred
  172. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  173. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  174. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  175. while (display.nextPage());
  176. //Serial.println("helloWorld done");
  177. }
  178. void helloFullScreenPartialMode()
  179. {
  180. //Serial.println("helloFullScreenPartialMode");
  181. const char fullscreen[] = "full screen update";
  182. const char fpm[] = "fast partial mode";
  183. const char spm[] = "slow partial mode";
  184. const char npm[] = "no partial mode";
  185. display.setPartialWindow(0, 0, display.width(), display.height());
  186. display.setRotation(1);
  187. display.setFont(&FreeMonoBold9pt7b);
  188. display.setTextColor(GxEPD_BLACK);
  189. const char* updatemode;
  190. if (display.epd2.hasFastPartialUpdate)
  191. {
  192. updatemode = fpm;
  193. }
  194. else if (display.epd2.hasPartialUpdate)
  195. {
  196. updatemode = spm;
  197. }
  198. else
  199. {
  200. updatemode = npm;
  201. }
  202. // do this outside of the loop
  203. int16_t tbx, tby; uint16_t tbw, tbh;
  204. // center update text
  205. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  206. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  207. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  208. // center update mode
  209. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  210. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  211. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  212. // center HelloWorld
  213. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  214. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  215. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  216. display.firstPage();
  217. do
  218. {
  219. display.fillScreen(GxEPD_WHITE);
  220. display.setCursor(hwx, hwy);
  221. display.print(HelloWorld);
  222. display.setCursor(utx, uty);
  223. display.print(fullscreen);
  224. display.setCursor(umx, umy);
  225. display.print(updatemode);
  226. }
  227. while (display.nextPage());
  228. //Serial.println("helloFullScreenPartialMode done");
  229. }
  230. void helloArduino()
  231. {
  232. //Serial.println("helloArduino");
  233. display.setRotation(1);
  234. display.setFont(&FreeMonoBold9pt7b);
  235. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  236. int16_t tbx, tby; uint16_t tbw, tbh;
  237. // align with centered HelloWorld
  238. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  239. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  240. // height might be different
  241. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  242. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  243. // make the window big enough to cover (overwrite) descenders of previous text
  244. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  245. uint16_t wy = (display.height() / 4) - wh / 2;
  246. display.setPartialWindow(0, wy, display.width(), wh);
  247. display.firstPage();
  248. do
  249. {
  250. display.fillScreen(GxEPD_WHITE);
  251. //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
  252. display.setCursor(x, y);
  253. display.print(HelloArduino);
  254. }
  255. while (display.nextPage());
  256. delay(1000);
  257. //Serial.println("helloArduino done");
  258. }
  259. void helloEpaper()
  260. {
  261. //Serial.println("helloEpaper");
  262. display.setRotation(1);
  263. display.setFont(&FreeMonoBold9pt7b);
  264. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  265. int16_t tbx, tby; uint16_t tbw, tbh;
  266. // align with centered HelloWorld
  267. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  268. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  269. // height might be different
  270. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  271. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  272. // make the window big enough to cover (overwrite) descenders of previous text
  273. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  274. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  275. display.setPartialWindow(0, wy, display.width(), wh);
  276. display.firstPage();
  277. do
  278. {
  279. display.fillScreen(GxEPD_WHITE);
  280. display.setCursor(x, y);
  281. display.print(HelloEpaper);
  282. }
  283. while (display.nextPage());
  284. //Serial.println("helloEpaper done");
  285. }
  286. void deepSleepTest()
  287. {
  288. //Serial.println("deepSleepTest");
  289. const char hibernating[] = "hibernating ...";
  290. const char wokeup[] = "woke up";
  291. const char from[] = "from deep sleep";
  292. const char again[] = "again";
  293. display.setRotation(1);
  294. display.setFont(&FreeMonoBold9pt7b);
  295. display.setTextColor(GxEPD_BLACK);
  296. int16_t tbx, tby; uint16_t tbw, tbh;
  297. // center text
  298. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  299. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  300. uint16_t y = ((display.height() - tbh) / 2) - tby;
  301. display.setFullWindow();
  302. display.firstPage();
  303. do
  304. {
  305. display.fillScreen(GxEPD_WHITE);
  306. display.setCursor(x, y);
  307. display.print(hibernating);
  308. }
  309. while (display.nextPage());
  310. display.hibernate();
  311. delay(5000);
  312. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  313. uint16_t wx = (display.width() - tbw) / 2;
  314. uint16_t wy = (display.height() / 3) + tbh / 2; // y is base line!
  315. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  316. uint16_t fx = (display.width() - tbw) / 2;
  317. uint16_t fy = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  318. display.firstPage();
  319. do
  320. {
  321. display.fillScreen(GxEPD_WHITE);
  322. display.setCursor(wx, wy);
  323. display.print(wokeup);
  324. display.setCursor(fx, fy);
  325. display.print(from);
  326. }
  327. while (display.nextPage());
  328. delay(5000);
  329. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  330. uint16_t hx = (display.width() - tbw) / 2;
  331. uint16_t hy = (display.height() / 3) + tbh / 2; // y is base line!
  332. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  333. uint16_t ax = (display.width() - tbw) / 2;
  334. uint16_t ay = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  335. display.firstPage();
  336. do
  337. {
  338. display.fillScreen(GxEPD_WHITE);
  339. display.setCursor(hx, hy);
  340. display.print(hibernating);
  341. display.setCursor(ax, ay);
  342. display.print(again);
  343. }
  344. while (display.nextPage());
  345. display.hibernate();
  346. //Serial.println("deepSleepTest done");
  347. }
  348. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  349. {
  350. //Serial.println("showBox");
  351. display.setRotation(1);
  352. if (partial)
  353. {
  354. display.setPartialWindow(x, y, w, h);
  355. }
  356. else
  357. {
  358. display.setFullWindow();
  359. }
  360. display.firstPage();
  361. do
  362. {
  363. display.fillScreen(GxEPD_WHITE);
  364. display.fillRect(x, y, w, h, GxEPD_BLACK);
  365. }
  366. while (display.nextPage());
  367. //Serial.println("showBox done");
  368. }
  369. void drawCornerTest()
  370. {
  371. display.setFullWindow();
  372. display.setFont(&FreeMonoBold9pt7b);
  373. display.setTextColor(GxEPD_BLACK);
  374. for (uint16_t r = 0; r <= 4; r++)
  375. {
  376. display.setRotation(r);
  377. display.firstPage();
  378. do
  379. {
  380. display.fillScreen(GxEPD_WHITE);
  381. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  382. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  383. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  384. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  385. display.setCursor(display.width() / 2, display.height() / 2);
  386. display.print(display.getRotation());
  387. }
  388. while (display.nextPage());
  389. delay(2000);
  390. }
  391. }
  392. void showFont(const char name[], const GFXfont* f)
  393. {
  394. display.setFullWindow();
  395. display.setRotation(0);
  396. display.setTextColor(GxEPD_BLACK);
  397. display.firstPage();
  398. do
  399. {
  400. drawFont(name, f);
  401. }
  402. while (display.nextPage());
  403. }
  404. void drawFont(const char name[], const GFXfont* f)
  405. {
  406. //display.setRotation(0);
  407. display.fillScreen(GxEPD_WHITE);
  408. display.setTextColor(GxEPD_BLACK);
  409. display.setFont(f);
  410. display.setCursor(0, 0);
  411. display.println();
  412. display.println(name);
  413. display.println(" !\"#$%&'()*+,-./");
  414. display.println("0123456789:;<=>?");
  415. display.println("@ABCDEFGHIJKLMNO");
  416. display.println("PQRSTUVWXYZ[\\]^_");
  417. if (display.epd2.hasColor)
  418. {
  419. display.setTextColor(GxEPD_RED);
  420. }
  421. display.println("`abcdefghijklmno");
  422. display.println("pqrstuvwxyz{|}~ ");
  423. }
  424. // note for partial update window and setPartialWindow() method:
  425. // partial update window size and position is on byte boundary in physical x direction
  426. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  427. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  428. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  429. void showPartialUpdate()
  430. {
  431. // some useful background
  432. helloWorld();
  433. // use asymmetric values for test
  434. uint16_t box_x = 10;
  435. uint16_t box_y = 15;
  436. uint16_t box_w = 70;
  437. uint16_t box_h = 20;
  438. uint16_t cursor_y = box_y + box_h - 6;
  439. float value = 13.95;
  440. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  441. display.setFont(&FreeMonoBold9pt7b);
  442. display.setTextColor(GxEPD_BLACK);
  443. // show where the update box is
  444. for (uint16_t r = 0; r < 4; r++)
  445. {
  446. display.setRotation(r);
  447. display.setPartialWindow(box_x, box_y, box_w, box_h);
  448. display.firstPage();
  449. do
  450. {
  451. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  452. //display.fillScreen(GxEPD_BLACK);
  453. }
  454. while (display.nextPage());
  455. delay(2000);
  456. display.firstPage();
  457. do
  458. {
  459. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  460. }
  461. while (display.nextPage());
  462. delay(1000);
  463. }
  464. //return;
  465. // show updates in the update box
  466. for (uint16_t r = 0; r < 4; r++)
  467. {
  468. display.setRotation(r);
  469. display.setPartialWindow(box_x, box_y, box_w, box_h);
  470. for (uint16_t i = 1; i <= 10; i += incr)
  471. {
  472. display.firstPage();
  473. do
  474. {
  475. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  476. display.setCursor(box_x, cursor_y);
  477. display.print(value * i, 2);
  478. }
  479. while (display.nextPage());
  480. delay(500);
  481. }
  482. delay(1000);
  483. display.firstPage();
  484. do
  485. {
  486. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  487. }
  488. while (display.nextPage());
  489. delay(1000);
  490. }
  491. }
  492. void drawBitmaps()
  493. {
  494. display.setFullWindow();
  495. #ifdef _GxBitmaps104x212_H_
  496. drawBitmaps104x212();
  497. #endif
  498. #ifdef _GxBitmaps128x250_H_
  499. drawBitmaps128x250();
  500. #endif
  501. #ifdef _GxBitmaps128x296_H_
  502. drawBitmaps128x296();
  503. #endif
  504. #ifdef _GxBitmaps176x264_H_
  505. drawBitmaps176x264();
  506. #endif
  507. #ifdef _GxBitmaps400x300_H_
  508. drawBitmaps400x300();
  509. #endif
  510. #ifdef _GxBitmaps640x384_H_
  511. drawBitmaps640x384();
  512. #endif
  513. #ifdef _WS_Bitmaps800x600_H_
  514. drawBitmaps800x600();
  515. #endif
  516. // 3-color
  517. #ifdef _GxBitmaps3c104x212_H_
  518. drawBitmaps3c104x212();
  519. #endif
  520. #ifdef _GxBitmaps3c128x296_H_
  521. drawBitmaps3c128x296();
  522. #endif
  523. #ifdef _GxBitmaps3c176x264_H_
  524. drawBitmaps3c176x264();
  525. #endif
  526. #ifdef _GxBitmaps3c400x300_H_
  527. drawBitmaps3c400x300();
  528. #endif
  529. // show these after the specific bitmaps
  530. #ifdef _GxBitmaps200x200_H_
  531. drawBitmaps200x200();
  532. #endif
  533. // 3-color
  534. #ifdef _GxBitmaps3c200x200_H_
  535. drawBitmaps3c200x200();
  536. #endif
  537. }
  538. #ifdef _GxBitmaps200x200_H_
  539. void drawBitmaps200x200()
  540. {
  541. #if defined(__AVR)
  542. const unsigned char* bitmaps[] =
  543. {
  544. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  545. };
  546. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  547. const unsigned char* bitmaps[] =
  548. {
  549. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  550. };
  551. #else
  552. const unsigned char* bitmaps[] =
  553. {
  554. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  555. };
  556. #endif
  557. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  558. {
  559. bool m = display.mirror(true);
  560. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  561. {
  562. display.firstPage();
  563. do
  564. {
  565. display.fillScreen(GxEPD_WHITE);
  566. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  567. }
  568. while (display.nextPage());
  569. delay(2000);
  570. }
  571. display.mirror(m);
  572. }
  573. //else
  574. {
  575. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  576. display.clearScreen(); // use default for white
  577. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  578. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  579. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  580. {
  581. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  582. delay(2000);
  583. }
  584. }
  585. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  586. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  587. {
  588. int16_t x = -60;
  589. int16_t y = -60;
  590. for (uint16_t j = 0; j < 10; j++)
  591. {
  592. display.writeScreenBuffer(); // use default for white
  593. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  594. display.refresh(true);
  595. if (display.epd2.hasFastPartialUpdate)
  596. {
  597. // for differential update: set previous buffer equal to current buffer in controller
  598. display.epd2.writeScreenBufferAgain(); // use default for white
  599. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  600. }
  601. delay(2000);
  602. x += 40;
  603. y += 40;
  604. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  605. }
  606. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  607. break; // comment out for full show
  608. }
  609. display.writeScreenBuffer(); // use default for white
  610. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  611. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  612. display.refresh(true);
  613. delay(2000);
  614. }
  615. #endif
  616. #ifdef _GxBitmaps104x212_H_
  617. void drawBitmaps104x212()
  618. {
  619. #if !defined(__AVR)
  620. const unsigned char* bitmaps[] =
  621. {
  622. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  623. };
  624. #else
  625. const unsigned char* bitmaps[] =
  626. {
  627. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  628. };
  629. #endif
  630. if (display.epd2.panel == GxEPD2::GDEW0213I5F)
  631. {
  632. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  633. {
  634. display.firstPage();
  635. do
  636. {
  637. display.fillScreen(GxEPD_WHITE);
  638. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  639. }
  640. while (display.nextPage());
  641. delay(2000);
  642. }
  643. }
  644. }
  645. #endif
  646. #ifdef _GxBitmaps128x250_H_
  647. void drawBitmaps128x250()
  648. {
  649. #if !defined(__AVR)
  650. const unsigned char* bitmaps[] =
  651. {
  652. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  653. };
  654. #else
  655. const unsigned char* bitmaps[] =
  656. {
  657. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  658. };
  659. #endif
  660. if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
  661. {
  662. bool m = display.mirror(true);
  663. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  664. {
  665. display.firstPage();
  666. do
  667. {
  668. display.fillScreen(GxEPD_WHITE);
  669. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  670. }
  671. while (display.nextPage());
  672. delay(2000);
  673. }
  674. display.mirror(m);
  675. }
  676. }
  677. #endif
  678. #ifdef _GxBitmaps128x296_H_
  679. void drawBitmaps128x296()
  680. {
  681. #if !defined(__AVR)
  682. const unsigned char* bitmaps[] =
  683. {
  684. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  685. };
  686. #else
  687. const unsigned char* bitmaps[] =
  688. {
  689. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  690. };
  691. #endif
  692. if (display.epd2.panel == GxEPD2::GDEH029A1)
  693. {
  694. bool m = display.mirror(true);
  695. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  696. {
  697. display.firstPage();
  698. do
  699. {
  700. display.fillScreen(GxEPD_WHITE);
  701. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  702. }
  703. while (display.nextPage());
  704. delay(2000);
  705. }
  706. display.mirror(m);
  707. }
  708. }
  709. #endif
  710. #ifdef _GxBitmaps176x264_H_
  711. void drawBitmaps176x264()
  712. {
  713. #if !defined(__AVR)
  714. const unsigned char* bitmaps[] =
  715. {
  716. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  717. };
  718. #else
  719. const unsigned char* bitmaps[] =
  720. {
  721. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  722. };
  723. #endif
  724. if (display.epd2.panel == GxEPD2::GDEW027W3)
  725. {
  726. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  727. {
  728. display.firstPage();
  729. do
  730. {
  731. display.fillScreen(GxEPD_WHITE);
  732. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  733. }
  734. while (display.nextPage());
  735. delay(2000);
  736. }
  737. }
  738. }
  739. #endif
  740. #ifdef _GxBitmaps400x300_H_
  741. void drawBitmaps400x300()
  742. {
  743. #if !defined(__AVR)
  744. const unsigned char* bitmaps[] =
  745. {
  746. Bitmap400x300_1, Bitmap400x300_2
  747. };
  748. #else
  749. const unsigned char* bitmaps[] = {}; // not enough code space
  750. #endif
  751. if (display.epd2.panel == GxEPD2::GDEW042T2)
  752. {
  753. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  754. {
  755. display.firstPage();
  756. do
  757. {
  758. display.fillScreen(GxEPD_WHITE);
  759. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  760. }
  761. while (display.nextPage());
  762. delay(2000);
  763. }
  764. }
  765. }
  766. #endif
  767. #ifdef _GxBitmaps640x384_H_
  768. void drawBitmaps640x384()
  769. {
  770. #if !defined(__AVR)
  771. const unsigned char* bitmaps[] =
  772. {
  773. Bitmap640x384_1, Bitmap640x384_2
  774. };
  775. #else
  776. const unsigned char* bitmaps[] = {}; // not enough code space
  777. #endif
  778. if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
  779. {
  780. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  781. {
  782. display.firstPage();
  783. do
  784. {
  785. display.fillScreen(GxEPD_WHITE);
  786. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  787. }
  788. while (display.nextPage());
  789. delay(2000);
  790. }
  791. }
  792. }
  793. #endif
  794. #ifdef _WS_Bitmaps800x600_H_
  795. void drawBitmaps800x600()
  796. {
  797. #if defined(ESP8266) || defined(ESP32)
  798. if (display.epd2.panel == GxEPD2::ED060SCT)
  799. {
  800. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  801. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  802. delay(2000);
  803. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  804. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  805. // delay(2000);
  806. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  807. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  808. // delay(2000);
  809. }
  810. #endif
  811. }
  812. #endif
  813. struct bitmap_pair
  814. {
  815. const unsigned char* black;
  816. const unsigned char* red;
  817. };
  818. #ifdef _GxBitmaps3c200x200_H_
  819. void drawBitmaps3c200x200()
  820. {
  821. bitmap_pair bitmap_pairs[] =
  822. {
  823. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  824. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  825. };
  826. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  827. {
  828. display.firstPage();
  829. do
  830. {
  831. display.fillScreen(GxEPD_WHITE);
  832. // Bitmap3c200x200_black has 2 bits per pixel
  833. // taken from Adafruit_GFX.cpp, modified
  834. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  835. uint8_t byte = 0;
  836. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  837. {
  838. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  839. {
  840. if (i & 3) byte <<= 2;
  841. else
  842. {
  843. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  844. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  845. #else
  846. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  847. #endif
  848. }
  849. if (!(byte & 0x80))
  850. {
  851. display.drawPixel(i, j, GxEPD_BLACK);
  852. }
  853. }
  854. }
  855. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  856. }
  857. while (display.nextPage());
  858. delay(2000);
  859. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  860. {
  861. display.firstPage();
  862. do
  863. {
  864. display.fillScreen(GxEPD_WHITE);
  865. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  866. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  867. }
  868. while (display.nextPage());
  869. delay(2000);
  870. }
  871. }
  872. if (display.epd2.hasColor)
  873. {
  874. display.clearScreen(); // use default for white
  875. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  876. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  877. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  878. {
  879. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  880. delay(2000);
  881. }
  882. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  883. {
  884. int16_t x = -60;
  885. int16_t y = -60;
  886. for (uint16_t j = 0; j < 10; j++)
  887. {
  888. display.writeScreenBuffer(); // use default for white
  889. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  890. display.refresh();
  891. delay(1000);
  892. x += 40;
  893. y += 40;
  894. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  895. }
  896. }
  897. display.writeScreenBuffer(); // use default for white
  898. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  899. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, int16_t(display.epd2.WIDTH) - 200, int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, false, true);
  900. display.refresh();
  901. delay(2000);
  902. }
  903. }
  904. #endif
  905. #ifdef _GxBitmaps3c104x212_H_
  906. void drawBitmaps3c104x212()
  907. {
  908. #if !defined(__AVR)
  909. bitmap_pair bitmap_pairs[] =
  910. {
  911. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  912. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  913. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  914. };
  915. #else
  916. bitmap_pair bitmap_pairs[] =
  917. {
  918. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  919. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  920. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  921. };
  922. #endif
  923. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  924. {
  925. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  926. {
  927. display.firstPage();
  928. do
  929. {
  930. display.fillScreen(GxEPD_WHITE);
  931. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  932. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  933. {
  934. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  935. }
  936. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  937. }
  938. while (display.nextPage());
  939. delay(2000);
  940. }
  941. }
  942. }
  943. #endif
  944. #ifdef _GxBitmaps3c128x296_H_
  945. void drawBitmaps3c128x296()
  946. {
  947. #if !defined(__AVR)
  948. bitmap_pair bitmap_pairs[] =
  949. {
  950. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  951. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  952. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  953. };
  954. #else
  955. bitmap_pair bitmap_pairs[] =
  956. {
  957. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  958. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  959. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  960. };
  961. #endif
  962. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  963. {
  964. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  965. {
  966. display.firstPage();
  967. do
  968. {
  969. display.fillScreen(GxEPD_WHITE);
  970. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  971. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  972. {
  973. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  974. }
  975. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  976. }
  977. while (display.nextPage());
  978. delay(2000);
  979. }
  980. }
  981. }
  982. #endif
  983. #ifdef _GxBitmaps3c176x264_H_
  984. void drawBitmaps3c176x264()
  985. {
  986. bitmap_pair bitmap_pairs[] =
  987. {
  988. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  989. };
  990. if (display.epd2.panel == GxEPD2::GDEW027C44)
  991. {
  992. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  993. {
  994. display.firstPage();
  995. do
  996. {
  997. display.fillScreen(GxEPD_WHITE);
  998. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  999. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1000. }
  1001. while (display.nextPage());
  1002. delay(2000);
  1003. }
  1004. }
  1005. }
  1006. #endif
  1007. #ifdef _GxBitmaps3c400x300_H_
  1008. void drawBitmaps3c400x300()
  1009. {
  1010. #if !defined(__AVR)
  1011. bitmap_pair bitmap_pairs[] =
  1012. {
  1013. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1014. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1015. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1016. };
  1017. #else
  1018. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1019. #endif
  1020. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1021. {
  1022. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1023. {
  1024. display.firstPage();
  1025. do
  1026. {
  1027. display.fillScreen(GxEPD_WHITE);
  1028. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1029. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1030. }
  1031. while (display.nextPage());
  1032. delay(2000);
  1033. }
  1034. }
  1035. }
  1036. #endif