GxEPD2_Example.ino 63 KB

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