GxEPD2_Example.ino 77 KB

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