GxEPD2_Example.ino 62 KB

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