GxEPD2_Example.ino 62 KB

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