GxEPD2_GFX_MultiDisplayExample.ino 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. // GxEPD2_GFX_MultiDisplayExample : 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: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
  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:
  12. // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
  13. // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
  14. // mapping suggestion from Waveshare SPI e-Paper to Wemos D1 mini
  15. // BUSY -> D2, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V
  16. // NOTE: connect 3.3k pull-down from D8 to GND if your board or shield has level converters
  17. // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case, or 4k7 pull-down
  18. // mapping suggestion from Waveshare SPI e-Paper to generic ESP8266
  19. // BUSY -> GPIO4, RST -> GPIO2, DC -> GPIO0, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
  20. // NOTE: connect 3.3k pull-down from GPIO15 to GND if your board or shield has level converters
  21. // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case, or 3.3k pull-down
  22. // mapping of Waveshare e-Paper ESP8266 Driver Board, new version (see GxEPD2_boards_added.h for old version)
  23. // BUSY -> GPIO5, RST -> GPIO2, DC -> GPIO4, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
  24. // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, add a 3.3k pull-down in case
  25. // the e-Paper ESP8266 Driver Board should have no boot mode issue, as it doesn't use level converters
  26. // mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board
  27. // NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD
  28. // BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V
  29. // mapping of Waveshare ESP32 Driver Board
  30. // BUSY -> 25, RST -> 26, DC -> 27, CS-> 15, CLK -> 13, DIN -> 14
  31. // NOTE: this board uses "unusual" SPI pins and requires re-mapping of HW SPI to these pins in SPIClass
  32. // see example GxEPD2_WS_ESP32_Driver.ino, it shows how this can be done easily
  33. // new mapping suggestion for STM32F1, e.g. STM32F103C8T6 "BluePill"
  34. // BUSY -> A1, RST -> A2, DC -> A3, CS-> A4, CLK -> A5, DIN -> A7
  35. // mapping suggestion for AVR, UNO, NANO etc.
  36. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11
  37. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter
  38. // enable GxEPD2_GFX base class
  39. #define ENABLE_GxEPD2_GFX 1
  40. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  41. //#include <GFX.h>
  42. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  43. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  44. // !!!! ============================================================================================ !!!!
  45. #include <GxEPD2_BW.h>
  46. #include <GxEPD2_3C.h>
  47. #include <Fonts/FreeMonoBold9pt7b.h>
  48. // create display class instances for each display, each instance with different CS line, each instance with RST disabled,
  49. // (or use separate RST pins for each display),
  50. // each instance with different BUSY line, or BUSY lines or-ed to one pin
  51. // disable reset line to disable cross resets by multiple instances
  52. #if defined (ESP8266)
  53. #define RST_PIN 0 // D3(0)
  54. #define CS_1 SS // CS = D8(15)
  55. #define CS_2 16 // CS = D0(16)
  56. #define CS_3 5 // CS = D1(5)
  57. // BUSY lines can be or-ed with diodes and pulldown register for displays with BUSY active HIGH
  58. #define BUSY_H_x 4 // BUSY = D2(4)
  59. // BUSY lines can be or-ed with diodes and pullup resistor for displays with BUSY active LOW
  60. //#define BUSY_L_x 4 // BUSY = D2(4)
  61. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  62. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display1(GxEPD2_154(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEP015OC1 no longer available
  63. GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display1(GxEPD2_154_D67(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0154D67
  64. //GxEPD2_BW<GxEPD2_154_T8, GxEPD2_154_T8::HEIGHT> display(GxEPD2_154_T8(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154T8 152x152
  65. //GxEPD2_BW<GxEPD2_154_M09, GxEPD2_154_M09::HEIGHT> display(GxEPD2_154_M09(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M09 200x200
  66. //GxEPD2_BW<GxEPD2_154_M10, GxEPD2_154_M10::HEIGHT> display(GxEPD2_154_M10(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M10 152x152
  67. GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display2(GxEPD2_213(/*CS=*/ CS_2, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x));
  68. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0213B72
  69. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0213B73
  70. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213I5F
  71. GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display3(GxEPD2_290(/*CS=*/ CS_3, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x));
  72. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029T5
  73. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  74. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  75. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  76. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  77. // can use only half buffer size
  78. //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  79. //GxEPD2_BW < GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT / 2 > display(GxEPD2_583_T8(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  80. //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  81. //GxEPD2_BW < GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT / 2 > display(GxEPD2_750_T7(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075T7 800x480
  82. // 3-color e-papers
  83. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW0154Z04 no longer available
  84. //GxEPD2_3C<GxEPD2_154_Z90c, GxEPD2_154_Z90c::HEIGHT> display(GxEPD2_154_Z90c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEH0154Z90
  85. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  86. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  87. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  88. // can use only half buffer size
  89. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  90. // can use only quarter buffer size
  91. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT / 4> display(GxEPD2_583c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  92. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display3(GxEPD2_750c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  93. //GxEPD2_3C < GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT / 4 > display(GxEPD2_750c_Z08(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075Z08 800x480
  94. #endif
  95. #if defined(ESP32)
  96. #define RST_PIN 16
  97. #define CS_1 SS // CS = 5(SS)
  98. #define CS_2 0 // CS = 0
  99. #define CS_3 2 // CS = 2
  100. #define CS_4 13 // CS = 13
  101. // BUSY lines can be or-ed with diodes and pulldown register for displays with BUSY active HIGH
  102. #define BUSY_H_x 4 // BUSY = 4
  103. // BUSY lines can be or-ed with diodes and pullup resistor for displays with BUSY active LOW
  104. #define BUSY_L_x 15 // BUSY = 15
  105. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  106. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display1(GxEPD2_154(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEP015OC1 no longer available
  107. GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display1(GxEPD2_154_D67(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0154D67
  108. //GxEPD2_BW<GxEPD2_154_T8, GxEPD2_154_T8::HEIGHT> display(GxEPD2_154_T8(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154T8 152x152
  109. //GxEPD2_BW<GxEPD2_154_M09, GxEPD2_154_M09::HEIGHT> display(GxEPD2_154_M09(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M09 200x200
  110. //GxEPD2_BW<GxEPD2_154_M10, GxEPD2_154_M10::HEIGHT> display(GxEPD2_154_M10(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M10 152x152
  111. GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display2(GxEPD2_213(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x));
  112. GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display3(GxEPD2_290(/*CS=*/ CS_3, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x));
  113. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029T5
  114. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  115. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  116. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  117. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display4(GxEPD2_420(/*CS=*/ CS_4, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  118. //GxEPD2_BW<GxEPD2_583, GxEPD2_583::HEIGHT> display(GxEPD2_583(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  119. //GxEPD2_BW<GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT> display(GxEPD2_583_T8(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  120. //GxEPD2_BW<GxEPD2_750, GxEPD2_750::HEIGHT> display(GxEPD2_750(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  121. //GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(GxEPD2_750_T7(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075T7 800x480
  122. // 3-color e-papers
  123. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW0154Z04 no longer available
  124. //GxEPD2_3C<GxEPD2_154_Z90c, GxEPD2_154_Z90c::HEIGHT> display(GxEPD2_154_Z90c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEH0154Z90
  125. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  126. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  127. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  128. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  129. GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT> display4(GxEPD2_750c(/*CS=*/ CS_4, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x));
  130. //GxEPD2_3C<GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT> display(GxEPD2_750c_Z08(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075Z08 800x480
  131. #endif
  132. // comment out unused bitmaps to reduce code space used
  133. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  134. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  135. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  136. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  137. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  138. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  139. // 3-color
  140. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  141. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  142. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  143. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  144. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  145. void setup()
  146. {
  147. Serial.begin(115200);
  148. Serial.println();
  149. Serial.println("setup");
  150. // one common reset for all displays
  151. digitalWrite(RST_PIN, HIGH);
  152. pinMode(RST_PIN, OUTPUT);
  153. delay(20);
  154. digitalWrite(RST_PIN, LOW);
  155. delay(20);
  156. digitalWrite(RST_PIN, HIGH);
  157. delay(200);
  158. display1.init(115200); // enable diagnostic output on Serial
  159. display2.init(115200); // enable diagnostic output on Serial
  160. display3.init(115200); // enable diagnostic output on Serial
  161. #if defined(ESP32)
  162. display4.init(115200); // enable diagnostic output on Serial
  163. #endif
  164. // first update should be full refresh
  165. helloWorld(display1);
  166. helloWorld(display2);
  167. helloWorld(display3);
  168. #if defined(ESP32)
  169. helloWorld(display4);
  170. #endif
  171. delay(1000);
  172. // partial refresh mode can be used to full screen,
  173. // effective if display panel hasFastPartialUpdate
  174. helloFullScreenPartialMode(display1);
  175. helloFullScreenPartialMode(display2);
  176. helloFullScreenPartialMode(display3);
  177. #if defined(ESP32)
  178. helloFullScreenPartialMode(display4);
  179. #endif
  180. delay(1000);
  181. helloArduino(display1);
  182. helloArduino(display2);
  183. helloArduino(display3);
  184. #if defined(ESP32)
  185. helloArduino(display4);
  186. #endif
  187. delay(1000);
  188. helloEpaper(display1);
  189. helloEpaper(display2);
  190. helloEpaper(display3);
  191. #if defined(ESP32)
  192. helloEpaper(display4);
  193. #endif
  194. delay(1000);
  195. showFont(display1, "FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  196. showFont(display2, "FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  197. showFont(display3, "FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  198. #if defined(ESP32)
  199. showFont(display4, "FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  200. #endif
  201. delay(1000);
  202. drawBitmaps(display1);
  203. drawBitmaps(display2);
  204. drawBitmaps(display3);
  205. #if defined(ESP32)
  206. drawBitmaps(display4);
  207. #endif
  208. // if (display1.epd2.hasPartialUpdate)
  209. // {
  210. // showPartialUpdate(display1);
  211. // delay(1000);
  212. // } // else // on GDEW0154Z04 only full update available, doesn't look nice
  213. //drawCornerTest(display1);
  214. //showBox(display1, 16, 16, 48, 32, false);
  215. //showBox(display1, 16, 56, 48, 32, true);
  216. display1.powerOff();
  217. display2.powerOff();
  218. display3.powerOff();
  219. Serial.println("setup done");
  220. }
  221. void loop()
  222. {
  223. }
  224. void helloWorld(GxEPD2_GFX& display)
  225. {
  226. //Serial.println("helloWorld");
  227. display.setRotation(1);
  228. display.setFont(&FreeMonoBold9pt7b);
  229. display.setTextColor(GxEPD_BLACK);
  230. uint16_t x = (display.width() - 160) / 2;
  231. uint16_t y = display.height() / 2;
  232. display.setFullWindow();
  233. display.firstPage();
  234. do
  235. {
  236. display.fillScreen(GxEPD_WHITE);
  237. display.setCursor(x, y);
  238. display.println("Hello World!");
  239. }
  240. while (display.nextPage());
  241. //Serial.println("helloWorld done");
  242. }
  243. void helloFullScreenPartialMode(GxEPD2_GFX& display)
  244. {
  245. //Serial.println("helloFullScreenPartialMode");
  246. display.setPartialWindow(0, 0, display.width(), display.height());
  247. display.setRotation(1);
  248. display.setFont(&FreeMonoBold9pt7b);
  249. display.setTextColor(GxEPD_BLACK);
  250. display.firstPage();
  251. do
  252. {
  253. uint16_t x = (display.width() - 160) / 2;
  254. uint16_t y = display.height() / 2;
  255. display.fillScreen(GxEPD_WHITE);
  256. display.setCursor(x, y);
  257. display.println("Hello World!");
  258. y = display.height() / 4;
  259. display.setCursor(x, y);
  260. display.println("full screen");
  261. y = display.height() * 3 / 4;
  262. if (display.width() <= 200) x = 0;
  263. display.setCursor(x, y);
  264. if (display.epd2.hasFastPartialUpdate)
  265. {
  266. display.println("fast partial mode");
  267. }
  268. else if (display.epd2.hasPartialUpdate)
  269. {
  270. display.println("slow partial mode");
  271. }
  272. else
  273. {
  274. display.println("no partial mode");
  275. }
  276. }
  277. while (display.nextPage());
  278. //Serial.println("helloFullScreenPartialMode done");
  279. }
  280. void helloArduino(GxEPD2_GFX& display)
  281. {
  282. //Serial.println("helloArduino");
  283. display.setRotation(1);
  284. display.setFont(&FreeMonoBold9pt7b);
  285. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  286. uint16_t x = (display.width() - 160) / 2;
  287. uint16_t y = display.height() / 4;
  288. display.setPartialWindow(0, y - 14, display.width(), 20);
  289. display.firstPage();
  290. do
  291. {
  292. display.fillScreen(GxEPD_WHITE);
  293. display.setCursor(x, y);
  294. display.println("Hello Arduino!");
  295. }
  296. while (display.nextPage());
  297. delay(1000);
  298. //Serial.println("helloArduino done");
  299. }
  300. void helloEpaper(GxEPD2_GFX& display)
  301. {
  302. //Serial.println("helloEpaper");
  303. display.setRotation(1);
  304. display.setFont(&FreeMonoBold9pt7b);
  305. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  306. uint16_t x = (display.width() - 160) / 2;
  307. uint16_t y = display.height() * 3 / 4;
  308. display.setPartialWindow(0, y - 14, display.width(), 20);
  309. display.firstPage();
  310. do
  311. {
  312. display.fillScreen(GxEPD_WHITE);
  313. display.setCursor(x, y);
  314. display.println("Hello E-Paper!");
  315. }
  316. while (display.nextPage());
  317. //Serial.println("helloEpaper done");
  318. }
  319. void showBox(GxEPD2_GFX& display, uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  320. {
  321. //Serial.println("showBox");
  322. display.setRotation(1);
  323. if (partial)
  324. {
  325. display.setPartialWindow(x, y, w, h);
  326. }
  327. else
  328. {
  329. display.setFullWindow();
  330. }
  331. display.firstPage();
  332. do
  333. {
  334. display.fillScreen(GxEPD_WHITE);
  335. display.fillRect(x, y, w, h, GxEPD_BLACK);
  336. }
  337. while (display.nextPage());
  338. //Serial.println("showBox done");
  339. }
  340. void drawCornerTest(GxEPD2_GFX& display)
  341. {
  342. display.setFullWindow();
  343. display.setFont(&FreeMonoBold9pt7b);
  344. display.setTextColor(GxEPD_BLACK);
  345. for (uint16_t r = 0; r <= 4; r++)
  346. {
  347. display.setRotation(r);
  348. display.firstPage();
  349. do
  350. {
  351. display.fillScreen(GxEPD_WHITE);
  352. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  353. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  354. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  355. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  356. display.setCursor(display.width() / 2, display.height() / 2);
  357. display.print(display.getRotation());
  358. }
  359. while (display.nextPage());
  360. delay(2000);
  361. }
  362. }
  363. void showFont(GxEPD2_GFX& display, const char name[], const GFXfont* f)
  364. {
  365. display.setFullWindow();
  366. display.setRotation(0);
  367. display.setTextColor(GxEPD_BLACK);
  368. display.firstPage();
  369. do
  370. {
  371. drawFont(display, name, f);
  372. }
  373. while (display.nextPage());
  374. }
  375. //void drawFont(GxEPD2_GFX& display, const char name[], const GFXfont* f);
  376. void drawFont(GxEPD2_GFX& display, const char name[], const GFXfont* f)
  377. {
  378. //display.setRotation(0);
  379. display.fillScreen(GxEPD_WHITE);
  380. display.setTextColor(GxEPD_BLACK);
  381. display.setFont(f);
  382. display.setCursor(0, 0);
  383. display.println();
  384. display.println(name);
  385. display.println(" !\"#$%&'()*+,-./");
  386. display.println("0123456789:;<=>?");
  387. display.println("@ABCDEFGHIJKLMNO");
  388. display.println("PQRSTUVWXYZ[\\]^_");
  389. if (display.epd2.hasColor)
  390. {
  391. display.setTextColor(GxEPD_RED);
  392. }
  393. display.println("`abcdefghijklmno");
  394. display.println("pqrstuvwxyz{|}~ ");
  395. }
  396. void showPartialUpdate(GxEPD2_GFX& display)
  397. {
  398. // some useful background
  399. helloWorld(display);
  400. // use asymmetric values for test
  401. uint16_t box_x = 10;
  402. uint16_t box_y = 15;
  403. uint16_t box_w = 70;
  404. uint16_t box_h = 20;
  405. uint16_t cursor_y = box_y + box_h - 6;
  406. float value = 13.95;
  407. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  408. display.setFont(&FreeMonoBold9pt7b);
  409. display.setTextColor(GxEPD_BLACK);
  410. // show where the update box is
  411. for (uint16_t r = 0; r < 4; r++)
  412. {
  413. display.setRotation(r);
  414. display.setPartialWindow(box_x, box_y, box_w, box_h);
  415. display.firstPage();
  416. do
  417. {
  418. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  419. //display.fillScreen(GxEPD_BLACK);
  420. }
  421. while (display.nextPage());
  422. delay(2000);
  423. display.firstPage();
  424. do
  425. {
  426. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  427. }
  428. while (display.nextPage());
  429. delay(1000);
  430. }
  431. //return;
  432. // show updates in the update box
  433. for (uint16_t r = 0; r < 4; r++)
  434. {
  435. display.setRotation(r);
  436. display.setPartialWindow(box_x, box_y, box_w, box_h);
  437. for (uint16_t i = 1; i <= 10; i += incr)
  438. {
  439. display.firstPage();
  440. do
  441. {
  442. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  443. display.setCursor(box_x, cursor_y);
  444. display.print(value * i, 2);
  445. }
  446. while (display.nextPage());
  447. delay(500);
  448. }
  449. delay(1000);
  450. display.firstPage();
  451. do
  452. {
  453. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  454. }
  455. while (display.nextPage());
  456. delay(1000);
  457. }
  458. }
  459. #ifdef _GxBitmaps200x200_H_
  460. void drawBitmaps200x200(GxEPD2_GFX& display);
  461. void drawBitmaps200x200(GxEPD2_GFX& display)
  462. {
  463. #if defined(__AVR)
  464. const unsigned char* bitmaps[] =
  465. {
  466. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  467. };
  468. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  469. const unsigned char* bitmaps[] =
  470. {
  471. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  472. };
  473. #else
  474. const unsigned char* bitmaps[] =
  475. {
  476. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  477. };
  478. #endif
  479. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  480. {
  481. bool m = display.mirror(true);
  482. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  483. {
  484. display.firstPage();
  485. do
  486. {
  487. display.fillScreen(GxEPD_WHITE);
  488. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  489. }
  490. while (display.nextPage());
  491. delay(2000);
  492. }
  493. display.mirror(m);
  494. }
  495. //else
  496. {
  497. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  498. display.clearScreen(); // use default for white
  499. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  500. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  501. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  502. {
  503. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  504. delay(2000);
  505. }
  506. }
  507. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  508. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  509. {
  510. int16_t x = -60;
  511. int16_t y = -60;
  512. for (uint16_t j = 0; j < 10; j++)
  513. {
  514. display.writeScreenBuffer(); // use default for white
  515. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  516. display.refresh(true);
  517. if (display.epd2.hasFastPartialUpdate)
  518. {
  519. // for differential update: set previous buffer equal to current buffer in controller
  520. display.epd2.writeScreenBufferAgain(); // use default for white
  521. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  522. }
  523. delay(2000);
  524. x += 40;
  525. y += 40;
  526. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  527. }
  528. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  529. break; // comment out for full show
  530. }
  531. display.writeScreenBuffer(); // use default for white
  532. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  533. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  534. display.refresh(true);
  535. delay(2000);
  536. }
  537. #endif
  538. #ifdef _GxBitmaps128x250_H_
  539. void drawBitmaps128x250(GxEPD2_GFX& display);
  540. void drawBitmaps128x250(GxEPD2_GFX& display)
  541. {
  542. #if !defined(__AVR)
  543. const unsigned char* bitmaps[] =
  544. {
  545. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  546. };
  547. #else
  548. const unsigned char* bitmaps[] =
  549. {
  550. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  551. };
  552. #endif
  553. if (display.epd2.panel == GxEPD2::GDE0213B1)
  554. {
  555. bool m = display.mirror(true);
  556. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  557. {
  558. display.firstPage();
  559. do
  560. {
  561. display.fillScreen(GxEPD_WHITE);
  562. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  563. }
  564. while (display.nextPage());
  565. delay(2000);
  566. }
  567. display.mirror(m);
  568. }
  569. }
  570. #endif
  571. #ifdef _GxBitmaps128x296_H_
  572. void drawBitmaps128x296(GxEPD2_GFX& display);
  573. void drawBitmaps128x296(GxEPD2_GFX& display)
  574. {
  575. #if !defined(__AVR)
  576. const unsigned char* bitmaps[] =
  577. {
  578. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  579. };
  580. #else
  581. const unsigned char* bitmaps[] =
  582. {
  583. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  584. };
  585. #endif
  586. if (display.epd2.panel == GxEPD2::GDEH029A1)
  587. {
  588. bool m = display.mirror(true);
  589. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  590. {
  591. display.firstPage();
  592. do
  593. {
  594. display.fillScreen(GxEPD_WHITE);
  595. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  596. }
  597. while (display.nextPage());
  598. delay(2000);
  599. }
  600. display.mirror(m);
  601. }
  602. }
  603. #endif
  604. #ifdef _GxBitmaps176x264_H_
  605. void drawBitmaps176x264(GxEPD2_GFX& display);
  606. void drawBitmaps176x264(GxEPD2_GFX& display)
  607. {
  608. const unsigned char* bitmaps[] =
  609. {
  610. Bitmap176x264_1, Bitmap176x264_2
  611. };
  612. if (display.epd2.panel == GxEPD2::GDEW027W3)
  613. {
  614. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  615. {
  616. display.firstPage();
  617. do
  618. {
  619. display.fillScreen(GxEPD_WHITE);
  620. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  621. }
  622. while (display.nextPage());
  623. delay(2000);
  624. }
  625. }
  626. }
  627. #endif
  628. #ifdef _GxBitmaps400x300_H_
  629. void drawBitmaps400x300(GxEPD2_GFX& display);
  630. void drawBitmaps400x300(GxEPD2_GFX& display)
  631. {
  632. #if !defined(__AVR)
  633. const unsigned char* bitmaps[] =
  634. {
  635. Bitmap400x300_1, Bitmap400x300_2
  636. };
  637. #else
  638. const unsigned char* bitmaps[] = {}; // not enough code space
  639. #endif
  640. if (display.epd2.panel == GxEPD2::GDEW042T2)
  641. {
  642. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  643. {
  644. display.firstPage();
  645. do
  646. {
  647. display.fillScreen(GxEPD_WHITE);
  648. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  649. }
  650. while (display.nextPage());
  651. delay(2000);
  652. }
  653. }
  654. }
  655. #endif
  656. #ifdef _GxBitmaps640x384_H_
  657. void drawBitmaps640x384(GxEPD2_GFX& display);
  658. void drawBitmaps640x384(GxEPD2_GFX& display)
  659. {
  660. #if !defined(__AVR)
  661. const unsigned char* bitmaps[] =
  662. {
  663. Bitmap640x384_1, Bitmap640x384_2
  664. };
  665. #else
  666. const unsigned char* bitmaps[] = {}; // not enough code space
  667. #endif
  668. if (display.epd2.panel == GxEPD2::GDEW075T8)
  669. {
  670. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  671. {
  672. display.firstPage();
  673. do
  674. {
  675. display.fillScreen(GxEPD_WHITE);
  676. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  677. }
  678. while (display.nextPage());
  679. delay(2000);
  680. }
  681. }
  682. }
  683. #endif
  684. struct bitmap_pair
  685. {
  686. const unsigned char* black;
  687. const unsigned char* red;
  688. };
  689. #ifdef _GxBitmaps3c200x200_H_
  690. void drawBitmaps3c200x200(GxEPD2_GFX& display);
  691. void drawBitmaps3c200x200(GxEPD2_GFX& display)
  692. {
  693. bitmap_pair bitmap_pairs[] =
  694. {
  695. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  696. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  697. };
  698. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  699. {
  700. display.firstPage();
  701. do
  702. {
  703. display.fillScreen(GxEPD_WHITE);
  704. // Bitmap3c200x200_black has 2 bits per pixel
  705. // taken from Adafruit_GFX.cpp, modified
  706. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  707. uint8_t byte = 0;
  708. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  709. {
  710. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  711. {
  712. if (i & 3) byte <<= 2;
  713. else
  714. {
  715. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  716. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  717. #else
  718. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  719. #endif
  720. }
  721. if (!(byte & 0x80))
  722. {
  723. display.drawPixel(i, j, GxEPD_BLACK);
  724. }
  725. }
  726. }
  727. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  728. }
  729. while (display.nextPage());
  730. delay(2000);
  731. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  732. {
  733. display.firstPage();
  734. do
  735. {
  736. display.fillScreen(GxEPD_WHITE);
  737. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  738. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  739. }
  740. while (display.nextPage());
  741. delay(2000);
  742. }
  743. }
  744. if (display.epd2.hasColor)
  745. {
  746. display.clearScreen(); // use default for white
  747. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  748. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  749. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  750. {
  751. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  752. delay(2000);
  753. }
  754. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  755. {
  756. int16_t x = -60;
  757. int16_t y = -60;
  758. for (uint16_t j = 0; j < 10; j++)
  759. {
  760. display.writeScreenBuffer(); // use default for white
  761. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  762. display.refresh();
  763. delay(2000);
  764. x += 40;
  765. y += 40;
  766. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  767. }
  768. }
  769. display.writeScreenBuffer(); // use default for white
  770. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  771. 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);
  772. display.refresh();
  773. delay(2000);
  774. }
  775. }
  776. #endif
  777. #ifdef _GxBitmaps3c104x212_H_
  778. void drawBitmaps3c104x212(GxEPD2_GFX& display);
  779. void drawBitmaps3c104x212(GxEPD2_GFX& display)
  780. {
  781. #if !defined(__AVR)
  782. bitmap_pair bitmap_pairs[] =
  783. {
  784. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  785. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  786. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  787. };
  788. #else
  789. bitmap_pair bitmap_pairs[] =
  790. {
  791. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  792. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  793. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  794. };
  795. #endif
  796. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  797. {
  798. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  799. {
  800. display.firstPage();
  801. do
  802. {
  803. display.fillScreen(GxEPD_WHITE);
  804. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  805. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  806. {
  807. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  808. }
  809. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  810. }
  811. while (display.nextPage());
  812. delay(2000);
  813. }
  814. }
  815. }
  816. #endif
  817. #ifdef _GxBitmaps3c128x296_H_
  818. void drawBitmaps3c128x296(GxEPD2_GFX& display);
  819. void drawBitmaps3c128x296(GxEPD2_GFX& display)
  820. {
  821. #if !defined(__AVR)
  822. bitmap_pair bitmap_pairs[] =
  823. {
  824. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  825. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  826. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  827. };
  828. #else
  829. bitmap_pair bitmap_pairs[] =
  830. {
  831. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  832. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  833. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  834. };
  835. #endif
  836. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  837. {
  838. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  839. {
  840. display.firstPage();
  841. do
  842. {
  843. display.fillScreen(GxEPD_WHITE);
  844. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  845. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  846. {
  847. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  848. }
  849. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  850. }
  851. while (display.nextPage());
  852. delay(2000);
  853. }
  854. }
  855. }
  856. #endif
  857. #ifdef _GxBitmaps3c176x264_H_
  858. void drawBitmaps3c176x264(GxEPD2_GFX& display);
  859. void drawBitmaps3c176x264(GxEPD2_GFX& display)
  860. {
  861. bitmap_pair bitmap_pairs[] =
  862. {
  863. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  864. };
  865. if (display.epd2.panel == GxEPD2::GDEW027C44)
  866. {
  867. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  868. {
  869. display.firstPage();
  870. do
  871. {
  872. display.fillScreen(GxEPD_WHITE);
  873. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  874. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  875. }
  876. while (display.nextPage());
  877. delay(2000);
  878. }
  879. }
  880. }
  881. #endif
  882. #ifdef _GxBitmaps3c400x300_H_
  883. void drawBitmaps3c400x300(GxEPD2_GFX& display);
  884. void drawBitmaps3c400x300(GxEPD2_GFX& display)
  885. {
  886. #if !defined(__AVR)
  887. bitmap_pair bitmap_pairs[] =
  888. {
  889. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  890. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  891. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  892. };
  893. #else
  894. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  895. #endif
  896. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  897. {
  898. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  899. {
  900. display.firstPage();
  901. do
  902. {
  903. display.fillScreen(GxEPD_WHITE);
  904. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  905. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  906. }
  907. while (display.nextPage());
  908. delay(2000);
  909. }
  910. }
  911. }
  912. #endif
  913. void drawBitmaps(GxEPD2_GFX& display)
  914. {
  915. display.setFullWindow();
  916. display.setRotation(0);
  917. #ifdef _GxBitmaps128x250_H_
  918. drawBitmaps128x250(display);
  919. #endif
  920. #ifdef _GxBitmaps128x296_H_
  921. drawBitmaps128x296(display);
  922. #endif
  923. #ifdef _GxBitmaps176x264_H_
  924. drawBitmaps176x264(display);
  925. #endif
  926. #ifdef _GxBitmaps400x300_H_
  927. drawBitmaps400x300(display);
  928. #endif
  929. #ifdef _GxBitmaps640x384_H_
  930. drawBitmaps640x384(display);
  931. #endif
  932. // 3-color
  933. #ifdef _GxBitmaps3c104x212_H_
  934. drawBitmaps3c104x212(display);
  935. #endif
  936. #ifdef _GxBitmaps3c128x296_H_
  937. drawBitmaps3c128x296(display);
  938. #endif
  939. #ifdef _GxBitmaps3c176x264_H_
  940. drawBitmaps3c176x264(display);
  941. #endif
  942. #ifdef _GxBitmaps3c400x300_H_
  943. drawBitmaps3c400x300(display);
  944. #endif
  945. // show these after the specific bitmaps
  946. #ifdef _GxBitmaps200x200_H_
  947. drawBitmaps200x200(display);
  948. #endif
  949. // 3-color
  950. #ifdef _GxBitmaps3c200x200_H_
  951. drawBitmaps3c200x200(display);
  952. #endif
  953. }