GxEPD2_WS_ESP32_Driver.ino 35 KB

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