GxEPD2_WS_ESP32_Driver.ino 36 KB

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