GxEPD2_MultiDisplayExample.ino 37 KB

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