GxEPD2_WS_ESP32_Driver.ino 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  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. // GxEPD2_WS_ESP32_Driver : GxEPD2_Example variant for Universal e-Paper Raw Panel Driver Board, ESP32 WiFi / Bluetooth Wireless
  12. // https://www.waveshare.com/product/e-paper-esp32-driver-board.htm
  13. // Supporting Arduino Forum Topics (closed, read only):
  14. // Good Display ePaper for Arduino: https://forum.arduino.cc/t/good-display-epaper-for-arduino/419657
  15. // Waveshare e-paper displays with SPI: https://forum.arduino.cc/t/waveshare-e-paper-displays-with-spi/467865
  16. //
  17. // Add new topics in https://forum.arduino.cc/c/using-arduino/displays/23 for new questions and issues
  18. // mapping of Waveshare ESP32 Driver Board
  19. // BUSY -> 25, RST -> 26, DC -> 27, CS-> 15, CLK -> 13, DIN -> 14
  20. // NOTE: this board uses "unusual" SPI pins and requires re-mapping of HW SPI to these pins in SPIClass
  21. // this example shows how this can be done easily, updated for use with HSPI
  22. //
  23. // The Wavehare ESP32 Driver Board uses uncommon SPI pins for the FPC connector. It uses HSPI pins, but SCK and MOSI are swapped.
  24. // 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.
  25. // 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.
  26. // The logical configuration would be to use the e-paper connection on HSPI with re-mapped pins, and use VSPI for other SPI clients.
  27. // VSPI with standard VSPI pins is used by the global SPI instance of the Arduino IDE ESP32 package.
  28. // uncomment next line to use HSPI for EPD (and VSPI for SD), e.g. with Waveshare ESP32 Driver Board
  29. #define USE_HSPI_FOR_EPD
  30. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  31. // enable or disable GxEPD2_GFX base class
  32. #define ENABLE_GxEPD2_GFX 0
  33. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  34. //#include <GFX.h>
  35. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  36. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  37. #include <GxEPD2_BW.h>
  38. #include <GxEPD2_3C.h>
  39. #include <GxEPD2_4C.h>
  40. #include <GxEPD2_7C.h>
  41. #include <Fonts/FreeMonoBold9pt7b.h>
  42. // select the display class (only one), matching the kind of display panel
  43. #define GxEPD2_DISPLAY_CLASS GxEPD2_BW
  44. //#define GxEPD2_DISPLAY_CLASS GxEPD2_3C
  45. //#define GxEPD2_DISPLAY_CLASS GxEPD2_4C
  46. //#define GxEPD2_DISPLAY_CLASS GxEPD2_7C
  47. // select the display driver class (only one) for your panel
  48. //#define GxEPD2_DRIVER_CLASS GxEPD2_102 // GDEW0102T4 80x128, UC8175, (WFT0102CZA2)
  49. //#define GxEPD2_DRIVER_CLASS GxEPD2_150_BN // DEPG0150BN 200x200, SSD1681, (FPC8101), TTGO T5 V2.4.1
  50. //#define GxEPD2_DRIVER_CLASS GxEPD2_154 // GDEP015OC1 200x200, IL3829, (WFC0000CZ07), no longer available
  51. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_D67 // GDEH0154D67 200x200, SSD1681, (HINK-E154A07-A1)
  52. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_T8 // GDEW0154T8 152x152, UC8151 (IL0373), (WFT0154CZ17)
  53. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_M09 // GDEW0154M09 200x200, JD79653A, (WFT0154CZB3)
  54. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_M10 // GDEW0154M10 152x152, UC8151D, (WFT0154CZ17)
  55. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_GDEY0154D67 // GDEY0154D67 200x200, SSD1681, (FPC-B001 20.05.21)
  56. //#define GxEPD2_DRIVER_CLASS GxEPD2_213 // GDE0213B1 122x250, IL3895, (HINK-E0213-G01), phased out
  57. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_B72 // GDEH0213B72 122x250, SSD1675A (IL3897), (HINK-E0213A22-A0 SLH1852)
  58. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_B73 // GDEH0213B73 122x250, SSD1675B, (HINK-E0213A22-A0 SLH1914)
  59. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_B74 // GDEM0213B74 122x250, SSD1680, FPC-7528B)
  60. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_flex // GDEW0213I5F 104x212, UC8151 (IL0373), (WFT0213CZ16)
  61. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_M21 // GDEW0213M21 104x212, UC8151 (IL0373), (WFT0213CZ16)
  62. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_T5D // GDEW0213T5D 104x212, UC8151D, (WFT0213CZ16)
  63. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_BN // DEPG0213BN 122x250, SSD1680, (FPC-7528B), TTGO T5 V2.4.1, V2.3.1
  64. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_GDEY0213B74 // GDEY0213B74 122x250, SSD1680, (FPC-A002 20.04.08)
  65. //#define GxEPD2_DRIVER_CLASS GxEPD2_260 // GDEW026T0 152x296, UC8151 (IL0373), (WFT0154CZ17)
  66. //#define GxEPD2_DRIVER_CLASS GxEPD2_260_M01 // GDEW026M01 152x296, UC8151 (IL0373), (WFT0260CZB2)
  67. //#define GxEPD2_DRIVER_CLASS GxEPD2_266_BN // DEPG0266BN 152x296, SSD1680, (FPC7510), TTGO T5 V2.66, TTGO T5 V2.4.1
  68. //#define GxEPD2_DRIVER_CLASS GxEPD2_266_GDEY0266T90 // GDEY0266T90 152x296, SSD1680, (FPC-A003 HB)
  69. //#define GxEPD2_DRIVER_CLASS GxEPD2_270 // GDEW027W3 176x264, EK79652 (IL91874), (WFI0190CZ22)
  70. //#define GxEPD2_DRIVER_CLASS GxEPD2_270_GDEY027T91 // GDEY027T91 176x264, SSD1680, (FB)
  71. //#define GxEPD2_DRIVER_CLASS GxEPD2_290 // GDEH029A1 128x296, SSD1608 (IL3820), (E029A01-FPC-A1 SYX1553)
  72. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T5 // GDEW029T5 128x296, UC8151 (IL0373), (WFT0290CZ10)
  73. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T5D // GDEW029T5D 128x296, UC8151D, (WFT0290CZ10)
  74. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_I6FD // GDEW029I6FD 128x296, UC8151D, (WFT0290CZ10)
  75. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T94 // GDEM029T94 128x296, SSD1680, (FPC-7519 rev.b)
  76. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T94_V2 // GDEM029T94 128x296, SSD1680, (FPC-7519 rev.b), Waveshare 2.9" V2 variant
  77. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_BS // DEPG0290BS 128x296, SSD1680, (FPC-7519 rev.b)
  78. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_M06 // GDEW029M06 128x296, UC8151D, (WFT0290CZ10)
  79. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_GDEY029T94 // GDEY029T94 128x296, SSD1680, (FPC-A005 20.06.15)
  80. //#define GxEPD2_DRIVER_CLASS GxEPD2_310_GDEQ031T10 // GDEQ031T10 240x320, UC8253, (no inking, backside mark KEGMO 3100)
  81. //#define GxEPD2_DRIVER_CLASS GxEPD2_371 // GDEW0371W7 240x416, UC8171 (IL0324), (missing)
  82. //#define GxEPD2_DRIVER_CLASS GxEPD2_370_TC1 // ED037TC1 280x480, SSD1677, (ICA-FU-20 ichia 2029), Waveshare 3.7"
  83. //#define GxEPD2_DRIVER_CLASS GxEPD2_420 // GDEW042T2 400x300, UC8176 (IL0398), (WFT042CZ15)
  84. //#define GxEPD2_DRIVER_CLASS GxEPD2_420_M01 // GDEW042M01 400x300, UC8176 (IL0398), (WFT042CZ15)
  85. //#define GxEPD2_DRIVER_CLASS GxEPD2_420_GDEY042T81 // GDEY042T81 400x300, SSD1683 (no inking)
  86. //#define GxEPD2_DRIVER_CLASS GxEPD2_426_GDEQ0426T82 // GDEQ0426T82 480x800, SSD1677 (P426010-MF1-A)
  87. //#define GxEPD2_DRIVER_CLASS GxEPD2_583 // GDEW0583T7 600x448, UC8159c (IL0371), (missing)
  88. //#define GxEPD2_DRIVER_CLASS GxEPD2_583_T8 // GDEW0583T8 648x480, EK79655 (GD7965), (WFT0583CZ61)
  89. //#define GxEPD2_DRIVER_CLASS GxEPD2_583_GDEQ0583T31 // GDEQ0583T31 648x480, UC8179, (P583010-MF1-B)
  90. //#define GxEPD2_DRIVER_CLASS GxEPD2_750 // GDEW075T8 640x384, UC8159c (IL0371), (WF0583CZ09)
  91. //#define GxEPD2_DRIVER_CLASS GxEPD2_750_T7 // GDEW075T7 800x480, EK79655 (GD7965), (WFT0583CZ61)
  92. //#define GxEPD2_DRIVER_CLASS GxEPD2_750_GDEY075T7 // GDEY075T7 800x480, UC8179 (GD7965), (FPC-C001 20.08.20)
  93. //#define GxEPD2_DRIVER_CLASS GxEPD2_1160_T91 // GDEH116T91 960x640, SSD1677, (none or hidden)
  94. //#define GxEPD2_DRIVER_CLASS GxEPD2_1248 // GDEW1248T3 1304x984, UC8179, (WFT1248BZ23,WFT1248BZ24)
  95. // 3-color e-papers
  96. //#define GxEPD2_DRIVER_CLASS GxEPD2_154c // GDEW0154Z04 200x200, IL0376F, (WFT0000CZ04), no longer available
  97. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_Z90c // GDEH0154Z90 200x200, SSD1681, (HINK-E154A07-A1)
  98. //#define GxEPD2_DRIVER_CLASS GxEPD2_213c // GDEW0213Z16 104x212, UC8151 (IL0373), (WFT0213CZ16)
  99. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_Z19c // GDEH0213Z19 104x212, UC8151D, (HINK-E0213A20-A2 2020-11-19)
  100. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_Z98c // GDEY0213Z98 122x250, SSD1680, (FPC-A002 20.04.08)
  101. //#define GxEPD2_DRIVER_CLASS GxEPD2_266c // GDEY0266Z90 152x296, SSD1680, (FPC-7510)
  102. //#define GxEPD2_DRIVER_CLASS GxEPD2_270c // GDEW027C44 176x264, IL91874, (WFI0190CZ22)
  103. //#define GxEPD2_DRIVER_CLASS GxEPD2_290c // GDEW029Z10 128x296, UC8151 (IL0373), (WFT0290CZ10)
  104. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_Z13c // GDEH029Z13 128x296, UC8151D, (HINK-E029A10-A3 20160809)
  105. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_C90c // GDEM029C90 128x296, SSD1680, (FPC-7519 rev.b)
  106. //#define GxEPD2_DRIVER_CLASS GxEPD2_420c // GDEW042Z15 400x300, UC8176 (IL0398), (WFT0420CZ15)
  107. //#define GxEPD2_DRIVER_CLASS GxEPD2_420c_Z21 // GDEQ042Z21 400x300, UC8276, (hidden)
  108. //#define GxEPD2_DRIVER_CLASS GxEPD2_583c // GDEW0583Z21 600x448, UC8159c (IL0371), (missing)
  109. //#define GxEPD2_DRIVER_CLASS GxEPD2_583c_Z83 // GDEW0583Z83 648x480, EK79655 (GD7965), (WFT0583CZ61)
  110. //#define GxEPD2_DRIVER_CLASS GxEPD2_750c // GDEW075Z09 640x384, UC8159c (IL0371), (WF0583CZ09)
  111. //#define GxEPD2_DRIVER_CLASS GxEPD2_750c_Z08 // GDEW075Z08 800x480, EK79655 (GD7965), (WFT0583CZ61)
  112. //#define GxEPD2_DRIVER_CLASS GxEPD2_750c_Z90 // GDEH075Z90 880x528, SSD1677, (HINK-E075A07-A0)
  113. //#define GxEPD2_DRIVER_CLASS GxEPD2_1248c // GDEY1248Z51 1304x984, UC8179, (WFT1248BZ23,WFT1248BZ24)
  114. // 4-color e-paper
  115. //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
  116. //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
  117. //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)
  118. //#define GxEPD2_DRIVER_CLASS GxEPD2_300c // Waveshare 3.00" 4-color
  119. //#define GxEPD2_DRIVER_CLASS GxEPD2_420c_GDEY0420F51 // GDEY0420F51 400x300, HX8717 (no inking)
  120. //#define GxEPD2_DRIVER_CLASS GxEPD2_437c // Waveshare 4.37" 4-color
  121. // 7-color e-paper
  122. //#define GxEPD2_DRIVER_CLASS GxEPD2_565c // Waveshare 5.65" 7-color
  123. //#define GxEPD2_DRIVER_CLASS GxEPD2_730c_GDEY073D46 // GDEY073D46 800x480 7-color, (N-FPC-001 2021.11.26)
  124. //#define GxEPD2_DRIVER_CLASS GxEPD2_730c_ACeP_730 // Waveshare 7.3" 7-color
  125. // somehow there should be an easier way to do this
  126. #define GxEPD2_BW_IS_GxEPD2_BW true
  127. #define GxEPD2_3C_IS_GxEPD2_3C true
  128. #define GxEPD2_7C_IS_GxEPD2_7C true
  129. #define GxEPD2_1248_IS_GxEPD2_1248 true
  130. #define IS_GxEPD(c, x) (c##x)
  131. #define IS_GxEPD2_BW(x) IS_GxEPD(GxEPD2_BW_IS_, x)
  132. #define IS_GxEPD2_3C(x) IS_GxEPD(GxEPD2_3C_IS_, x)
  133. #define IS_GxEPD2_7C(x) IS_GxEPD(GxEPD2_7C_IS_, x)
  134. #define IS_GxEPD2_1248(x) IS_GxEPD(GxEPD2_1248_IS_, x)
  135. #if defined(ESP32)
  136. #define MAX_DISPLAY_BUFFER_SIZE 65536ul // e.g.
  137. #if IS_GxEPD2_BW(GxEPD2_DISPLAY_CLASS)
  138. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  139. #elif IS_GxEPD2_3C(GxEPD2_DISPLAY_CLASS)
  140. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
  141. #elif IS_GxEPD2_7C(GxEPD2_DISPLAY_CLASS)
  142. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2))
  143. #endif
  144. GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_HEIGHT(GxEPD2_DRIVER_CLASS)> display(GxEPD2_DRIVER_CLASS(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  145. #endif
  146. // alternately you can copy the constructor from GxEPD2_display_selection.h of GxEPD_Example to here
  147. // and adapt it to the ESP32 Driver wiring, e.g.
  148. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEH0154D67
  149. // comment out unused bitmaps to reduce code space used
  150. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  151. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  152. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  153. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  154. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  155. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  156. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  157. // 3-color
  158. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  159. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  160. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  161. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  162. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  163. #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  164. SPIClass hspi(HSPI);
  165. #endif
  166. void setup()
  167. {
  168. Serial.begin(115200);
  169. Serial.println();
  170. Serial.println("setup");
  171. // *** special handling for Waveshare ESP32 Driver board *** //
  172. // ********************************************************* //
  173. #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  174. hspi.begin(13, 12, 14, 15); // remap hspi for EPD (swap pins)
  175. display.epd2.selectSPI(hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  176. #endif
  177. // *** end of special handling for Waveshare ESP32 Driver board *** //
  178. // **************************************************************** //
  179. display.init(115200);
  180. // first update should be full refresh
  181. helloWorld();
  182. delay(1000);
  183. // partial refresh mode can be used to full screen,
  184. // effective if display panel hasFastPartialUpdate
  185. helloFullScreenPartialMode();
  186. delay(1000);
  187. helloArduino();
  188. delay(1000);
  189. helloEpaper();
  190. delay(1000);
  191. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  192. delay(1000);
  193. drawBitmaps();
  194. if (display.epd2.hasPartialUpdate)
  195. {
  196. showPartialUpdate();
  197. delay(1000);
  198. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  199. //drawCornerTest();
  200. //showBox(16, 16, 48, 32, false);
  201. //showBox(16, 56, 48, 32, true);
  202. display.powerOff();
  203. deepSleepTest();
  204. Serial.println("setup done");
  205. }
  206. void loop()
  207. {
  208. }
  209. // note for partial update window and setPartialWindow() method:
  210. // partial update window size and position is on byte boundary in physical x direction
  211. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  212. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  213. const char HelloWorld[] = "Hello World!";
  214. const char HelloArduino[] = "Hello Arduino!";
  215. const char HelloEpaper[] = "Hello E-Paper!";
  216. void helloWorld()
  217. {
  218. //Serial.println("helloWorld");
  219. display.setRotation(1);
  220. display.setFont(&FreeMonoBold9pt7b);
  221. display.setTextColor(GxEPD_BLACK);
  222. int16_t tbx, tby; uint16_t tbw, tbh;
  223. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  224. // center bounding box by transposition of origin:
  225. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  226. uint16_t y = ((display.height() - tbh) / 2) - tby;
  227. display.setFullWindow();
  228. display.firstPage();
  229. do
  230. {
  231. display.fillScreen(GxEPD_WHITE);
  232. display.setCursor(x, y);
  233. display.print(HelloWorld);
  234. }
  235. while (display.nextPage());
  236. //Serial.println("helloWorld done");
  237. }
  238. void helloWorldForDummies()
  239. {
  240. //Serial.println("helloWorld");
  241. const char text[] = "Hello World!";
  242. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  243. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  244. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  245. display.setRotation(1);
  246. // select a suitable font in Adafruit_GFX
  247. display.setFont(&FreeMonoBold9pt7b);
  248. // on e-papers black on white is more pleasant to read
  249. display.setTextColor(GxEPD_BLACK);
  250. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  251. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  252. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  253. // center bounding box by transposition of origin:
  254. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  255. uint16_t y = ((display.height() - tbh) / 2) - tby;
  256. // full window mode is the initial mode, set it anyway
  257. display.setFullWindow();
  258. // here we use paged drawing, even if the processor has enough RAM for full buffer
  259. // so this can be used with any supported processor board.
  260. // the cost in code overhead and execution time penalty is marginal
  261. // tell the graphics class to use paged drawing mode
  262. display.firstPage();
  263. do
  264. {
  265. // this part of code is executed multiple times, as many as needed,
  266. // in case of full buffer it is executed once
  267. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  268. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  269. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  270. display.setCursor(x, y); // set the postition to start printing text
  271. display.print(text); // print some text
  272. // end of part executed multiple times
  273. }
  274. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  275. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  276. // returns true if more pages need be drawn and transferred
  277. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  278. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  279. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  280. while (display.nextPage());
  281. //Serial.println("helloWorld done");
  282. }
  283. void helloFullScreenPartialMode()
  284. {
  285. //Serial.println("helloFullScreenPartialMode");
  286. const char fullscreen[] = "full screen update";
  287. const char fpm[] = "fast partial mode";
  288. const char spm[] = "slow partial mode";
  289. const char npm[] = "no partial mode";
  290. display.setPartialWindow(0, 0, display.width(), display.height());
  291. display.setRotation(1);
  292. display.setFont(&FreeMonoBold9pt7b);
  293. display.setTextColor(GxEPD_BLACK);
  294. const char* updatemode;
  295. if (display.epd2.hasFastPartialUpdate)
  296. {
  297. updatemode = fpm;
  298. }
  299. else if (display.epd2.hasPartialUpdate)
  300. {
  301. updatemode = spm;
  302. }
  303. else
  304. {
  305. updatemode = npm;
  306. }
  307. // do this outside of the loop
  308. int16_t tbx, tby; uint16_t tbw, tbh;
  309. // center update text
  310. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  311. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  312. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  313. // center update mode
  314. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  315. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  316. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  317. // center HelloWorld
  318. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  319. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  320. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  321. display.firstPage();
  322. do
  323. {
  324. display.fillScreen(GxEPD_WHITE);
  325. display.setCursor(hwx, hwy);
  326. display.print(HelloWorld);
  327. display.setCursor(utx, uty);
  328. display.print(fullscreen);
  329. display.setCursor(umx, umy);
  330. display.print(updatemode);
  331. }
  332. while (display.nextPage());
  333. //Serial.println("helloFullScreenPartialMode done");
  334. }
  335. void helloArduino()
  336. {
  337. //Serial.println("helloArduino");
  338. display.setRotation(1);
  339. display.setFont(&FreeMonoBold9pt7b);
  340. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  341. int16_t tbx, tby; uint16_t tbw, tbh;
  342. // align with centered HelloWorld
  343. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  344. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  345. // height might be different
  346. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  347. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  348. // make the window big enough to cover (overwrite) descenders of previous text
  349. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  350. uint16_t wy = (display.height() / 4) - wh / 2;
  351. display.setPartialWindow(0, wy, display.width(), wh);
  352. display.firstPage();
  353. do
  354. {
  355. display.fillScreen(GxEPD_WHITE);
  356. //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
  357. display.setCursor(x, y);
  358. display.print(HelloArduino);
  359. }
  360. while (display.nextPage());
  361. delay(1000);
  362. //Serial.println("helloArduino done");
  363. }
  364. void helloEpaper()
  365. {
  366. //Serial.println("helloEpaper");
  367. display.setRotation(1);
  368. display.setFont(&FreeMonoBold9pt7b);
  369. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  370. int16_t tbx, tby; uint16_t tbw, tbh;
  371. // align with centered HelloWorld
  372. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  373. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  374. // height might be different
  375. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  376. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  377. // make the window big enough to cover (overwrite) descenders of previous text
  378. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  379. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  380. display.setPartialWindow(0, wy, display.width(), wh);
  381. display.firstPage();
  382. do
  383. {
  384. display.fillScreen(GxEPD_WHITE);
  385. display.setCursor(x, y);
  386. display.print(HelloEpaper);
  387. }
  388. while (display.nextPage());
  389. //Serial.println("helloEpaper done");
  390. }
  391. void deepSleepTest()
  392. {
  393. //Serial.println("deepSleepTest");
  394. const char hibernating[] = "hibernating ...";
  395. const char wokeup[] = "woke up";
  396. const char from[] = "from deep sleep";
  397. const char again[] = "again";
  398. display.setRotation(1);
  399. display.setFont(&FreeMonoBold9pt7b);
  400. display.setTextColor(GxEPD_BLACK);
  401. int16_t tbx, tby; uint16_t tbw, tbh;
  402. // center text
  403. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  404. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  405. uint16_t y = ((display.height() - tbh) / 2) - tby;
  406. display.setFullWindow();
  407. display.firstPage();
  408. do
  409. {
  410. display.fillScreen(GxEPD_WHITE);
  411. display.setCursor(x, y);
  412. display.print(hibernating);
  413. }
  414. while (display.nextPage());
  415. display.hibernate();
  416. delay(5000);
  417. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  418. uint16_t wx = (display.width() - tbw) / 2;
  419. uint16_t wy = (display.height() / 3) + tbh / 2; // y is base line!
  420. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  421. uint16_t fx = (display.width() - tbw) / 2;
  422. uint16_t fy = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  423. display.firstPage();
  424. do
  425. {
  426. display.fillScreen(GxEPD_WHITE);
  427. display.setCursor(wx, wy);
  428. display.print(wokeup);
  429. display.setCursor(fx, fy);
  430. display.print(from);
  431. }
  432. while (display.nextPage());
  433. delay(5000);
  434. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  435. uint16_t hx = (display.width() - tbw) / 2;
  436. uint16_t hy = (display.height() / 3) + tbh / 2; // y is base line!
  437. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  438. uint16_t ax = (display.width() - tbw) / 2;
  439. uint16_t ay = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  440. display.firstPage();
  441. do
  442. {
  443. display.fillScreen(GxEPD_WHITE);
  444. display.setCursor(hx, hy);
  445. display.print(hibernating);
  446. display.setCursor(ax, ay);
  447. display.print(again);
  448. }
  449. while (display.nextPage());
  450. display.hibernate();
  451. //Serial.println("deepSleepTest done");
  452. }
  453. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  454. {
  455. //Serial.println("showBox");
  456. display.setRotation(1);
  457. if (partial)
  458. {
  459. display.setPartialWindow(x, y, w, h);
  460. }
  461. else
  462. {
  463. display.setFullWindow();
  464. }
  465. display.firstPage();
  466. do
  467. {
  468. display.fillScreen(GxEPD_WHITE);
  469. display.fillRect(x, y, w, h, GxEPD_BLACK);
  470. }
  471. while (display.nextPage());
  472. //Serial.println("showBox done");
  473. }
  474. void drawCornerTest()
  475. {
  476. display.setFullWindow();
  477. display.setFont(&FreeMonoBold9pt7b);
  478. display.setTextColor(GxEPD_BLACK);
  479. for (uint16_t r = 0; r <= 4; r++)
  480. {
  481. display.setRotation(r);
  482. display.firstPage();
  483. do
  484. {
  485. display.fillScreen(GxEPD_WHITE);
  486. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  487. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  488. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  489. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  490. display.setCursor(display.width() / 2, display.height() / 2);
  491. display.print(display.getRotation());
  492. }
  493. while (display.nextPage());
  494. delay(2000);
  495. }
  496. }
  497. void showFont(const char name[], const GFXfont* f)
  498. {
  499. display.setFullWindow();
  500. display.setRotation(0);
  501. display.setTextColor(GxEPD_BLACK);
  502. display.firstPage();
  503. do
  504. {
  505. drawFont(name, f);
  506. }
  507. while (display.nextPage());
  508. }
  509. void drawFont(const char name[], const GFXfont* f)
  510. {
  511. //display.setRotation(0);
  512. display.fillScreen(GxEPD_WHITE);
  513. display.setTextColor(GxEPD_BLACK);
  514. display.setFont(f);
  515. display.setCursor(0, 0);
  516. display.println();
  517. display.println(name);
  518. display.println(" !\"#$%&'()*+,-./");
  519. display.println("0123456789:;<=>?");
  520. display.println("@ABCDEFGHIJKLMNO");
  521. display.println("PQRSTUVWXYZ[\\]^_");
  522. if (display.epd2.hasColor)
  523. {
  524. display.setTextColor(GxEPD_RED);
  525. }
  526. display.println("`abcdefghijklmno");
  527. display.println("pqrstuvwxyz{|}~ ");
  528. }
  529. // note for partial update window and setPartialWindow() method:
  530. // partial update window size and position is on byte boundary in physical x direction
  531. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  532. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  533. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  534. void showPartialUpdate()
  535. {
  536. // some useful background
  537. helloWorld();
  538. // use asymmetric values for test
  539. uint16_t box_x = 10;
  540. uint16_t box_y = 15;
  541. uint16_t box_w = 70;
  542. uint16_t box_h = 20;
  543. uint16_t cursor_y = box_y + box_h - 6;
  544. float value = 13.95;
  545. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  546. display.setFont(&FreeMonoBold9pt7b);
  547. display.setTextColor(GxEPD_BLACK);
  548. // show where the update box is
  549. for (uint16_t r = 0; r < 4; r++)
  550. {
  551. display.setRotation(r);
  552. display.setPartialWindow(box_x, box_y, box_w, box_h);
  553. display.firstPage();
  554. do
  555. {
  556. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  557. //display.fillScreen(GxEPD_BLACK);
  558. }
  559. while (display.nextPage());
  560. delay(2000);
  561. display.firstPage();
  562. do
  563. {
  564. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  565. }
  566. while (display.nextPage());
  567. delay(1000);
  568. }
  569. //return;
  570. // show updates in the update box
  571. for (uint16_t r = 0; r < 4; r++)
  572. {
  573. display.setRotation(r);
  574. display.setPartialWindow(box_x, box_y, box_w, box_h);
  575. for (uint16_t i = 1; i <= 10; i += incr)
  576. {
  577. display.firstPage();
  578. do
  579. {
  580. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  581. display.setCursor(box_x, cursor_y);
  582. display.print(value * i, 2);
  583. }
  584. while (display.nextPage());
  585. delay(500);
  586. }
  587. delay(1000);
  588. display.firstPage();
  589. do
  590. {
  591. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  592. }
  593. while (display.nextPage());
  594. delay(1000);
  595. }
  596. }
  597. void drawBitmaps()
  598. {
  599. display.setFullWindow();
  600. #ifdef _GxBitmaps104x212_H_
  601. drawBitmaps104x212();
  602. #endif
  603. #ifdef _GxBitmaps128x250_H_
  604. drawBitmaps128x250();
  605. #endif
  606. #ifdef _GxBitmaps128x296_H_
  607. drawBitmaps128x296();
  608. #endif
  609. #ifdef _GxBitmaps176x264_H_
  610. drawBitmaps176x264();
  611. #endif
  612. #ifdef _GxBitmaps400x300_H_
  613. drawBitmaps400x300();
  614. #endif
  615. #ifdef _GxBitmaps640x384_H_
  616. drawBitmaps640x384();
  617. #endif
  618. #ifdef _WS_Bitmaps800x600_H_
  619. drawBitmaps800x600();
  620. #endif
  621. // 3-color
  622. #ifdef _GxBitmaps3c104x212_H_
  623. drawBitmaps3c104x212();
  624. #endif
  625. #ifdef _GxBitmaps3c128x296_H_
  626. drawBitmaps3c128x296();
  627. #endif
  628. #ifdef _GxBitmaps3c176x264_H_
  629. drawBitmaps3c176x264();
  630. #endif
  631. #ifdef _GxBitmaps3c400x300_H_
  632. drawBitmaps3c400x300();
  633. #endif
  634. // show these after the specific bitmaps
  635. #ifdef _GxBitmaps200x200_H_
  636. drawBitmaps200x200();
  637. #endif
  638. // 3-color
  639. #ifdef _GxBitmaps3c200x200_H_
  640. drawBitmaps3c200x200();
  641. #endif
  642. }
  643. #ifdef _GxBitmaps200x200_H_
  644. void drawBitmaps200x200()
  645. {
  646. #if defined(__AVR)
  647. const unsigned char* bitmaps[] =
  648. {
  649. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  650. };
  651. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  652. const unsigned char* bitmaps[] =
  653. {
  654. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  655. };
  656. #else
  657. const unsigned char* bitmaps[] =
  658. {
  659. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  660. };
  661. #endif
  662. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  663. {
  664. bool m = display.mirror(true);
  665. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  666. {
  667. display.firstPage();
  668. do
  669. {
  670. display.fillScreen(GxEPD_WHITE);
  671. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  672. }
  673. while (display.nextPage());
  674. delay(2000);
  675. }
  676. display.mirror(m);
  677. }
  678. //else
  679. {
  680. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  681. display.clearScreen(); // use default for white
  682. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  683. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  684. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  685. {
  686. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  687. delay(2000);
  688. }
  689. }
  690. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  691. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  692. {
  693. int16_t x = -60;
  694. int16_t y = -60;
  695. for (uint16_t j = 0; j < 10; j++)
  696. {
  697. display.writeScreenBuffer(); // use default for white
  698. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  699. display.refresh(true);
  700. if (display.epd2.hasFastPartialUpdate)
  701. {
  702. // for differential update: set previous buffer equal to current buffer in controller
  703. display.epd2.writeScreenBufferAgain(); // use default for white
  704. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  705. }
  706. delay(2000);
  707. x += 40;
  708. y += 40;
  709. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  710. }
  711. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  712. break; // comment out for full show
  713. }
  714. display.writeScreenBuffer(); // use default for white
  715. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  716. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  717. display.refresh(true);
  718. delay(2000);
  719. }
  720. #endif
  721. #ifdef _GxBitmaps104x212_H_
  722. void drawBitmaps104x212()
  723. {
  724. #if !defined(__AVR)
  725. const unsigned char* bitmaps[] =
  726. {
  727. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  728. };
  729. #else
  730. const unsigned char* bitmaps[] =
  731. {
  732. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  733. };
  734. #endif
  735. if (display.epd2.panel == GxEPD2::GDEW0213I5F)
  736. {
  737. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  738. {
  739. display.firstPage();
  740. do
  741. {
  742. display.fillScreen(GxEPD_WHITE);
  743. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  744. }
  745. while (display.nextPage());
  746. delay(2000);
  747. }
  748. }
  749. }
  750. #endif
  751. #ifdef _GxBitmaps128x250_H_
  752. void drawBitmaps128x250()
  753. {
  754. #if !defined(__AVR)
  755. const unsigned char* bitmaps[] =
  756. {
  757. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  758. };
  759. #else
  760. const unsigned char* bitmaps[] =
  761. {
  762. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  763. };
  764. #endif
  765. if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
  766. {
  767. bool m = display.mirror(true);
  768. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  769. {
  770. display.firstPage();
  771. do
  772. {
  773. display.fillScreen(GxEPD_WHITE);
  774. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  775. }
  776. while (display.nextPage());
  777. delay(2000);
  778. }
  779. display.mirror(m);
  780. }
  781. }
  782. #endif
  783. #ifdef _GxBitmaps128x296_H_
  784. void drawBitmaps128x296()
  785. {
  786. #if !defined(__AVR)
  787. const unsigned char* bitmaps[] =
  788. {
  789. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  790. };
  791. #else
  792. const unsigned char* bitmaps[] =
  793. {
  794. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  795. };
  796. #endif
  797. if (display.epd2.panel == GxEPD2::GDEH029A1)
  798. {
  799. bool m = display.mirror(true);
  800. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  801. {
  802. display.firstPage();
  803. do
  804. {
  805. display.fillScreen(GxEPD_WHITE);
  806. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  807. }
  808. while (display.nextPage());
  809. delay(2000);
  810. }
  811. display.mirror(m);
  812. }
  813. }
  814. #endif
  815. #ifdef _GxBitmaps176x264_H_
  816. void drawBitmaps176x264()
  817. {
  818. #if !defined(__AVR)
  819. const unsigned char* bitmaps[] =
  820. {
  821. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  822. };
  823. #else
  824. const unsigned char* bitmaps[] =
  825. {
  826. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  827. };
  828. #endif
  829. if (display.epd2.panel == GxEPD2::GDEW027W3)
  830. {
  831. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  832. {
  833. display.firstPage();
  834. do
  835. {
  836. display.fillScreen(GxEPD_WHITE);
  837. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  838. }
  839. while (display.nextPage());
  840. delay(2000);
  841. }
  842. }
  843. }
  844. #endif
  845. #ifdef _GxBitmaps400x300_H_
  846. void drawBitmaps400x300()
  847. {
  848. #if !defined(__AVR)
  849. const unsigned char* bitmaps[] =
  850. {
  851. Bitmap400x300_1, Bitmap400x300_2
  852. };
  853. #else
  854. const unsigned char* bitmaps[] = {}; // not enough code space
  855. #endif
  856. if (display.epd2.panel == GxEPD2::GDEW042T2)
  857. {
  858. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  859. {
  860. display.firstPage();
  861. do
  862. {
  863. display.fillScreen(GxEPD_WHITE);
  864. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  865. }
  866. while (display.nextPage());
  867. delay(2000);
  868. }
  869. }
  870. }
  871. #endif
  872. #ifdef _GxBitmaps640x384_H_
  873. void drawBitmaps640x384()
  874. {
  875. #if !defined(__AVR)
  876. const unsigned char* bitmaps[] =
  877. {
  878. Bitmap640x384_1, Bitmap640x384_2
  879. };
  880. #else
  881. const unsigned char* bitmaps[] = {}; // not enough code space
  882. #endif
  883. if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
  884. {
  885. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  886. {
  887. display.firstPage();
  888. do
  889. {
  890. display.fillScreen(GxEPD_WHITE);
  891. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  892. }
  893. while (display.nextPage());
  894. delay(2000);
  895. }
  896. }
  897. }
  898. #endif
  899. #ifdef _WS_Bitmaps800x600_H_
  900. void drawBitmaps800x600()
  901. {
  902. #if defined(ESP8266) || defined(ESP32)
  903. if (display.epd2.panel == GxEPD2::ED060SCT)
  904. {
  905. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  906. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  907. delay(2000);
  908. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  909. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  910. // delay(2000);
  911. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  912. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  913. // delay(2000);
  914. }
  915. #endif
  916. }
  917. #endif
  918. struct bitmap_pair
  919. {
  920. const unsigned char* black;
  921. const unsigned char* red;
  922. };
  923. #ifdef _GxBitmaps3c200x200_H_
  924. void drawBitmaps3c200x200()
  925. {
  926. bitmap_pair bitmap_pairs[] =
  927. {
  928. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  929. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  930. };
  931. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  932. {
  933. display.firstPage();
  934. do
  935. {
  936. display.fillScreen(GxEPD_WHITE);
  937. // Bitmap3c200x200_black has 2 bits per pixel
  938. // taken from Adafruit_GFX.cpp, modified
  939. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  940. uint8_t byte = 0;
  941. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  942. {
  943. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  944. {
  945. if (i & 3) byte <<= 2;
  946. else
  947. {
  948. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  949. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  950. #else
  951. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  952. #endif
  953. }
  954. if (!(byte & 0x80))
  955. {
  956. display.drawPixel(i, j, GxEPD_BLACK);
  957. }
  958. }
  959. }
  960. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  961. }
  962. while (display.nextPage());
  963. delay(2000);
  964. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  965. {
  966. display.firstPage();
  967. do
  968. {
  969. display.fillScreen(GxEPD_WHITE);
  970. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  971. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  972. }
  973. while (display.nextPage());
  974. delay(2000);
  975. }
  976. }
  977. if (display.epd2.hasColor)
  978. {
  979. display.clearScreen(); // use default for white
  980. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  981. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  982. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  983. {
  984. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  985. delay(2000);
  986. }
  987. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  988. {
  989. int16_t x = -60;
  990. int16_t y = -60;
  991. for (uint16_t j = 0; j < 10; j++)
  992. {
  993. display.writeScreenBuffer(); // use default for white
  994. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  995. display.refresh();
  996. delay(1000);
  997. x += 40;
  998. y += 40;
  999. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1000. }
  1001. }
  1002. display.writeScreenBuffer(); // use default for white
  1003. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  1004. 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);
  1005. display.refresh();
  1006. delay(2000);
  1007. }
  1008. }
  1009. #endif
  1010. #ifdef _GxBitmaps3c104x212_H_
  1011. void drawBitmaps3c104x212()
  1012. {
  1013. #if !defined(__AVR)
  1014. bitmap_pair bitmap_pairs[] =
  1015. {
  1016. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1017. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1018. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1019. };
  1020. #else
  1021. bitmap_pair bitmap_pairs[] =
  1022. {
  1023. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1024. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1025. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1026. };
  1027. #endif
  1028. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1029. {
  1030. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1031. {
  1032. display.firstPage();
  1033. do
  1034. {
  1035. display.fillScreen(GxEPD_WHITE);
  1036. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1037. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1038. {
  1039. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1040. }
  1041. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1042. }
  1043. while (display.nextPage());
  1044. delay(2000);
  1045. }
  1046. }
  1047. }
  1048. #endif
  1049. #ifdef _GxBitmaps3c128x296_H_
  1050. void drawBitmaps3c128x296()
  1051. {
  1052. #if !defined(__AVR)
  1053. bitmap_pair bitmap_pairs[] =
  1054. {
  1055. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1056. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1057. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1058. };
  1059. #else
  1060. bitmap_pair bitmap_pairs[] =
  1061. {
  1062. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1063. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1064. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1065. };
  1066. #endif
  1067. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  1068. {
  1069. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1070. {
  1071. display.firstPage();
  1072. do
  1073. {
  1074. display.fillScreen(GxEPD_WHITE);
  1075. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1076. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1077. {
  1078. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1079. }
  1080. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1081. }
  1082. while (display.nextPage());
  1083. delay(2000);
  1084. }
  1085. }
  1086. }
  1087. #endif
  1088. #ifdef _GxBitmaps3c176x264_H_
  1089. void drawBitmaps3c176x264()
  1090. {
  1091. bitmap_pair bitmap_pairs[] =
  1092. {
  1093. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1094. };
  1095. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1096. {
  1097. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1098. {
  1099. display.firstPage();
  1100. do
  1101. {
  1102. display.fillScreen(GxEPD_WHITE);
  1103. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1104. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1105. }
  1106. while (display.nextPage());
  1107. delay(2000);
  1108. }
  1109. }
  1110. }
  1111. #endif
  1112. #ifdef _GxBitmaps3c400x300_H_
  1113. void drawBitmaps3c400x300()
  1114. {
  1115. #if !defined(__AVR)
  1116. bitmap_pair bitmap_pairs[] =
  1117. {
  1118. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1119. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1120. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1121. };
  1122. #else
  1123. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1124. #endif
  1125. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1126. {
  1127. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1128. {
  1129. display.firstPage();
  1130. do
  1131. {
  1132. display.fillScreen(GxEPD_WHITE);
  1133. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1134. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1135. }
  1136. while (display.nextPage());
  1137. delay(2000);
  1138. }
  1139. }
  1140. }
  1141. #endif