GxEPD2_ParticleExample.ino 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. // Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
  2. // Requires HW SPI and Adafruit_GFX. Caution: these e-papers require 3.3V supply AND data lines!
  3. //
  4. // Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
  5. //
  6. // Author: Jean-Marc Zingg
  7. //
  8. // Version: see library.properties
  9. //
  10. // Library: https://github.com/ZinggJM/GxEPD2_PP
  11. //
  12. #include <Adafruit_GFX_RK.h>
  13. #include <GxEPD2.h>
  14. // Supporting Arduino Forum Topics:
  15. // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
  16. // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
  17. // mapping suggestion from Waveshare SPI e-Paper to Particle Photon
  18. // A5 MOSI
  19. // A4 MISO
  20. // A3 SCK
  21. // A2 SS
  22. // BUSY -> D4, RST -> A0, DC -> A1, CS -> A2, CLK -> A3, DIN -> A5, GND -> GND, 3.3V -> 3.3V
  23. // NOTE: it looks like MISO can't be used as general input pin for BUSY.
  24. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  25. // enable or disable GxEPD2_GFX base class
  26. #define ENABLE_GxEPD2_GFX 0
  27. #include <Arduino.h>
  28. #include <Adafruit_GFX.h>
  29. #include <FreeMonoBold9pt7b.h>
  30. #include <GxEPD2_BW.h>
  31. #include <GxEPD2_3C.h>
  32. #if defined(PARTICLE)
  33. // select one and adapt to your mapping, for buffered drawing, can use full buffer size (full HEIGHT) for Photon
  34. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  35. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4)); // GDE0213B1, phased out
  36. GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4)); // GDEH0213B72
  37. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4)); // GDEH0213B73
  38. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4)); // GDEW0213I5F
  39. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  40. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4)); // GDEW029T5
  41. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  42. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  43. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  44. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  45. //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  46. //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  47. // 3-color e-papers
  48. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  49. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  50. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  51. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  52. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  53. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT / 4 > display(GxEPD2_583c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  54. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4 > display(GxEPD2_750c(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4));
  55. //GxEPD2_3C<GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT / 4 > display(GxEPD2_750c_Z08(/*CS=A2*/ SS, /*DC=*/ A1, /*RST=*/ A0, /*BUSY=*/ D4)); // GDEW075Z08 800x480
  56. #endif
  57. // comment out unused bitmaps to reduce code space used
  58. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  59. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  60. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  61. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  62. #include "bitmaps/Bitmaps152x296.h" // 2.6" b/w
  63. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  64. #include "bitmaps/Bitmaps240x416.h" // 3.71" b/w
  65. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  66. //#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // can't select together with the others for Photon
  67. // 3-color
  68. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  69. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  70. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  71. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  72. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  73. //#include "bitmaps/Bitmaps3c800x480.h" // 7.5" b/w/r
  74. //#include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
  75. void setup()
  76. {
  77. Serial.begin(115200);
  78. Serial.println();
  79. Serial.println("setup");
  80. delay(100);
  81. display.init(115200);
  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 _GxBitmaps152x296_H_
  531. drawBitmaps152x296();
  532. #endif
  533. #ifdef _GxBitmaps3c176x264_H_
  534. drawBitmaps3c176x264();
  535. #endif
  536. #ifdef _GxBitmaps240x416_H_
  537. drawBitmaps240x416();
  538. #endif
  539. #ifdef _GxBitmaps3c400x300_H_
  540. drawBitmaps3c400x300();
  541. #endif
  542. #ifdef _GxBitmaps3c800x480_H_
  543. drawBitmaps3c800x480();
  544. #endif
  545. // show these after the specific bitmaps
  546. #ifdef _GxBitmaps200x200_H_
  547. drawBitmaps200x200();
  548. #endif
  549. // 3-color
  550. #ifdef _GxBitmaps3c200x200_H_
  551. drawBitmaps3c200x200();
  552. #endif
  553. }
  554. #ifdef _GxBitmaps200x200_H_
  555. void drawBitmaps200x200()
  556. {
  557. #if defined(__AVR)
  558. const unsigned char* bitmaps[] =
  559. {
  560. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  561. };
  562. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  563. const unsigned char* bitmaps[] =
  564. {
  565. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  566. };
  567. #else
  568. const unsigned char* bitmaps[] =
  569. {
  570. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  571. };
  572. #endif
  573. if (display.epd2.panel == GxEPD2::GDEP015OC1)
  574. {
  575. bool m = display.mirror(true);
  576. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  577. {
  578. display.firstPage();
  579. do
  580. {
  581. display.fillScreen(GxEPD_WHITE);
  582. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  583. }
  584. while (display.nextPage());
  585. delay(2000);
  586. }
  587. display.mirror(m);
  588. }
  589. //else
  590. {
  591. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  592. display.clearScreen(); // use default for white
  593. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  594. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  595. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  596. {
  597. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  598. delay(2000);
  599. }
  600. }
  601. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  602. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  603. {
  604. int16_t x = -60;
  605. int16_t y = -60;
  606. for (uint16_t j = 0; j < 10; j++)
  607. {
  608. display.writeScreenBuffer(); // use default for white
  609. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  610. display.refresh(true);
  611. if (display.epd2.hasFastPartialUpdate)
  612. {
  613. // for differential update: set previous buffer equal to current buffer in controller
  614. display.epd2.writeScreenBufferAgain(); // use default for white
  615. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  616. }
  617. delay(2000);
  618. x += 40;
  619. y += 40;
  620. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  621. }
  622. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  623. break; // comment out for full show
  624. }
  625. display.writeScreenBuffer(); // use default for white
  626. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  627. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  628. display.refresh(true);
  629. delay(2000);
  630. }
  631. #endif
  632. #ifdef _GxBitmaps104x212_H_
  633. void drawBitmaps104x212()
  634. {
  635. #if !defined(__AVR)
  636. const unsigned char* bitmaps[] =
  637. {
  638. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  639. };
  640. #else
  641. const unsigned char* bitmaps[] =
  642. {
  643. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  644. };
  645. #endif
  646. if (display.epd2.panel == GxEPD2::GDEW0213I5F)
  647. {
  648. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  649. {
  650. display.firstPage();
  651. do
  652. {
  653. display.fillScreen(GxEPD_WHITE);
  654. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  655. }
  656. while (display.nextPage());
  657. delay(2000);
  658. }
  659. }
  660. }
  661. #endif
  662. #ifdef _GxBitmaps128x250_H_
  663. void drawBitmaps128x250()
  664. {
  665. #if !defined(__AVR)
  666. const unsigned char* bitmaps[] =
  667. {
  668. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  669. };
  670. #else
  671. const unsigned char* bitmaps[] =
  672. {
  673. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  674. };
  675. #endif
  676. if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
  677. {
  678. bool m = display.mirror(true);
  679. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  680. {
  681. display.firstPage();
  682. do
  683. {
  684. display.fillScreen(GxEPD_WHITE);
  685. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  686. }
  687. while (display.nextPage());
  688. delay(2000);
  689. }
  690. display.mirror(m);
  691. }
  692. }
  693. #endif
  694. #ifdef _GxBitmaps128x296_H_
  695. void drawBitmaps128x296()
  696. {
  697. #if !defined(__AVR)
  698. const unsigned char* bitmaps[] =
  699. {
  700. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  701. };
  702. #else
  703. const unsigned char* bitmaps[] =
  704. {
  705. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  706. };
  707. #endif
  708. if (display.epd2.panel == GxEPD2::GDEH029A1)
  709. {
  710. bool m = display.mirror(true);
  711. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  712. {
  713. display.firstPage();
  714. do
  715. {
  716. display.fillScreen(GxEPD_WHITE);
  717. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  718. }
  719. while (display.nextPage());
  720. delay(2000);
  721. }
  722. display.mirror(m);
  723. }
  724. }
  725. #endif
  726. #ifdef _GxBitmaps152x296_H_
  727. void drawBitmaps152x296()
  728. {
  729. #if !defined(__AVR)
  730. const unsigned char* bitmaps[] =
  731. {
  732. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  733. };
  734. #else
  735. const unsigned char* bitmaps[] =
  736. {
  737. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  738. };
  739. #endif
  740. if (display.epd2.panel == GxEPD2::GDEW026T0)
  741. {
  742. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  743. {
  744. display.firstPage();
  745. do
  746. {
  747. display.fillScreen(GxEPD_WHITE);
  748. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  749. }
  750. while (display.nextPage());
  751. delay(2000);
  752. }
  753. }
  754. }
  755. #endif
  756. #ifdef _GxBitmaps176x264_H_
  757. void drawBitmaps176x264()
  758. {
  759. #if !defined(__AVR)
  760. const unsigned char* bitmaps[] =
  761. {
  762. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  763. };
  764. #else
  765. const unsigned char* bitmaps[] =
  766. {
  767. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  768. };
  769. #endif
  770. if (display.epd2.panel == GxEPD2::GDEW027W3)
  771. {
  772. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  773. {
  774. display.firstPage();
  775. do
  776. {
  777. display.fillScreen(GxEPD_WHITE);
  778. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  779. }
  780. while (display.nextPage());
  781. delay(2000);
  782. }
  783. }
  784. }
  785. #endif
  786. #ifdef _GxBitmaps240x416_H_
  787. void drawBitmaps240x416()
  788. {
  789. #if !defined(__AVR)
  790. const unsigned char* bitmaps[] =
  791. {
  792. Bitmap240x416_1, Bitmap240x416_2, Bitmap240x416_3
  793. };
  794. #else
  795. const unsigned char* bitmaps[] =
  796. {
  797. Bitmap240x460_1, Bitmap240x460_2, Bitmap240x460_3
  798. };
  799. #endif
  800. if (display.epd2.panel == GxEPD2::GDEW0371W7)
  801. {
  802. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  803. {
  804. display.firstPage();
  805. do
  806. {
  807. display.fillScreen(GxEPD_WHITE);
  808. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  809. }
  810. while (display.nextPage());
  811. delay(2000);
  812. }
  813. }
  814. }
  815. #endif
  816. #ifdef _GxBitmaps400x300_H_
  817. void drawBitmaps400x300()
  818. {
  819. #if !defined(__AVR)
  820. const unsigned char* bitmaps[] =
  821. {
  822. Bitmap400x300_1, Bitmap400x300_2
  823. };
  824. #else
  825. const unsigned char* bitmaps[] = {}; // not enough code space
  826. #endif
  827. if (display.epd2.panel == GxEPD2::GDEW042T2)
  828. {
  829. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  830. {
  831. display.firstPage();
  832. do
  833. {
  834. display.fillScreen(GxEPD_WHITE);
  835. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  836. }
  837. while (display.nextPage());
  838. delay(2000);
  839. }
  840. }
  841. }
  842. #endif
  843. #ifdef _GxBitmaps640x384_H_
  844. void drawBitmaps640x384()
  845. {
  846. #if !defined(__AVR)
  847. const unsigned char* bitmaps[] =
  848. {
  849. Bitmap640x384_1, Bitmap640x384_2
  850. };
  851. #else
  852. const unsigned char* bitmaps[] = {}; // not enough code space
  853. #endif
  854. if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
  855. {
  856. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  857. {
  858. display.firstPage();
  859. do
  860. {
  861. display.fillScreen(GxEPD_WHITE);
  862. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  863. }
  864. while (display.nextPage());
  865. delay(2000);
  866. }
  867. }
  868. }
  869. #endif
  870. #ifdef _WS_Bitmaps800x600_H_
  871. void drawBitmaps800x600()
  872. {
  873. #if defined(ESP8266) || defined(ESP32)
  874. if (display.epd2.panel == GxEPD2::ED060SCT)
  875. {
  876. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  877. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  878. delay(2000);
  879. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  880. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  881. // delay(2000);
  882. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  883. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  884. // delay(2000);
  885. }
  886. #endif
  887. }
  888. #endif
  889. struct bitmap_pair
  890. {
  891. const unsigned char* black;
  892. const unsigned char* red;
  893. };
  894. #ifdef _GxBitmaps3c200x200_H_
  895. void drawBitmaps3c200x200()
  896. {
  897. bitmap_pair bitmap_pairs[] =
  898. {
  899. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  900. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  901. };
  902. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  903. {
  904. display.firstPage();
  905. do
  906. {
  907. display.fillScreen(GxEPD_WHITE);
  908. // Bitmap3c200x200_black has 2 bits per pixel
  909. // taken from Adafruit_GFX.cpp, modified
  910. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  911. uint8_t byte = 0;
  912. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  913. {
  914. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  915. {
  916. if (i & 3) byte <<= 2;
  917. else
  918. {
  919. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  920. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  921. #else
  922. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  923. #endif
  924. }
  925. if (!(byte & 0x80))
  926. {
  927. display.drawPixel(i, j, GxEPD_BLACK);
  928. }
  929. }
  930. }
  931. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  932. }
  933. while (display.nextPage());
  934. delay(2000);
  935. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  936. {
  937. display.firstPage();
  938. do
  939. {
  940. display.fillScreen(GxEPD_WHITE);
  941. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  942. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  943. }
  944. while (display.nextPage());
  945. delay(2000);
  946. }
  947. }
  948. if (display.epd2.hasColor)
  949. {
  950. display.clearScreen(); // use default for white
  951. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  952. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  953. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  954. {
  955. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  956. delay(2000);
  957. }
  958. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  959. {
  960. int16_t x = -60;
  961. int16_t y = -60;
  962. for (uint16_t j = 0; j < 10; j++)
  963. {
  964. display.writeScreenBuffer(); // use default for white
  965. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  966. display.refresh();
  967. delay(1000);
  968. x += 40;
  969. y += 40;
  970. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  971. }
  972. }
  973. display.writeScreenBuffer(); // use default for white
  974. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  975. 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);
  976. display.refresh();
  977. delay(2000);
  978. }
  979. }
  980. #endif
  981. #ifdef _GxBitmaps3c104x212_H_
  982. void drawBitmaps3c104x212()
  983. {
  984. #if !defined(__AVR)
  985. bitmap_pair bitmap_pairs[] =
  986. {
  987. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  988. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  989. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  990. };
  991. #else
  992. bitmap_pair bitmap_pairs[] =
  993. {
  994. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  995. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  996. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  997. };
  998. #endif
  999. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1000. {
  1001. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1002. {
  1003. display.firstPage();
  1004. do
  1005. {
  1006. display.fillScreen(GxEPD_WHITE);
  1007. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1008. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1009. {
  1010. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1011. }
  1012. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1013. }
  1014. while (display.nextPage());
  1015. delay(2000);
  1016. }
  1017. }
  1018. }
  1019. #endif
  1020. #ifdef _GxBitmaps3c128x296_H_
  1021. void drawBitmaps3c128x296()
  1022. {
  1023. #if !defined(__AVR)
  1024. bitmap_pair bitmap_pairs[] =
  1025. {
  1026. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1027. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1028. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1029. };
  1030. #else
  1031. bitmap_pair bitmap_pairs[] =
  1032. {
  1033. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1034. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1035. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1036. };
  1037. #endif
  1038. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  1039. {
  1040. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1041. {
  1042. display.firstPage();
  1043. do
  1044. {
  1045. display.fillScreen(GxEPD_WHITE);
  1046. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1047. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1048. {
  1049. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1050. }
  1051. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1052. }
  1053. while (display.nextPage());
  1054. delay(2000);
  1055. }
  1056. }
  1057. }
  1058. #endif
  1059. #ifdef _GxBitmaps3c176x264_H_
  1060. void drawBitmaps3c176x264()
  1061. {
  1062. bitmap_pair bitmap_pairs[] =
  1063. {
  1064. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1065. };
  1066. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1067. {
  1068. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1069. {
  1070. display.firstPage();
  1071. do
  1072. {
  1073. display.fillScreen(GxEPD_WHITE);
  1074. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1075. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1076. }
  1077. while (display.nextPage());
  1078. delay(2000);
  1079. }
  1080. }
  1081. }
  1082. #endif
  1083. #ifdef _GxBitmaps3c400x300_H_
  1084. void drawBitmaps3c400x300()
  1085. {
  1086. #if !defined(__AVR)
  1087. bitmap_pair bitmap_pairs[] =
  1088. {
  1089. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1090. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1091. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1092. };
  1093. #else
  1094. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1095. #endif
  1096. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1097. {
  1098. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1099. {
  1100. display.firstPage();
  1101. do
  1102. {
  1103. display.fillScreen(GxEPD_WHITE);
  1104. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1105. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1106. }
  1107. while (display.nextPage());
  1108. delay(2000);
  1109. }
  1110. }
  1111. }
  1112. #endif
  1113. #ifdef _GxBitmaps3c800x480_H_
  1114. void drawBitmaps3c800x480()
  1115. {
  1116. #if !defined(__AVR)
  1117. bitmap_pair bitmap_pairs[] =
  1118. {
  1119. {Bitmap3c800x480_1_black, Bitmap3c800x480_1_red}
  1120. };
  1121. #else
  1122. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1123. #endif
  1124. if (display.epd2.panel == GxEPD2::GDEW075Z08)
  1125. {
  1126. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1127. {
  1128. display.firstPage();
  1129. do
  1130. {
  1131. display.fillScreen(GxEPD_WHITE);
  1132. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1133. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1134. }
  1135. while (display.nextPage());
  1136. delay(2000);
  1137. }
  1138. }
  1139. }
  1140. #endif