GxEPD2_GFX_MultiDisplayExample.ino 37 KB

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