GxEPD2_Example.ino 61 KB

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