GxEPD2_MultiDisplayExample.ino 38 KB

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