GxEPD2_WS_ESP32_Driver.ino 37 KB

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