GxEPD2_WS_ESP32_Driver.ino 37 KB

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