GxEPD2_Example.ino 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803
  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. // Supporting Arduino Forum Topics:
  12. // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
  13. // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
  14. // see GxEPD2_wiring_examples.h for wiring suggestions and examples
  15. // NOTE for use with Waveshare ESP32 Driver Board:
  16. // **** also need to select the constructor with the parameters for this board in GxEPD2_display_selection_new_style.h ****
  17. //
  18. // The Wavehare ESP32 Driver Board uses uncommon SPI pins for the FPC connector. It uses HSPI pins, but SCK and MOSI are swapped.
  19. // To use HW SPI with the ESP32 Driver Board, HW SPI pins need be re-mapped in any case. Can be done using either HSPI or VSPI.
  20. // Other SPI clients can either be connected to the same SPI bus as the e-paper, or to the other HW SPI bus, or through SW SPI.
  21. // The logical configuration would be to use the e-paper connection on HSPI with re-mapped pins, and use VSPI for other SPI clients.
  22. // VSPI with standard VSPI pins is used by the global SPI instance of the Arduino IDE ESP32 package.
  23. // uncomment next line to use HSPI for EPD (and e.g VSPI for SD), e.g. with Waveshare ESP32 Driver Board
  24. //#define USE_HSPI_FOR_EPD
  25. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  26. // enable or disable GxEPD2_GFX base class
  27. #define ENABLE_GxEPD2_GFX 0
  28. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  29. //#include <GFX.h>
  30. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  31. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  32. #include <GxEPD2_BW.h>
  33. #include <GxEPD2_3C.h>
  34. #include <GxEPD2_4C.h>
  35. #include <GxEPD2_7C.h>
  36. #include <Fonts/FreeMonoBold9pt7b.h>
  37. // select the display constructor line in one of the following files (old style):
  38. #include "GxEPD2_display_selection.h"
  39. #include "GxEPD2_display_selection_added.h"
  40. // or select the display class and display driver class in the following file (new style):
  41. #include "GxEPD2_display_selection_new_style.h"
  42. #if !defined(__AVR) && !defined(STM32F1xx)
  43. // note 16.11.2019: the compiler may exclude code based on constant if statements (display.epd2.panel == constant),
  44. // therefore bitmaps may get optimized out by the linker
  45. // comment out unused bitmaps to reduce code space used
  46. #include "bitmaps/Bitmaps80x128.h" // 1.02" b/w
  47. #include "bitmaps/Bitmaps152x152.h" // 1.54" b/w
  48. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  49. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  50. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  51. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  52. #include "bitmaps/Bitmaps152x296.h" // 2.6" b/w
  53. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  54. #include "bitmaps/Bitmaps240x416.h" // 3.71" b/w
  55. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  56. #include "bitmaps/Bitmaps648x480.h" // 5.38" b/w
  57. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  58. #include "bitmaps/Bitmaps800x480.h" // 7.5" b/w
  59. // 3-color
  60. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  61. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  62. #include "bitmaps/Bitmaps3c128x250.h" // 2.13" b/w/r
  63. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  64. #include "bitmaps/Bitmaps3c152x296.h" // 2.66" b/w/r
  65. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  66. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  67. #if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
  68. #include "bitmaps/Bitmaps3c648x480.h" // 5.83" b/w/r
  69. #include "bitmaps/Bitmaps3c800x480.h" // 7.5" b/w/r
  70. #include "bitmaps/Bitmaps3c880x528.h" // 7.5" b/w/r
  71. #include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
  72. #include "bitmaps/WS_Bitmaps4c168x168.h" // 4.37" 4-color
  73. #include "bitmaps/WS_Bitmaps7c192x143.h" // 5.65" 7-color
  74. //#include "bitmaps/WS_Bitmaps7c300x180.h" // 7.3" 7-color
  75. #endif
  76. #if defined(ESP32)
  77. #include "bitmaps/Bitmaps1304x984.h" // 12.48" b/w
  78. #include "bitmaps/Bitmaps3c1304x984.h" // 12.48" b/w/r
  79. #include "bitmaps/Bitmaps7c800x480.h" // 7.3" 7-color
  80. #endif
  81. #else
  82. // select only one to fit in code space
  83. //#include "bitmaps/Bitmaps80x128.h" // 1.02" b/w
  84. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  85. //#include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  86. //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  87. //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  88. //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  89. ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
  90. ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
  91. // 3-color
  92. //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  93. //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  94. #include "bitmaps/Bitmaps3c128x250.h" // 2.13" b/w/r
  95. //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  96. //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  97. ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
  98. #endif
  99. #if defined(ARDUINO_ARCH_RP2040) && defined(ARDUINO_RASPBERRY_PI_PICO)
  100. // SPI pins used by GoodDisplay DESPI-PICO. note: steals standard I2C pins PIN_WIRE_SDA (6), PIN_WIRE_SCL (7)
  101. // uncomment next line for use with GoodDisplay DESPI-PICO. // MbedSPI(int miso, int mosi, int sck);
  102. arduino::MbedSPI SPI0(4, 7, 6); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  103. #endif
  104. #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  105. SPIClass hspi(HSPI);
  106. #endif
  107. void setup()
  108. {
  109. Serial.begin(115200);
  110. Serial.println();
  111. Serial.println("setup");
  112. delay(100);
  113. #if defined(ARDUINO_ARCH_RP2040) && defined(ARDUINO_RASPBERRY_PI_PICO)
  114. // uncomment next line for use with GoodDisplay DESPI-PICO, or use the extended init method
  115. //display.epd2.selectSPI(SPI0, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  116. // uncomment next 2 lines to allow recovery from configuration failures
  117. pinMode(15, INPUT_PULLUP); // safety pin
  118. while (!digitalRead(15)) delay(100); // check safety pin for fail recovery
  119. #endif
  120. #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  121. hspi.begin(13, 12, 14, 15); // remap hspi for EPD (swap pins)
  122. display.epd2.selectSPI(hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  123. #endif
  124. //display.init(115200); // default 10ms reset pulse, e.g. for bare panels with DESPI-C02
  125. display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
  126. //display.init(115200, true, 10, false, SPI0, SPISettings(4000000, MSBFIRST, SPI_MODE0)); // extended init method with SPI channel and/or settings selection
  127. // first update should be full refresh
  128. helloWorld();
  129. delay(1000);
  130. // partial refresh mode can be used to full screen,
  131. // effective if display panel hasFastPartialUpdate
  132. helloFullScreenPartialMode();
  133. delay(1000);
  134. //stripeTest(); return; // GDEH029Z13 issue
  135. helloArduino();
  136. delay(1000);
  137. helloEpaper();
  138. delay(1000);
  139. //helloValue(123.9, 1);
  140. //delay(1000);
  141. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  142. delay(1000);
  143. if (display.epd2.WIDTH < 104)
  144. {
  145. showFont("glcdfont", 0);
  146. delay(1000);
  147. }
  148. drawBitmaps();
  149. drawGraphics();
  150. //return;
  151. #if !defined(__AVR) // takes too long!
  152. if ((display.epd2.panel == GxEPD2::ACeP565) || (display.epd2.panel == GxEPD2::GDEY073D46))
  153. {
  154. //draw7colorlines();
  155. //delay(2000);
  156. draw7colors();
  157. delay(4000);
  158. }
  159. #endif
  160. if (display.epd2.hasPartialUpdate)
  161. {
  162. showPartialUpdate();
  163. delay(1000);
  164. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  165. //drawCornerTest();
  166. //showBox(16, 16, 48, 32, false);
  167. //showBox(16, 56, 48, 32, true);
  168. display.powerOff();
  169. deepSleepTest();
  170. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  171. drawBitmaps1304x984();
  172. display.powerOff();
  173. #endif
  174. Serial.println("setup done");
  175. }
  176. void loop()
  177. {
  178. }
  179. // note for partial update window and setPartialWindow() method:
  180. // partial update window size and position is on byte boundary in physical x direction
  181. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  182. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  183. const char HelloWorld[] = "Hello World!";
  184. const char HelloArduino[] = "Hello Arduino!";
  185. const char HelloEpaper[] = "Hello E-Paper!";
  186. void helloWorld()
  187. {
  188. //Serial.println("helloWorld");
  189. display.setRotation(1);
  190. display.setFont(&FreeMonoBold9pt7b);
  191. if (display.epd2.WIDTH < 104) display.setFont(0);
  192. display.setTextColor(GxEPD_BLACK);
  193. int16_t tbx, tby; uint16_t tbw, tbh;
  194. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  195. // center bounding box by transposition of origin:
  196. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  197. uint16_t y = ((display.height() - tbh) / 2) - tby;
  198. display.setFullWindow();
  199. display.firstPage();
  200. do
  201. {
  202. display.fillScreen(GxEPD_WHITE);
  203. display.setCursor(x, y);
  204. display.print(HelloWorld);
  205. }
  206. while (display.nextPage());
  207. //Serial.println("helloWorld done");
  208. }
  209. void helloWorldForDummies()
  210. {
  211. //Serial.println("helloWorld");
  212. const char text[] = "Hello World!";
  213. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  214. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  215. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  216. display.setRotation(1);
  217. // select a suitable font in Adafruit_GFX
  218. display.setFont(&FreeMonoBold9pt7b);
  219. // on e-papers black on white is more pleasant to read
  220. display.setTextColor(GxEPD_BLACK);
  221. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  222. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  223. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  224. // center bounding box by transposition of origin:
  225. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  226. uint16_t y = ((display.height() - tbh) / 2) - tby;
  227. // full window mode is the initial mode, set it anyway
  228. display.setFullWindow();
  229. // here we use paged drawing, even if the processor has enough RAM for full buffer
  230. // so this can be used with any supported processor board.
  231. // the cost in code overhead and execution time penalty is marginal
  232. // tell the graphics class to use paged drawing mode
  233. display.firstPage();
  234. do
  235. {
  236. // this part of code is executed multiple times, as many as needed,
  237. // in case of full buffer it is executed once
  238. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  239. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  240. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  241. display.setCursor(x, y); // set the postition to start printing text
  242. display.print(text); // print some text
  243. // end of part executed multiple times
  244. }
  245. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  246. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  247. // returns true if more pages need be drawn and transferred
  248. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  249. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  250. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  251. while (display.nextPage());
  252. //Serial.println("helloWorld done");
  253. }
  254. void helloFullScreenPartialMode()
  255. {
  256. //Serial.println("helloFullScreenPartialMode");
  257. const char fullscreen[] = "full screen update";
  258. const char fpm[] = "fast partial mode";
  259. const char spm[] = "slow partial mode";
  260. const char npm[] = "no partial mode";
  261. display.setPartialWindow(0, 0, display.width(), display.height());
  262. display.setRotation(1);
  263. display.setFont(&FreeMonoBold9pt7b);
  264. if (display.epd2.WIDTH < 104) display.setFont(0);
  265. display.setTextColor(GxEPD_BLACK);
  266. const char* updatemode;
  267. if (display.epd2.hasFastPartialUpdate)
  268. {
  269. updatemode = fpm;
  270. }
  271. else if (display.epd2.hasPartialUpdate)
  272. {
  273. updatemode = spm;
  274. }
  275. else
  276. {
  277. updatemode = npm;
  278. }
  279. // do this outside of the loop
  280. int16_t tbx, tby; uint16_t tbw, tbh;
  281. // center update text
  282. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  283. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  284. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  285. // center update mode
  286. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  287. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  288. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  289. // center HelloWorld
  290. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  291. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  292. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  293. display.firstPage();
  294. do
  295. {
  296. display.fillScreen(GxEPD_WHITE);
  297. display.setCursor(hwx, hwy);
  298. display.print(HelloWorld);
  299. display.setCursor(utx, uty);
  300. display.print(fullscreen);
  301. display.setCursor(umx, umy);
  302. display.print(updatemode);
  303. }
  304. while (display.nextPage());
  305. //Serial.println("helloFullScreenPartialMode done");
  306. }
  307. void helloArduino()
  308. {
  309. //Serial.println("helloArduino");
  310. display.setRotation(1);
  311. display.setFont(&FreeMonoBold9pt7b);
  312. if (display.epd2.WIDTH < 104) display.setFont(0);
  313. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  314. int16_t tbx, tby; uint16_t tbw, tbh;
  315. // align with centered HelloWorld
  316. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  317. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  318. // height might be different
  319. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  320. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  321. // make the window big enough to cover (overwrite) descenders of previous text
  322. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  323. uint16_t wy = (display.height() / 4) - wh / 2;
  324. display.setPartialWindow(0, wy, display.width(), wh);
  325. display.firstPage();
  326. do
  327. {
  328. display.fillScreen(GxEPD_WHITE);
  329. //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
  330. display.setCursor(x, y);
  331. display.print(HelloArduino);
  332. }
  333. while (display.nextPage());
  334. delay(1000);
  335. //Serial.println("helloArduino done");
  336. }
  337. void helloEpaper()
  338. {
  339. //Serial.println("helloEpaper");
  340. display.setRotation(1);
  341. display.setFont(&FreeMonoBold9pt7b);
  342. if (display.epd2.WIDTH < 104) display.setFont(0);
  343. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  344. int16_t tbx, tby; uint16_t tbw, tbh;
  345. // align with centered HelloWorld
  346. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  347. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  348. // height might be different
  349. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  350. uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
  351. // make the window big enough to cover (overwrite) descenders of previous text
  352. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  353. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  354. display.setPartialWindow(0, wy, display.width(), wh);
  355. display.firstPage();
  356. do
  357. {
  358. display.fillScreen(GxEPD_WHITE);
  359. display.setCursor(x, y);
  360. display.print(HelloEpaper);
  361. }
  362. while (display.nextPage());
  363. //Serial.println("helloEpaper done");
  364. }
  365. // test partial window issue on GDEW0213Z19 and GDEH029Z13
  366. void stripeTest()
  367. {
  368. helloStripe(104);
  369. delay(2000);
  370. helloStripe(96);
  371. }
  372. const char HelloStripe[] = "Hello Stripe!";
  373. void helloStripe(uint16_t pw_xe) // end of partial window in physcal x direction
  374. {
  375. //Serial.print("HelloStripe("); Serial.print(pw_xe); Serial.println(")");
  376. display.setRotation(3);
  377. display.setFont(&FreeMonoBold9pt7b);
  378. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  379. int16_t tbx, tby; uint16_t tbw, tbh;
  380. display.getTextBounds(HelloStripe, 0, 0, &tbx, &tby, &tbw, &tbh);
  381. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  382. uint16_t wy = pw_xe - wh;
  383. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  384. uint16_t y = wy - tby;
  385. display.setPartialWindow(0, wy, display.width(), wh);
  386. display.firstPage();
  387. do
  388. {
  389. display.fillScreen(GxEPD_WHITE);
  390. display.setCursor(x, y);
  391. display.print(HelloStripe);
  392. }
  393. while (display.nextPage());
  394. //Serial.println("HelloStripe done");
  395. }
  396. #if defined(ESP8266) || defined(ESP32)
  397. #include <StreamString.h>
  398. #define PrintString StreamString
  399. #else
  400. class PrintString : public Print, public String
  401. {
  402. public:
  403. size_t write(uint8_t data) override
  404. {
  405. return concat(char(data));
  406. };
  407. };
  408. #endif
  409. void helloValue(double v, int digits)
  410. {
  411. //Serial.println("helloValue");
  412. display.setRotation(1);
  413. display.setFont(&FreeMonoBold9pt7b);
  414. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  415. PrintString valueString;
  416. valueString.print(v, digits);
  417. int16_t tbx, tby; uint16_t tbw, tbh;
  418. display.getTextBounds(valueString, 0, 0, &tbx, &tby, &tbw, &tbh);
  419. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  420. uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
  421. // show what happens, if we use the bounding box for partial window
  422. uint16_t wx = (display.width() - tbw) / 2;
  423. uint16_t wy = ((display.height() * 3 / 4) - tbh / 2);
  424. display.setPartialWindow(wx, wy, tbw, tbh);
  425. display.firstPage();
  426. do
  427. {
  428. display.fillScreen(GxEPD_WHITE);
  429. display.setCursor(x, y);
  430. display.print(valueString);
  431. }
  432. while (display.nextPage());
  433. delay(2000);
  434. // make the partial window big enough to cover the previous text
  435. uint16_t ww = tbw; // remember window width
  436. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  437. // adjust, because HelloEpaper was aligned, not centered (could calculate this to be precise)
  438. ww = max(ww, uint16_t(tbw + 12)); // 12 seems ok
  439. wx = (display.width() - tbw) / 2;
  440. // make the window big enough to cover (overwrite) descenders of previous text
  441. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  442. wy = (display.height() * 3 / 4) - wh / 2;
  443. display.setPartialWindow(wx, wy, ww, wh);
  444. // alternately use the whole width for partial window
  445. //display.setPartialWindow(0, wy, display.width(), wh);
  446. display.firstPage();
  447. do
  448. {
  449. display.fillScreen(GxEPD_WHITE);
  450. display.setCursor(x, y);
  451. display.print(valueString);
  452. }
  453. while (display.nextPage());
  454. //Serial.println("helloValue done");
  455. }
  456. void deepSleepTest()
  457. {
  458. //Serial.println("deepSleepTest");
  459. const char hibernating[] = "hibernating ...";
  460. const char wokeup[] = "woke up";
  461. const char from[] = "from deep sleep";
  462. const char again[] = "again";
  463. display.setRotation(1);
  464. display.setFont(&FreeMonoBold9pt7b);
  465. if (display.epd2.WIDTH < 104) display.setFont(0);
  466. display.setTextColor(GxEPD_BLACK);
  467. int16_t tbx, tby; uint16_t tbw, tbh;
  468. // center text
  469. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  470. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  471. uint16_t y = ((display.height() - tbh) / 2) - tby;
  472. display.setFullWindow();
  473. display.firstPage();
  474. do
  475. {
  476. display.fillScreen(GxEPD_WHITE);
  477. display.setCursor(x, y);
  478. display.print(hibernating);
  479. }
  480. while (display.nextPage());
  481. display.hibernate();
  482. delay(5000);
  483. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  484. uint16_t wx = (display.width() - tbw) / 2;
  485. uint16_t wy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  486. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  487. uint16_t fx = (display.width() - tbw) / 2;
  488. uint16_t fy = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  489. display.firstPage();
  490. do
  491. {
  492. display.fillScreen(GxEPD_WHITE);
  493. display.setCursor(wx, wy);
  494. display.print(wokeup);
  495. display.setCursor(fx, fy);
  496. display.print(from);
  497. }
  498. while (display.nextPage());
  499. delay(5000);
  500. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  501. uint16_t hx = (display.width() - tbw) / 2;
  502. uint16_t hy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  503. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  504. uint16_t ax = (display.width() - tbw) / 2;
  505. uint16_t ay = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  506. display.firstPage();
  507. do
  508. {
  509. display.fillScreen(GxEPD_WHITE);
  510. display.setCursor(hx, hy);
  511. display.print(hibernating);
  512. display.setCursor(ax, ay);
  513. display.print(again);
  514. }
  515. while (display.nextPage());
  516. display.hibernate();
  517. //Serial.println("deepSleepTest done");
  518. }
  519. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  520. {
  521. //Serial.println("showBox");
  522. display.setRotation(1);
  523. if (partial)
  524. {
  525. display.setPartialWindow(x, y, w, h);
  526. }
  527. else
  528. {
  529. display.setFullWindow();
  530. }
  531. display.firstPage();
  532. do
  533. {
  534. display.fillScreen(GxEPD_WHITE);
  535. display.fillRect(x, y, w, h, GxEPD_BLACK);
  536. }
  537. while (display.nextPage());
  538. //Serial.println("showBox done");
  539. }
  540. void drawCornerTest()
  541. {
  542. display.setFullWindow();
  543. display.setFont(&FreeMonoBold9pt7b);
  544. display.setTextColor(GxEPD_BLACK);
  545. for (uint16_t r = 0; r <= 4; r++)
  546. {
  547. display.setRotation(r);
  548. display.firstPage();
  549. do
  550. {
  551. display.fillScreen(GxEPD_WHITE);
  552. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  553. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  554. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  555. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  556. display.setCursor(display.width() / 2, display.height() / 2);
  557. display.print(display.getRotation());
  558. }
  559. while (display.nextPage());
  560. delay(2000);
  561. }
  562. }
  563. void showFont(const char name[], const GFXfont* f)
  564. {
  565. display.setFullWindow();
  566. display.setRotation(0);
  567. display.setTextColor(GxEPD_BLACK);
  568. display.firstPage();
  569. do
  570. {
  571. drawFont(name, f);
  572. }
  573. while (display.nextPage());
  574. }
  575. void drawFont(const char name[], const GFXfont* f)
  576. {
  577. //display.setRotation(0);
  578. display.fillScreen(GxEPD_WHITE);
  579. display.setTextColor(GxEPD_BLACK);
  580. display.setFont(f);
  581. display.setCursor(0, 0);
  582. display.println();
  583. display.println(name);
  584. display.println(" !\"#$%&'()*+,-./");
  585. display.println("0123456789:;<=>?");
  586. display.println("@ABCDEFGHIJKLMNO");
  587. display.println("PQRSTUVWXYZ[\\]^_");
  588. if (display.epd2.hasColor)
  589. {
  590. display.setTextColor(GxEPD_RED);
  591. }
  592. display.println("`abcdefghijklmno");
  593. display.println("pqrstuvwxyz{|}~ ");
  594. }
  595. // note for partial update window and setPartialWindow() method:
  596. // partial update window size and position is on byte boundary in physical x direction
  597. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  598. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  599. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  600. void showPartialUpdate()
  601. {
  602. // some useful background
  603. helloWorld();
  604. // use asymmetric values for test
  605. uint16_t box_x = 10;
  606. uint16_t box_y = 15;
  607. uint16_t box_w = 70;
  608. uint16_t box_h = 20;
  609. uint16_t cursor_y = box_y + box_h - 6;
  610. if (display.epd2.WIDTH < 104) cursor_y = box_y + 6;
  611. float value = 13.95;
  612. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  613. display.setFont(&FreeMonoBold9pt7b);
  614. if (display.epd2.WIDTH < 104) display.setFont(0);
  615. display.setTextColor(GxEPD_BLACK);
  616. // show where the update box is
  617. for (uint16_t r = 0; r < 4; r++)
  618. {
  619. display.setRotation(r);
  620. display.setPartialWindow(box_x, box_y, box_w, box_h);
  621. display.firstPage();
  622. do
  623. {
  624. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  625. //display.fillScreen(GxEPD_BLACK);
  626. }
  627. while (display.nextPage());
  628. delay(2000);
  629. display.firstPage();
  630. do
  631. {
  632. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  633. }
  634. while (display.nextPage());
  635. delay(1000);
  636. }
  637. //return;
  638. // show updates in the update box
  639. for (uint16_t r = 0; r < 4; r++)
  640. {
  641. display.setRotation(r);
  642. display.setPartialWindow(box_x, box_y, box_w, box_h);
  643. for (uint16_t i = 1; i <= 10; i += incr)
  644. {
  645. display.firstPage();
  646. do
  647. {
  648. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  649. display.setCursor(box_x, cursor_y);
  650. display.print(value * i, 2);
  651. }
  652. while (display.nextPage());
  653. delay(500);
  654. }
  655. delay(1000);
  656. display.firstPage();
  657. do
  658. {
  659. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  660. }
  661. while (display.nextPage());
  662. delay(1000);
  663. }
  664. }
  665. void drawBitmaps()
  666. {
  667. display.setFullWindow();
  668. #ifdef _GxBitmaps80x128_H_
  669. drawBitmaps80x128();
  670. #endif
  671. #ifdef _GxBitmaps152x152_H_
  672. drawBitmaps152x152();
  673. #endif
  674. #ifdef _GxBitmaps104x212_H_
  675. drawBitmaps104x212();
  676. #endif
  677. #ifdef _GxBitmaps128x250_H_
  678. drawBitmaps128x250();
  679. #endif
  680. #ifdef _GxBitmaps128x296_H_
  681. drawBitmaps128x296();
  682. #endif
  683. #ifdef _GxBitmaps152x296_H_
  684. drawBitmaps152x296();
  685. #endif
  686. #ifdef _GxBitmaps176x264_H_
  687. drawBitmaps176x264();
  688. #endif
  689. #ifdef _GxBitmaps240x416_H_
  690. drawBitmaps240x416();
  691. #endif
  692. #ifdef _GxBitmaps400x300_H_
  693. drawBitmaps400x300();
  694. #endif
  695. #ifdef _GxBitmaps640x384_H_
  696. drawBitmaps640x384();
  697. #endif
  698. #ifdef _GxBitmaps648x480_H_
  699. drawBitmaps648x480();
  700. #endif
  701. #ifdef _GxBitmaps800x480_H_
  702. drawBitmaps800x480();
  703. #endif
  704. #ifdef _WS_Bitmaps800x600_H_
  705. drawBitmaps800x600();
  706. #endif
  707. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  708. drawBitmaps1304x984();
  709. #endif
  710. // 3-color
  711. #ifdef _GxBitmaps3c104x212_H_
  712. drawBitmaps3c104x212();
  713. #endif
  714. #ifdef _GxBitmaps3c128x250_H_
  715. drawBitmaps3c128x250();
  716. #endif
  717. #ifdef _GxBitmaps3c128x296_H_
  718. drawBitmaps3c128x296();
  719. #endif
  720. #ifdef _GxBitmaps3c152x296_H_
  721. drawBitmaps3c152x296();
  722. #endif
  723. #ifdef _GxBitmaps3c176x264_H_
  724. drawBitmaps3c176x264();
  725. #endif
  726. #ifdef _GxBitmaps3c400x300_H_
  727. drawBitmaps3c400x300();
  728. #endif
  729. #ifdef _GxBitmaps3c648x480_H_
  730. drawBitmaps3c648x480();
  731. #endif
  732. #ifdef _GxBitmaps3c800x480_H_
  733. drawBitmaps3c800x480();
  734. #endif
  735. #ifdef _GxBitmaps3c880x528_H_
  736. drawBitmaps3c880x528();
  737. #endif
  738. #if defined(_WS_Bitmaps4c168x168_H_)
  739. drawBitmaps4c168x168();
  740. #endif
  741. #if defined(_WS_Bitmaps7c192x143_H_)
  742. drawBitmaps7c192x143();
  743. #endif
  744. #if defined(_GxBitmaps7c800x480_H_)
  745. drawBitmaps7c800x480();
  746. #endif
  747. #if defined(_WS_Bitmaps7c300x180_H_)
  748. drawBitmaps7c300x180();
  749. #endif
  750. if ((display.epd2.WIDTH >= 200) && (display.epd2.HEIGHT >= 200))
  751. {
  752. // show these after the specific bitmaps
  753. #ifdef _GxBitmaps200x200_H_
  754. drawBitmaps200x200();
  755. #endif
  756. // 3-color
  757. #ifdef _GxBitmaps3c200x200_H_
  758. drawBitmaps3c200x200();
  759. #endif
  760. }
  761. #if defined(ESP32) && defined(_GxBitmaps3c1304x984_H_)
  762. drawBitmaps3c1304x984();
  763. #endif
  764. }
  765. #ifdef _GxBitmaps80x128_H_
  766. void drawBitmaps80x128()
  767. {
  768. #if !defined(__AVR)
  769. const unsigned char* bitmaps[] =
  770. {
  771. Bitmap80x128_1, Bitmap80x128_2, Bitmap80x128_3, Bitmap80x128_4, Bitmap80x128_5
  772. };
  773. #else
  774. const unsigned char* bitmaps[] =
  775. {
  776. Bitmap80x128_1, Bitmap80x128_2, Bitmap80x128_3, Bitmap80x128_4, Bitmap80x128_5
  777. };
  778. #endif
  779. if ((display.epd2.WIDTH == 80) && (display.epd2.HEIGHT == 128))
  780. {
  781. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  782. {
  783. display.firstPage();
  784. do
  785. {
  786. display.fillScreen(GxEPD_WHITE);
  787. display.drawInvertedBitmap(0, 0, bitmaps[i], 80, 128, GxEPD_BLACK);
  788. }
  789. while (display.nextPage());
  790. delay(2000);
  791. }
  792. display.firstPage();
  793. do
  794. {
  795. display.fillScreen(GxEPD_WHITE);
  796. display.drawBitmap(0, 0, WS_Bitmap80x128, 80, 128, GxEPD_BLACK);
  797. }
  798. while (display.nextPage());
  799. delay(2000);
  800. }
  801. }
  802. #endif
  803. #ifdef _GxBitmaps152x152_H_
  804. void drawBitmaps152x152()
  805. {
  806. #if !defined(__AVR)
  807. const unsigned char* bitmaps[] =
  808. {
  809. Bitmap152x152_1, Bitmap152x152_2, Bitmap152x152_3
  810. };
  811. #else
  812. const unsigned char* bitmaps[] =
  813. {
  814. Bitmap152x152_1, Bitmap152x152_2, Bitmap152x152_3
  815. };
  816. #endif
  817. if ((display.epd2.WIDTH == 152) && (display.epd2.HEIGHT == 152))
  818. {
  819. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  820. {
  821. display.firstPage();
  822. do
  823. {
  824. display.fillScreen(GxEPD_WHITE);
  825. display.drawInvertedBitmap(0, 0, bitmaps[i], 152, 152, GxEPD_BLACK);
  826. }
  827. while (display.nextPage());
  828. delay(2000);
  829. }
  830. }
  831. }
  832. #endif
  833. #ifdef _GxBitmaps200x200_H_
  834. void drawBitmaps200x200()
  835. {
  836. #if defined(ARDUINO_AVR_PRO)
  837. const unsigned char* bitmaps[] =
  838. {
  839. logo200x200
  840. };
  841. #elif defined(__AVR)
  842. const unsigned char* bitmaps[] =
  843. {
  844. logo200x200, //first200x200
  845. };
  846. #elif defined(_BOARD_GENERIC_STM32F103C_H_) || defined(STM32F1xx)
  847. const unsigned char* bitmaps[] =
  848. {
  849. logo200x200, first200x200, second200x200, third200x200, //fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  850. };
  851. #else
  852. const unsigned char* bitmaps[] =
  853. {
  854. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  855. //logo200x200, first200x200, second200x200, fourth200x200, third200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200 // ED037TC1 test
  856. };
  857. #endif
  858. if (display.epd2.hasColor) return; // to avoid many long refreshes
  859. if ((display.epd2.WIDTH == 200) && (display.epd2.HEIGHT == 200) && !display.epd2.hasColor)
  860. {
  861. bool m = display.mirror(true);
  862. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  863. {
  864. display.firstPage();
  865. do
  866. {
  867. display.fillScreen(GxEPD_WHITE);
  868. display.drawInvertedBitmap(0, 0, bitmaps[i], 200, 200, GxEPD_BLACK);
  869. }
  870. while (display.nextPage());
  871. delay(2000);
  872. }
  873. display.mirror(m);
  874. }
  875. //else
  876. {
  877. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  878. display.clearScreen(); // use default for white
  879. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  880. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  881. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  882. {
  883. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  884. delay(2000);
  885. }
  886. }
  887. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  888. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  889. {
  890. int16_t x = -60;
  891. int16_t y = -60;
  892. for (uint16_t j = 0; j < 10; j++)
  893. {
  894. display.writeScreenBuffer(); // use default for white
  895. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  896. display.refresh(true);
  897. if (display.epd2.hasFastPartialUpdate)
  898. {
  899. // for differential update: set previous buffer equal to current buffer in controller
  900. display.epd2.writeScreenBufferAgain(); // use default for white
  901. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  902. }
  903. delay(2000);
  904. x += display.epd2.WIDTH / 4;
  905. y += display.epd2.HEIGHT / 4;
  906. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  907. }
  908. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  909. break; // comment out for full show
  910. }
  911. display.writeScreenBuffer(); // use default for white
  912. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  913. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  914. display.refresh(true);
  915. // for differential update: set previous buffer equal to current buffer in controller
  916. display.epd2.writeScreenBufferAgain(); // use default for white
  917. display.epd2.writeImageAgain(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  918. display.epd2.writeImageAgain(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  919. delay(2000);
  920. }
  921. #endif
  922. #ifdef _GxBitmaps104x212_H_
  923. void drawBitmaps104x212()
  924. {
  925. #if !defined(__AVR)
  926. const unsigned char* bitmaps[] =
  927. {
  928. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  929. };
  930. #else
  931. const unsigned char* bitmaps[] =
  932. {
  933. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  934. };
  935. #endif
  936. if ((display.epd2.WIDTH == 104) && (display.epd2.HEIGHT == 212) && !display.epd2.hasColor)
  937. {
  938. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  939. {
  940. display.firstPage();
  941. do
  942. {
  943. display.fillScreen(GxEPD_WHITE);
  944. display.drawBitmap(0, 0, bitmaps[i], 104, 212, GxEPD_BLACK);
  945. }
  946. while (display.nextPage());
  947. delay(2000);
  948. }
  949. }
  950. }
  951. #endif
  952. #ifdef _GxBitmaps128x250_H_
  953. void drawBitmaps128x250()
  954. {
  955. #if !defined(__AVR)
  956. const unsigned char* bitmaps[] =
  957. {
  958. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  959. };
  960. #else
  961. const unsigned char* bitmaps[] =
  962. {
  963. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  964. };
  965. #endif
  966. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 250) && !display.epd2.hasColor)
  967. {
  968. bool m = display.mirror(true);
  969. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  970. {
  971. display.firstPage();
  972. do
  973. {
  974. display.fillScreen(GxEPD_WHITE);
  975. display.drawInvertedBitmap(0, 0, bitmaps[i], 128, 250, GxEPD_BLACK);
  976. }
  977. while (display.nextPage());
  978. delay(2000);
  979. }
  980. display.mirror(m);
  981. }
  982. }
  983. #endif
  984. #ifdef _GxBitmaps128x296_H_
  985. void drawBitmaps128x296()
  986. {
  987. #if !defined(__AVR)
  988. const unsigned char* bitmaps[] =
  989. {
  990. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  991. };
  992. #else
  993. const unsigned char* bitmaps[] =
  994. {
  995. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  996. };
  997. #endif
  998. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 296) && !display.epd2.hasColor)
  999. {
  1000. bool m = display.mirror(true);
  1001. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1002. {
  1003. display.firstPage();
  1004. do
  1005. {
  1006. display.fillScreen(GxEPD_WHITE);
  1007. display.drawInvertedBitmap(0, 0, bitmaps[i], 128, 296, GxEPD_BLACK);
  1008. }
  1009. while (display.nextPage());
  1010. delay(2000);
  1011. }
  1012. display.mirror(m);
  1013. }
  1014. }
  1015. #endif
  1016. #ifdef _GxBitmaps152x296_H_
  1017. void drawBitmaps152x296()
  1018. {
  1019. #if !defined(__AVR)
  1020. const unsigned char* bitmaps[] =
  1021. {
  1022. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  1023. };
  1024. #else
  1025. const unsigned char* bitmaps[] =
  1026. {
  1027. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  1028. };
  1029. #endif
  1030. if ((display.epd2.WIDTH == 152) && (display.epd2.HEIGHT == 296) && !display.epd2.hasColor)
  1031. {
  1032. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1033. {
  1034. display.firstPage();
  1035. do
  1036. {
  1037. display.fillScreen(GxEPD_WHITE);
  1038. display.drawInvertedBitmap(0, 0, bitmaps[i], 152, 296, GxEPD_BLACK);
  1039. }
  1040. while (display.nextPage());
  1041. delay(2000);
  1042. }
  1043. }
  1044. }
  1045. #endif
  1046. #ifdef _GxBitmaps176x264_H_
  1047. void drawBitmaps176x264()
  1048. {
  1049. #if !defined(__AVR)
  1050. const unsigned char* bitmaps[] =
  1051. {
  1052. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1053. };
  1054. #else
  1055. const unsigned char* bitmaps[] =
  1056. {
  1057. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1058. };
  1059. #endif
  1060. if ((display.epd2.WIDTH == 176) && (display.epd2.HEIGHT == 264) && !display.epd2.hasColor)
  1061. {
  1062. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1063. {
  1064. display.firstPage();
  1065. do
  1066. {
  1067. display.fillScreen(GxEPD_WHITE);
  1068. display.drawInvertedBitmap(0, 0, bitmaps[i], 176, 264, GxEPD_BLACK);
  1069. }
  1070. while (display.nextPage());
  1071. delay(2000);
  1072. }
  1073. }
  1074. }
  1075. #endif
  1076. #ifdef _GxBitmaps240x416_H_
  1077. void drawBitmaps240x416()
  1078. {
  1079. #if !defined(__AVR)
  1080. const unsigned char* bitmaps[] =
  1081. {
  1082. Bitmap240x416_1, Bitmap240x416_2, Bitmap240x416_3
  1083. };
  1084. #else
  1085. const unsigned char* bitmaps[] =
  1086. {
  1087. Bitmap240x460_1, Bitmap240x460_2, Bitmap240x460_3
  1088. };
  1089. #endif
  1090. if ((display.epd2.WIDTH == 240) && (display.epd2.HEIGHT == 416) && !display.epd2.hasColor)
  1091. {
  1092. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1093. {
  1094. display.firstPage();
  1095. do
  1096. {
  1097. display.fillScreen(GxEPD_WHITE);
  1098. display.drawInvertedBitmap(0, 0, bitmaps[i], 240, 416, GxEPD_BLACK);
  1099. }
  1100. while (display.nextPage());
  1101. delay(2000);
  1102. }
  1103. }
  1104. }
  1105. #endif
  1106. #ifdef _GxBitmaps400x300_H_
  1107. void drawBitmaps400x300()
  1108. {
  1109. #if !defined(__AVR)
  1110. const unsigned char* bitmaps[] =
  1111. {
  1112. Bitmap400x300_1, Bitmap400x300_2
  1113. };
  1114. #else
  1115. const unsigned char* bitmaps[] = {}; // not enough code space
  1116. #endif
  1117. if ((display.epd2.WIDTH == 400) && (display.epd2.HEIGHT == 300) && !display.epd2.hasColor)
  1118. {
  1119. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1120. {
  1121. display.firstPage();
  1122. do
  1123. {
  1124. display.fillScreen(GxEPD_WHITE);
  1125. display.drawInvertedBitmap(0, 0, bitmaps[i], 400, 300, GxEPD_BLACK);
  1126. }
  1127. while (display.nextPage());
  1128. delay(2000);
  1129. }
  1130. }
  1131. }
  1132. #endif
  1133. #ifdef _GxBitmaps640x384_H_
  1134. void drawBitmaps640x384()
  1135. {
  1136. #if !defined(__AVR)
  1137. const unsigned char* bitmaps[] =
  1138. {
  1139. Bitmap640x384_1, Bitmap640x384_2
  1140. };
  1141. #else
  1142. const unsigned char* bitmaps[] = {}; // not enough code space
  1143. #endif
  1144. if ((display.epd2.WIDTH == 640) && (display.epd2.HEIGHT == 384))
  1145. {
  1146. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1147. {
  1148. display.firstPage();
  1149. do
  1150. {
  1151. display.fillScreen(GxEPD_WHITE);
  1152. display.drawInvertedBitmap(0, 0, bitmaps[i], 640, 384, GxEPD_BLACK);
  1153. }
  1154. while (display.nextPage());
  1155. delay(2000);
  1156. }
  1157. }
  1158. }
  1159. #endif
  1160. #ifdef _GxBitmaps648x480_H_
  1161. void drawBitmaps648x480()
  1162. {
  1163. #if !defined(__AVR)
  1164. const unsigned char* bitmaps[] =
  1165. {
  1166. Bitmap648x480_1, Bitmap648x480_2, Bitmap648x480_3
  1167. };
  1168. #else
  1169. const unsigned char* bitmaps[] = {}; // not enough code space
  1170. #endif
  1171. if ((display.epd2.WIDTH == 648) && (display.epd2.HEIGHT == 480) && !display.epd2.hasColor)
  1172. {
  1173. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1174. {
  1175. display.firstPage();
  1176. do
  1177. {
  1178. display.fillScreen(GxEPD_WHITE);
  1179. display.drawBitmap(0, 0, bitmaps[i], 648, 480, GxEPD_BLACK);
  1180. }
  1181. while (display.nextPage());
  1182. delay(2000);
  1183. }
  1184. }
  1185. }
  1186. #endif
  1187. #ifdef _GxBitmaps800x480_H_
  1188. void drawBitmaps800x480()
  1189. {
  1190. #if !defined(__AVR)
  1191. const unsigned char* bitmaps[] =
  1192. {
  1193. Bitmap800x480_1, Bitmap800x480_2, Bitmap800x480_3, Bitmap800x480_4
  1194. };
  1195. #else
  1196. const unsigned char* bitmaps[] = {}; // not enough code space
  1197. #endif
  1198. if ((display.epd2.WIDTH == 800) && (display.epd2.HEIGHT == 480))
  1199. {
  1200. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1201. {
  1202. display.firstPage();
  1203. do
  1204. {
  1205. display.fillScreen(GxEPD_WHITE);
  1206. display.drawBitmap(0, 0, bitmaps[i], 800, 480, GxEPD_BLACK);
  1207. }
  1208. while (display.nextPage());
  1209. delay(2000);
  1210. }
  1211. if ((display.epd2.panel == GxEPD2::GDEW075T7) || (display.epd2.panel == GxEPD2::GDEY075T7))
  1212. {
  1213. // avoid ghosting caused by OTP waveform
  1214. display.clearScreen();
  1215. display.refresh(false); // full update
  1216. }
  1217. }
  1218. }
  1219. #endif
  1220. #ifdef _WS_Bitmaps800x600_H_
  1221. void drawBitmaps800x600()
  1222. {
  1223. #if defined(ESP8266) || defined(ESP32)
  1224. if ((display.epd2.panel == GxEPD2::ED060SCT) || (display.epd2.panel == GxEPD2::ED060KC1) || (display.epd2.panel == GxEPD2::ED078KC2))
  1225. {
  1226. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  1227. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  1228. delay(2000);
  1229. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  1230. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  1231. // delay(2000);
  1232. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  1233. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  1234. // delay(2000);
  1235. }
  1236. #endif
  1237. }
  1238. #endif
  1239. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  1240. void drawBitmaps1304x984()
  1241. {
  1242. if (display.epd2.panel == GxEPD2::GDEW1248T3)
  1243. {
  1244. display.drawImage(Bitmap1304x984, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1245. }
  1246. }
  1247. #endif
  1248. struct bitmap_pair
  1249. {
  1250. const unsigned char* black;
  1251. const unsigned char* red;
  1252. };
  1253. #ifdef _GxBitmaps3c200x200_H_
  1254. void drawBitmaps3c200x200()
  1255. {
  1256. bitmap_pair bitmap_pairs[] =
  1257. {
  1258. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  1259. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  1260. };
  1261. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  1262. {
  1263. display.firstPage();
  1264. do
  1265. {
  1266. display.fillScreen(GxEPD_WHITE);
  1267. // Bitmap3c200x200_black has 2 bits per pixel
  1268. // taken from Adafruit_GFX.cpp, modified
  1269. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  1270. uint8_t byte = 0;
  1271. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  1272. {
  1273. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  1274. {
  1275. if (i & 3) byte <<= 2;
  1276. else
  1277. {
  1278. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  1279. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  1280. #else
  1281. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  1282. #endif
  1283. }
  1284. if (!(byte & 0x80))
  1285. {
  1286. display.drawPixel(i, j, GxEPD_BLACK);
  1287. }
  1288. }
  1289. }
  1290. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1291. }
  1292. while (display.nextPage());
  1293. delay(2000);
  1294. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1295. {
  1296. display.firstPage();
  1297. do
  1298. {
  1299. display.fillScreen(GxEPD_WHITE);
  1300. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1301. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1302. }
  1303. while (display.nextPage());
  1304. delay(2000);
  1305. }
  1306. }
  1307. if (display.epd2.hasColor)
  1308. {
  1309. display.clearScreen(); // use default for white
  1310. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  1311. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  1312. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1313. {
  1314. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1315. delay(2000);
  1316. }
  1317. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1318. {
  1319. int16_t x = -60;
  1320. int16_t y = -60;
  1321. for (uint16_t j = 0; j < 10; j++)
  1322. {
  1323. display.writeScreenBuffer(); // use default for white
  1324. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1325. display.refresh();
  1326. delay(1000);
  1327. x += display.epd2.WIDTH / 4;
  1328. y += display.epd2.HEIGHT / 4;
  1329. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1330. }
  1331. }
  1332. display.writeScreenBuffer(); // use default for white
  1333. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  1334. 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);
  1335. display.refresh();
  1336. delay(2000);
  1337. }
  1338. }
  1339. #endif
  1340. #ifdef _GxBitmaps3c104x212_H_
  1341. void drawBitmaps3c104x212()
  1342. {
  1343. #if !defined(__AVR)
  1344. bitmap_pair bitmap_pairs[] =
  1345. {
  1346. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1347. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1348. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1349. };
  1350. #else
  1351. bitmap_pair bitmap_pairs[] =
  1352. {
  1353. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1354. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1355. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1356. };
  1357. #endif
  1358. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1359. {
  1360. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1361. {
  1362. display.firstPage();
  1363. do
  1364. {
  1365. display.fillScreen(GxEPD_WHITE);
  1366. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1367. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1368. {
  1369. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1370. }
  1371. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1372. }
  1373. while (display.nextPage());
  1374. delay(2000);
  1375. }
  1376. }
  1377. }
  1378. #endif
  1379. #ifdef _GxBitmaps3c128x250_H_
  1380. void drawBitmaps3c128x250()
  1381. {
  1382. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 250) && display.epd2.hasColor)
  1383. {
  1384. bool mirrored = display.mirror(true);
  1385. display.firstPage();
  1386. do
  1387. {
  1388. display.fillScreen(GxEPD_WHITE);
  1389. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_1_black, 128, 250, GxEPD_BLACK);
  1390. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_1_red, 128, 250, GxEPD_RED);
  1391. }
  1392. while (display.nextPage());
  1393. delay(2000);
  1394. #if !defined(__AVR)
  1395. display.firstPage();
  1396. do
  1397. {
  1398. display.fillScreen(GxEPD_WHITE);
  1399. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_2_black, 128, 250, GxEPD_BLACK);
  1400. display.drawBitmap(0, 0, Bitmap3c128x250_2_red, 128, 250, GxEPD_RED);
  1401. }
  1402. while (display.nextPage());
  1403. delay(2000);
  1404. #endif
  1405. display.mirror(mirrored);
  1406. }
  1407. }
  1408. #endif
  1409. #ifdef _GxBitmaps3c128x296_H_
  1410. void drawBitmaps3c128x296()
  1411. {
  1412. #if !defined(__AVR)
  1413. bitmap_pair bitmap_pairs[] =
  1414. {
  1415. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1416. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1417. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1418. };
  1419. #else
  1420. bitmap_pair bitmap_pairs[] =
  1421. {
  1422. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1423. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1424. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1425. };
  1426. #endif
  1427. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 296) && display.epd2.hasColor)
  1428. {
  1429. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1430. {
  1431. display.firstPage();
  1432. do
  1433. {
  1434. display.fillScreen(GxEPD_WHITE);
  1435. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, 128, 296, GxEPD_BLACK);
  1436. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1437. {
  1438. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 128, 296, GxEPD_RED);
  1439. }
  1440. else display.drawBitmap(0, 0, bitmap_pairs[i].red, 128, 296, GxEPD_RED);
  1441. }
  1442. while (display.nextPage());
  1443. delay(2000);
  1444. }
  1445. }
  1446. }
  1447. #endif
  1448. #ifdef _GxBitmaps3c152x296_H_
  1449. void drawBitmaps3c152x296()
  1450. {
  1451. bitmap_pair bitmap_pairs[] =
  1452. {
  1453. {Bitmap3c152x296_black, Bitmap3c152x296_red}
  1454. };
  1455. if (display.epd2.panel == GxEPD2::GDEY0266Z90)
  1456. {
  1457. bool mirrored = display.mirror(true);
  1458. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1459. {
  1460. display.firstPage();
  1461. do
  1462. {
  1463. display.fillScreen(GxEPD_WHITE);
  1464. display.drawBitmap(0, 0, bitmap_pairs[i].black, 152, 296, GxEPD_BLACK);
  1465. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 152, 296, GxEPD_RED);
  1466. }
  1467. while (display.nextPage());
  1468. delay(2000);
  1469. }
  1470. display.mirror(mirrored);
  1471. }
  1472. }
  1473. #endif
  1474. #ifdef _GxBitmaps3c176x264_H_
  1475. void drawBitmaps3c176x264()
  1476. {
  1477. bitmap_pair bitmap_pairs[] =
  1478. {
  1479. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1480. };
  1481. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1482. {
  1483. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1484. {
  1485. display.firstPage();
  1486. do
  1487. {
  1488. display.fillScreen(GxEPD_WHITE);
  1489. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1490. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1491. }
  1492. while (display.nextPage());
  1493. delay(2000);
  1494. }
  1495. }
  1496. }
  1497. #endif
  1498. #ifdef _GxBitmaps3c400x300_H_
  1499. void drawBitmaps3c400x300()
  1500. {
  1501. #if !defined(__AVR)
  1502. bitmap_pair bitmap_pairs[] =
  1503. {
  1504. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1505. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1506. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1507. };
  1508. #else
  1509. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1510. #endif
  1511. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1512. {
  1513. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1514. {
  1515. display.firstPage();
  1516. do
  1517. {
  1518. display.fillScreen(GxEPD_WHITE);
  1519. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1520. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1521. }
  1522. while (display.nextPage());
  1523. delay(2000);
  1524. }
  1525. }
  1526. }
  1527. #endif
  1528. #ifdef _GxBitmaps3c648x480_H_
  1529. void drawBitmaps3c648x480()
  1530. {
  1531. #if !defined(__AVR)
  1532. bitmap_pair bitmap_pairs[] =
  1533. {
  1534. {Bitmap3c648x480_black, Bitmap3c648x480_red}
  1535. };
  1536. #else
  1537. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1538. #endif
  1539. if (display.epd2.panel == GxEPD2::GDEW0583Z83)
  1540. {
  1541. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1542. {
  1543. display.firstPage();
  1544. do
  1545. {
  1546. display.fillScreen(GxEPD_WHITE);
  1547. display.drawBitmap(0, 0, bitmap_pairs[i].black, 648, 480, GxEPD_BLACK);
  1548. display.drawBitmap(0, 0, bitmap_pairs[i].red, 648, 480, GxEPD_RED);
  1549. }
  1550. while (display.nextPage());
  1551. delay(2000);
  1552. }
  1553. }
  1554. }
  1555. #endif
  1556. #ifdef _GxBitmaps3c800x480_H_
  1557. void drawBitmaps3c800x480()
  1558. {
  1559. #if !defined(__AVR)
  1560. bitmap_pair bitmap_pairs[] =
  1561. {
  1562. {Bitmap3c800x480_1_black, Bitmap3c800x480_1_red}
  1563. };
  1564. #else
  1565. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1566. #endif
  1567. if (display.epd2.panel == GxEPD2::GDEW075Z08)
  1568. {
  1569. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1570. {
  1571. display.firstPage();
  1572. do
  1573. {
  1574. display.fillScreen(GxEPD_WHITE);
  1575. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1576. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1577. }
  1578. while (display.nextPage());
  1579. delay(2000);
  1580. }
  1581. }
  1582. }
  1583. #endif
  1584. #ifdef _GxBitmaps3c880x528_H_
  1585. void drawBitmaps3c880x528()
  1586. {
  1587. #if !defined(__AVR)
  1588. bitmap_pair bitmap_pairs[] =
  1589. {
  1590. {Bitmap3c880x528_black, Bitmap3c880x528_red}
  1591. };
  1592. #else
  1593. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1594. #endif
  1595. if (display.epd2.panel == GxEPD2::GDEH075Z90)
  1596. {
  1597. bool m = display.mirror(true);
  1598. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1599. {
  1600. display.firstPage();
  1601. do
  1602. {
  1603. display.fillScreen(GxEPD_WHITE);
  1604. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, 880, 528, GxEPD_BLACK);
  1605. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 880, 528, GxEPD_RED);
  1606. }
  1607. while (display.nextPage());
  1608. delay(2000);
  1609. }
  1610. display.mirror(m);
  1611. }
  1612. }
  1613. #endif
  1614. #if defined(ESP32) && defined(_GxBitmaps3c1304x984_H_)
  1615. void drawBitmaps3c1304x984()
  1616. {
  1617. if (display.epd2.panel == GxEPD2::GDEY1248Z51)
  1618. {
  1619. //display.drawImage(Bitmap3c1304x984_black, Bitmap3c1304x984_red, 0, 0, 1304, 984, false, false, true);
  1620. display.writeImage(0, Bitmap3c1304x984_red, 0, 0, 1304, 984, true, false, true); // red bitmap is inverted
  1621. display.drawImage(Bitmap3c1304x984_black, 0, 0, 0, 1304, 984, true, false, true); // black bitmap is normal
  1622. }
  1623. }
  1624. #endif
  1625. #if defined(_WS_Bitmaps4c168x168_H_)
  1626. void drawBitmaps4c168x168()
  1627. {
  1628. if (display.epd2.panel == GxEPD2::Waveshare437inch4color)
  1629. {
  1630. display.drawNative(WS_Bitmap4c168x168, 0, (display.epd2.WIDTH - 168) / 2, (display.epd2.HEIGHT - 168) / 2, 168, 168, false, false, true);
  1631. delay(5000);
  1632. }
  1633. }
  1634. #endif
  1635. #if defined(_WS_Bitmaps7c192x143_H_)
  1636. void drawBitmaps7c192x143()
  1637. {
  1638. if (display.epd2.panel == GxEPD2::ACeP565)
  1639. {
  1640. display.drawNative(WS_Bitmap7c192x143, 0, (display.epd2.WIDTH - 192) / 2, (display.epd2.HEIGHT - 143) / 2, 192, 143, false, false, true);
  1641. delay(5000);
  1642. }
  1643. }
  1644. #endif
  1645. #if defined(_GxBitmaps7c800x480_H_)
  1646. void drawBitmaps7c800x480()
  1647. {
  1648. if (display.epd2.panel == GxEPD2::GDEY073D46)
  1649. {
  1650. display.epd2.drawDemoBitmap(Bitmap7c800x480, 0, 0, 0, 800, 480, 0, false, true); // special format
  1651. delay(5000);
  1652. }
  1653. }
  1654. #endif
  1655. #if defined(_WS_Bitmaps7c300x180_H_)
  1656. void drawBitmaps7c300x180()
  1657. {
  1658. if (display.epd2.panel == GxEPD2::GDEY073D46)
  1659. {
  1660. display.drawNative(WS_Bitmap7c300x180, 0, (display.epd2.WIDTH - 300) / 2, (display.epd2.HEIGHT - 180) / 2, 300, 180, false, false, true);
  1661. delay(5000);
  1662. }
  1663. }
  1664. #endif
  1665. void draw7colors()
  1666. {
  1667. display.setRotation(0);
  1668. uint16_t h = display.height() / 7;
  1669. display.firstPage();
  1670. do
  1671. {
  1672. display.fillRect(0, 0, display.width(), h, GxEPD_BLACK);
  1673. display.fillRect(0, h, display.width(), h, GxEPD_WHITE);
  1674. display.fillRect(0, 2 * h, display.width(), h, GxEPD_GREEN);
  1675. display.fillRect(0, 3 * h, display.width(), h, GxEPD_BLUE);
  1676. display.fillRect(0, 4 * h, display.width(), h, GxEPD_RED);
  1677. display.fillRect(0, 5 * h, display.width(), h, GxEPD_YELLOW);
  1678. display.fillRect(0, 6 * h, display.width(), h, GxEPD_ORANGE);
  1679. }
  1680. while (display.nextPage());
  1681. }
  1682. void draw7colorlines()
  1683. {
  1684. display.setRotation(0);
  1685. uint16_t h = 2;
  1686. display.firstPage();
  1687. do
  1688. {
  1689. uint16_t y = 0;
  1690. do
  1691. {
  1692. display.fillRect(0, y, display.width(), h, GxEPD_BLACK); y += h;
  1693. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1694. display.fillRect(0, y, display.width(), h, GxEPD_GREEN); y += h;
  1695. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1696. display.fillRect(0, y, display.width(), h, GxEPD_BLUE); y += h;
  1697. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1698. display.fillRect(0, y, display.width(), h, GxEPD_RED); y += h;
  1699. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1700. display.fillRect(0, y, display.width(), h, GxEPD_YELLOW); y += h;
  1701. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1702. display.fillRect(0, y, display.width(), h, GxEPD_ORANGE); y += h;
  1703. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1704. }
  1705. while ((y + 12 * h) < uint16_t(display.height()));
  1706. //display.drawPixel(0, y, GxEPD_BLACK); display.drawPixel(10, y, GxEPD_GREEN);
  1707. //display.drawPixel(20, y, GxEPD_BLUE); display.drawPixel(30, y, GxEPD_RED);
  1708. //display.drawPixel(40, y, GxEPD_YELLOW); display.drawPixel(50, y, GxEPD_ORANGE);
  1709. display.fillRect(0, y, 2, 2, GxEPD_BLACK); display.fillRect(10, y, 2, 2, GxEPD_GREEN);
  1710. display.fillRect(20, y, 2, 2, GxEPD_BLUE); display.fillRect(30, y, 2, 2, GxEPD_RED);
  1711. display.fillRect(40, y, 2, 2, GxEPD_YELLOW); display.fillRect(50, y, 2, 2, GxEPD_ORANGE);
  1712. }
  1713. while (display.nextPage());
  1714. }
  1715. void drawGraphics()
  1716. {
  1717. display.setRotation(0);
  1718. display.firstPage();
  1719. do
  1720. {
  1721. display.drawRect(display.width() / 8, display.height() / 8, display.width() * 3 / 4, display.height() * 3 / 4, GxEPD_BLACK);
  1722. display.drawLine(display.width() / 8, display.height() / 8, display.width() * 7 / 8, display.height() * 7 / 8, GxEPD_BLACK);
  1723. display.drawLine(display.width() / 8, display.height() * 7 / 8, display.width() *7 / 8, display.height() / 8, GxEPD_BLACK);
  1724. display.drawCircle(display.width() / 2, display.height() / 2, display.height() / 4, GxEPD_BLACK);
  1725. display.drawPixel(display.width() / 4, display.height() / 2 , GxEPD_BLACK);
  1726. display.drawPixel(display.width() * 3 / 4, display.height() / 2 , GxEPD_BLACK);
  1727. }
  1728. while (display.nextPage());
  1729. }