GxEPD2_NotPagedExample.ino 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  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: 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. // mapping of Waveshare Universal e-Paper Raw Panel Driver Shield for Arduino / NUCLEO
  38. // BUSY -> 7, RST -> 8, DC -> 9, CS-> 10, CLK -> 13, DIN -> 11
  39. // mapping suggestion for Arduino MEGA
  40. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 53, CLK -> 52, DIN -> 51
  41. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  42. // enable or disable GxEPD2_GFX base class
  43. #define ENABLE_GxEPD2_GFX 0
  44. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  45. //#include <GFX.h>
  46. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  47. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  48. #include <GxEPD2_BW.h>
  49. #include <GxEPD2_3C.h>
  50. #include <GxEPD2_7C.h>
  51. #include <Fonts/FreeMonoBold9pt7b.h>
  52. #if defined (ESP8266)
  53. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  54. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEP015OC1 no longer available
  55. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0154D67
  56. //GxEPD2_BW<GxEPD2_154_T8, GxEPD2_154_T8::HEIGHT> display(GxEPD2_154_T8(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW0154T8 152x152
  57. //GxEPD2_BW<GxEPD2_154_M09, GxEPD2_154_M09::HEIGHT> display(GxEPD2_154_M09(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW0154M09 200x200
  58. //GxEPD2_BW<GxEPD2_154_M10, GxEPD2_154_M10::HEIGHT> display(GxEPD2_154_M10(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW0154M10 152x152
  59. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDE0213B1, phased out
  60. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0213B72
  61. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0213B73
  62. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW0213I5F
  63. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  64. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW029T5
  65. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  66. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  67. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  68. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  69. // can use only half buffer size
  70. ////GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  71. ////GxEPD2_BW < GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT / 2 > display(GxEPD2_583_T8(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  72. ////GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  73. ////GxEPD2_BW < GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT / 2 > display(GxEPD2_750_T7(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW075T7 800x480
  74. // 3-color e-papers
  75. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW0154Z04 no longer available
  76. //GxEPD2_3C<GxEPD2_154_Z90c, GxEPD2_154_Z90c::HEIGHT> display(GxEPD2_154_Z90c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0154Z90
  77. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  78. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  79. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  80. // can use only half buffer size
  81. ////GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  82. // can use only quarter buffer size
  83. ////GxEPD2_3C < GxEPD2_583c, GxEPD2_583c::HEIGHT / 4 > display(GxEPD2_583c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  84. ////GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  85. ////GxEPD2_3C < GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT / 4 > display(GxEPD2_750c_Z08(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW075Z08 800x480
  86. // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
  87. // HRDY -> 4, RST -> 2, CS -> SS(15), SCK -> SCK(14), MOSI -> MOSI(D7(13)), MISO -> MISO(D6(12)), GND -> GND, 5V -> 5V
  88. // note: 5V supply needs to be exact and strong; 5V pin of USB powered Wemos D1 mini doesn't work!
  89. ////GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT / 8> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 0, /*RST=*/ 2, /*BUSY=*/ 4));
  90. // ***** for mapping of Waveshare e-Paper ESP8266 Driver Board *****
  91. // select one , can use full buffer size (full HEIGHT)
  92. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEP015OC1 no longer available
  93. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEH0154D67
  94. //GxEPD2_BW<GxEPD2_154_T8, GxEPD2_154_T8::HEIGHT> display(GxEPD2_154_T8(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW0154T8 152x152
  95. //GxEPD2_BW<GxEPD2_154_M09, GxEPD2_154_M09::HEIGHT> display(GxEPD2_154_M09(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW0154M09 200x200
  96. //GxEPD2_BW<GxEPD2_154_M10, GxEPD2_154_M10::HEIGHT> display(GxEPD2_154_M10(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW0154M10 152x152
  97. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDE0213B1, phased out
  98. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEH0213B72
  99. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEH0213B73
  100. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW0213I5F
  101. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  102. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW029T5
  103. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  104. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  105. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  106. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  107. // can use only half buffer size
  108. ////GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  109. ////GxEPD2_BW < GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT / 2 > display(GxEPD2_583_T8(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  110. ////GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  111. ////GxEPD2_BW < GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT / 2 > display(GxEPD2_750_T7(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW075T7 800x480
  112. // 3-color e-papers
  113. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW0154Z04 no longer available
  114. //GxEPD2_3C<GxEPD2_154_Z90c, GxEPD2_154_Z90c::HEIGHT> display(GxEPD2_154_Z90c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEH0154Z90
  115. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  116. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  117. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  118. // can use only half buffer size
  119. ////GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  120. // can use only quarter buffer size
  121. ////GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT / 4> display(GxEPD2_583c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  122. ////GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5));
  123. ////GxEPD2_3C<GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT / 4> display(GxEPD2_750c_Z08(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEW075Z08 800x480
  124. ////GxEPD2_3C<GxEPD2_750c_Z90, GxEPD2_750c_Z90::HEIGHT / 4> display(GxEPD2_750c_Z90(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // GDEH075Z90 880x528
  125. // 7-color e-paper
  126. ////GxEPD2_7C < GxEPD2_565c, GxEPD2_565c::HEIGHT / 4 > display(GxEPD2_565c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=2*/ 2, /*BUSY=5*/ 5)); // Waveshare 5.65" 7-color
  127. #endif
  128. #if defined(ESP32)
  129. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  130. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEP015OC1 no longer available
  131. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0154D67
  132. //GxEPD2_BW<GxEPD2_154_T8, GxEPD2_154_T8::HEIGHT> display(GxEPD2_154_T8(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154T8 152x152
  133. //GxEPD2_BW<GxEPD2_154_M09, GxEPD2_154_M09::HEIGHT> display(GxEPD2_154_M09(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154M09 200x200
  134. //GxEPD2_BW<GxEPD2_154_M10, GxEPD2_154_M10::HEIGHT> display(GxEPD2_154_M10(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154M10 152x152
  135. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDE0213B1, phased out
  136. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B72
  137. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B73
  138. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0213I5F
  139. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  140. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW029T5
  141. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  142. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  143. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  144. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  145. //GxEPD2_BW<GxEPD2_583, GxEPD2_583::HEIGHT> display(GxEPD2_583(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  146. //GxEPD2_BW<GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT> display(GxEPD2_583_T8(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  147. //GxEPD2_BW<GxEPD2_750, GxEPD2_750::HEIGHT> display(GxEPD2_750(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  148. //GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(GxEPD2_750_T7(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW075T7 800x480
  149. // 3-color e-papers
  150. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154Z04 no longer available
  151. //GxEPD2_3C<GxEPD2_154_Z90c, GxEPD2_154_Z90c::HEIGHT> display(GxEPD2_154_Z90c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0154Z90
  152. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  153. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  154. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  155. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  156. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT> display(GxEPD2_583c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  157. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT> display(GxEPD2_750c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  158. //GxEPD2_3C<GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT> display(GxEPD2_750c_Z08(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW075Z08 800x480
  159. //GxEPD2_3C<GxEPD2_565c, GxEPD2_565c::HEIGHT> display(GxEPD2_565c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  160. //GxEPD2_7C<GxEPD2_565c, GxEPD2_565c::HEIGHT> display(GxEPD2_565c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  161. GxEPD2_7C<GxEPD2_565c, 360> display(GxEPD2_565c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  162. // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
  163. // HRDY -> 4, RST -> 16, CS -> SS(5), SCK -> SCK(18), MOSI -> MOSI(23), MISO -> MISO(19), GND -> GND, 5V -> 5V
  164. // note: 5V supply needs to be exact and strong; 5V over diode from USB (e.g. Wemos D1 mini) doesn't work!
  165. //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  166. // Waveshare 12.48 b/w SPI display board and frame or Good Display 12.48 b/w panel GDEW1248T3
  167. // general constructor for use with all parameters, e.g. for Waveshare ESP32 driver board mounted on connection board
  168. //GxEPD2_BW < GxEPD2_1248, GxEPD2_1248::HEIGHT / 4 >
  169. //display(GxEPD2_1248(/*sck=*/ 13, /*miso=*/ 12, /*mosi=*/ 14, /*cs_m1=*/ 23, /*cs_s1=*/ 22, /*cs_m2=*/ 16, /*cs_s2=*/ 19,
  170. // /*dc1=*/ 25, /*dc2=*/ 17, /*rst1=*/ 33, /*rst2=*/ 5, /*busy_m1=*/ 32, /*busy_s1=*/ 26, /*busy_m2=*/ 18, /*busy_s2=*/ 4));
  171. #endif
  172. // can't use package "STMF1 Boards (STM32Duino.com)" (Roger Clark) anymore with Adafruit_GFX, use "STM32 Boards (selected from submenu)" (STMicroelectronics)
  173. #if defined(ARDUINO_ARCH_STM32)
  174. #define MAX_DISPLAY_BUFFER_SIZE 15000ul // ~15k is a good compromise
  175. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  176. // select one and adapt to your mapping
  177. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEP015OC1 no longer available
  178. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0154D67
  179. //GxEPD2_BW<GxEPD2_154_T8, MAX_HEIGHT(GxEPD2_154_T8)> display(GxEPD2_154_T8(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0154T8 152x152
  180. //GxEPD2_BW<GxEPD2_154_M09, MAX_HEIGHT(GxEPD2_154_M09)> display(GxEPD2_154_M09(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0154M09 200x200
  181. //GxEPD2_BW<GxEPD2_154_M10, MAX_HEIGHT(GxEPD2_154_M10)> display(GxEPD2_154_M10(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0154M10 152x152
  182. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDE0213B1, phased out
  183. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B72
  184. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B73
  185. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0213I5F
  186. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  187. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW029T5
  188. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  189. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  190. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  191. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  192. ////GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  193. ////GxEPD2_BW <GxEPD2_583_T8, MAX_HEIGHT(GxEPD2_583_T8)> display(GxEPD2_583_T8(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  194. ////GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  195. ////GxEPD2_BW<GxEPD2_750_T7, MAX_HEIGHT(GxEPD2_750_T7)> display(GxEPD2_750_T7(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW075T7 800x480
  196. // 3-color e-papers
  197. #define MAX_HEIGHT_3C(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
  198. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0154Z04 no longer available
  199. //GxEPD2_3C<GxEPD2_154_Z90c, MAX_HEIGHT_3C(GxEPD2_154_Z90c)> display(GxEPD2_154_Z90c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0154Z90
  200. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  201. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  202. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  203. ////GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  204. ////GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  205. ////GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  206. ////GxEPD2_3C<GxEPD2_750c_Z08, MAX_HEIGHT_3C(GxEPD2_750c_Z08)> display(GxEPD2_750c_Z08(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW075Z08 800x480
  207. #endif
  208. #include "GxEPD2_boards_added.h"
  209. //#include "GxEPD2_more_boards_added.h" // private
  210. #if !defined(__AVR) && !defined(_BOARD_GENERIC_STM32F103C_H_)
  211. // comment out unused bitmaps to reduce code space used
  212. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  213. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  214. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  215. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  216. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  217. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  218. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  219. // 3-color
  220. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  221. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  222. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  223. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  224. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  225. #if defined(ESP8266) || defined(ESP32)
  226. #include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
  227. #endif
  228. #else
  229. // select only one to fit in code space
  230. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  231. //#include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  232. //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  233. //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  234. //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  235. ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
  236. ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
  237. // 3-color
  238. //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  239. //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  240. //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  241. //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  242. ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
  243. #endif
  244. void setup()
  245. {
  246. Serial.begin(115200);
  247. Serial.println();
  248. Serial.println("setup");
  249. delay(100);
  250. display.init(115200);
  251. // first update should be full refresh
  252. helloWorld();
  253. delay(1000);
  254. // partial refresh mode can be used to full screen,
  255. // effective if display panel hasFastPartialUpdate
  256. helloFullScreenPartialMode();
  257. delay(1000);
  258. helloArduino();
  259. delay(1000);
  260. helloEpaper();
  261. delay(1000);
  262. //helloValue(123.9, 1);
  263. //delay(1000);
  264. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  265. delay(1000);
  266. drawBitmaps();
  267. if (display.epd2.hasPartialUpdate)
  268. {
  269. showPartialUpdate();
  270. delay(1000);
  271. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  272. //drawCornerTest();
  273. //showBox(16, 16, 48, 32, false);
  274. //showBox(16, 56, 48, 32, true);
  275. display.powerOff();
  276. deepSleepTest();
  277. Serial.println("setup done");
  278. }
  279. void loop()
  280. {
  281. }
  282. // note for partial update window and setPartialWindow() method:
  283. // partial update window size and position is on byte boundary in physical x direction
  284. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  285. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  286. const char HelloWorld[] = "Hello World!";
  287. const char HelloArduino[] = "Hello Arduino!";
  288. const char HelloEpaper[] = "Hello E-Paper!";
  289. void helloWorld()
  290. {
  291. //Serial.println("helloWorld");
  292. display.setRotation(1);
  293. display.setFont(&FreeMonoBold9pt7b);
  294. display.setTextColor(GxEPD_BLACK);
  295. int16_t tbx, tby; uint16_t tbw, tbh;
  296. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  297. // center bounding box by transposition of origin:
  298. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  299. uint16_t y = ((display.height() - tbh) / 2) - tby;
  300. // full window mode is the initial mode, set it anyway
  301. display.setFullWindow();
  302. display.fillScreen(GxEPD_WHITE);
  303. display.setCursor(x, y);
  304. display.print(HelloWorld);
  305. display.display(false); // full update
  306. //Serial.println("helloWorld done");
  307. }
  308. void helloWorldForDummiesNotPaged()
  309. {
  310. //Serial.println("helloWorld");
  311. const char text[] = "Hello World!";
  312. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  313. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  314. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  315. display.setRotation(1);
  316. // select a suitable font in Adafruit_GFX
  317. display.setFont(&FreeMonoBold9pt7b);
  318. // on e-papers black on white is more pleasant to read
  319. display.setTextColor(GxEPD_BLACK);
  320. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  321. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  322. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  323. // center bounding box by transposition of origin:
  324. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  325. uint16_t y = ((display.height() - tbh) / 2) - tby;
  326. // full window mode is the initial mode, set it anyway
  327. display.setFullWindow();
  328. // here we use full buffered drawing
  329. // only part of the display is used if page_height is less than HEIGHT
  330. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  331. display.setCursor(x, y); // set the postition to start printing text
  332. display.print(text); // print some text
  333. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  334. // and to refresh to the screen
  335. display.display(false); // full update
  336. //Serial.println("helloWorld done");
  337. }
  338. void helloFullScreenPartialMode()
  339. {
  340. //Serial.println("helloFullScreenPartialMode");
  341. const char fullscreen[] = "full screen update";
  342. const char fpm[] = "fast partial mode";
  343. const char spm[] = "slow partial mode";
  344. const char npm[] = "no partial mode";
  345. // full window mode is the initial mode, set it anyway
  346. display.setFullWindow();
  347. display.setRotation(1);
  348. display.setFont(&FreeMonoBold9pt7b);
  349. display.setTextColor(GxEPD_BLACK);
  350. const char* updatemode;
  351. if (display.epd2.hasFastPartialUpdate)
  352. {
  353. updatemode = fpm;
  354. }
  355. else if (display.epd2.hasPartialUpdate)
  356. {
  357. updatemode = spm;
  358. }
  359. else
  360. {
  361. updatemode = npm;
  362. }
  363. // do this outside of the loop
  364. int16_t tbx, tby; uint16_t tbw, tbh;
  365. // center update text
  366. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  367. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  368. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  369. // center update mode
  370. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  371. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  372. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  373. // center HelloWorld
  374. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  375. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  376. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  377. display.fillScreen(GxEPD_WHITE);
  378. display.setCursor(hwx, hwy);
  379. display.print(HelloWorld);
  380. display.setCursor(utx, uty);
  381. display.print(fullscreen);
  382. display.setCursor(umx, umy);
  383. display.print(updatemode);
  384. display.display(true); // partial update
  385. //Serial.println("helloFullScreenPartialMode done");
  386. }
  387. void helloArduino()
  388. {
  389. //Serial.println("helloArduino");
  390. display.setRotation(1);
  391. display.setFont(&FreeMonoBold9pt7b);
  392. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  393. int16_t tbx, tby; uint16_t tbw, tbh;
  394. // align with centered HelloWorld
  395. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  396. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  397. // height might be different
  398. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  399. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  400. // make the window big enough to cover (overwrite) descenders of previous text
  401. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  402. uint16_t wy = (display.height() / 4) - wh / 2;
  403. // full window mode is the initial mode, set it anyway
  404. display.setFullWindow();
  405. // DO NOT display.fillScreen(GxEPD_WHITE); keep current content!
  406. display.fillRect(0, wy, display.width(), wh, GxEPD_WHITE); // clear rect instead
  407. display.setCursor(x, y);
  408. display.print(HelloArduino);
  409. display.displayWindow(0, wy, display.width(), wh);
  410. delay(1000);
  411. //Serial.println("helloArduino done");
  412. }
  413. void helloEpaper()
  414. {
  415. //Serial.println("helloEpaper");
  416. display.setRotation(1);
  417. display.setFont(&FreeMonoBold9pt7b);
  418. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  419. int16_t tbx, tby; uint16_t tbw, tbh;
  420. // align with centered HelloWorld
  421. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  422. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  423. // height might be different
  424. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  425. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  426. // make the window big enough to cover (overwrite) descenders of previous text
  427. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  428. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  429. // full window mode is the initial mode, set it anyway
  430. display.setFullWindow();
  431. // DO NOT display.fillScreen(GxEPD_WHITE); keep current content!
  432. display.fillRect(0, wy, display.width(), wh, GxEPD_WHITE); // clear rect instead
  433. display.setCursor(x, y);
  434. display.print(HelloEpaper);
  435. display.displayWindow(0, wy, display.width(), wh);
  436. //Serial.println("helloEpaper done");
  437. }
  438. #if defined(ESP8266) || defined(ESP32)
  439. #include <StreamString.h>
  440. #define PrintString StreamString
  441. #else
  442. class PrintString : public Print, public String
  443. {
  444. public:
  445. size_t write(uint8_t data) override
  446. {
  447. return concat(char(data));
  448. };
  449. };
  450. #endif
  451. void helloValue(double v, int digits)
  452. {
  453. //Serial.println("helloValue");
  454. display.setRotation(1);
  455. display.setFont(&FreeMonoBold9pt7b);
  456. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  457. PrintString valueString;
  458. valueString.print(v, digits);
  459. int16_t tbx, tby; uint16_t tbw, tbh;
  460. display.getTextBounds(valueString, 0, 0, &tbx, &tby, &tbw, &tbh);
  461. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  462. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  463. // show what happens, if we use the bounding box for partial window
  464. uint16_t wx = (display.width() - tbw) / 2;
  465. uint16_t wy = (display.height() * 3 / 4) - tbh / 2;
  466. // full window mode is the initial mode, set it anyway
  467. display.setFullWindow();
  468. // DO NOT display.fillScreen(GxEPD_WHITE); keep current content!
  469. display.fillRect(wx, wy, tbw, tbh, GxEPD_WHITE); // clear rect instead
  470. display.setCursor(x, y);
  471. display.print(valueString);
  472. display.displayWindow(wx, wy, tbw, tbh);
  473. delay(2000);
  474. // make the partial window big enough to cover the previous text
  475. uint16_t ww = tbw; // remember window width
  476. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  477. // adjust, because HelloEpaper was aligned, not centered (could calculate this to be precise)
  478. ww = max(ww, uint16_t(tbw + 12)); // 12 seems ok
  479. wx = (display.width() - tbw) / 2;
  480. // make the window big enough to cover (overwrite) descenders of previous text
  481. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  482. wy = (display.height() * 3 / 4) - wh / 2;
  483. // DO NOT display.fillScreen(GxEPD_WHITE); keep current content!
  484. display.fillRect(wx, wy, ww, wh, GxEPD_WHITE); // clear rect instead
  485. display.setCursor(x, y);
  486. display.print(valueString);
  487. display.displayWindow(wx, wy, ww, wh);
  488. // alternately use the whole width for partial window
  489. //display.displayWindow(wx, wy, display.width(), wh);
  490. //Serial.println("helloValue done");
  491. }
  492. void deepSleepTest()
  493. {
  494. //Serial.println("deepSleepTest");
  495. const char hibernating[] = "hibernating ...";
  496. const char wokeup[] = "woke up";
  497. const char from[] = "from deep sleep";
  498. const char again[] = "again";
  499. display.setRotation(1);
  500. display.setFont(&FreeMonoBold9pt7b);
  501. display.setTextColor(GxEPD_BLACK);
  502. int16_t tbx, tby; uint16_t tbw, tbh;
  503. // center text
  504. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  505. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  506. uint16_t y = ((display.height() - tbh) / 2) - tby;
  507. display.setFullWindow();
  508. display.fillScreen(GxEPD_WHITE);
  509. display.setCursor(x, y);
  510. display.print(hibernating);
  511. display.display(false); // full update
  512. display.hibernate();
  513. delay(5000);
  514. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  515. uint16_t wx = (display.width() - tbw) / 2;
  516. uint16_t wy = (display.height() / 3) + tbh / 2; // y is base line!
  517. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  518. uint16_t fx = (display.width() - tbw) / 2;
  519. uint16_t fy = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  520. display.fillScreen(GxEPD_WHITE);
  521. display.setCursor(wx, wy);
  522. display.print(wokeup);
  523. display.setCursor(fx, fy);
  524. display.print(from);
  525. display.display(false); // full update
  526. delay(5000);
  527. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  528. uint16_t hx = (display.width() - tbw) / 2;
  529. uint16_t hy = (display.height() / 3) + tbh / 2; // y is base line!
  530. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  531. uint16_t ax = (display.width() - tbw) / 2;
  532. uint16_t ay = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  533. display.fillScreen(GxEPD_WHITE);
  534. display.setCursor(hx, hy);
  535. display.print(hibernating);
  536. display.setCursor(ax, ay);
  537. display.print(again);
  538. display.display(false); // full update
  539. display.hibernate();
  540. //Serial.println("deepSleepTest done");
  541. }
  542. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  543. {
  544. //Serial.println("showBox");
  545. display.setRotation(1);
  546. display.setFullWindow();
  547. display.fillScreen(GxEPD_WHITE);
  548. display.fillRect(x, y, w, h, GxEPD_BLACK);
  549. if (partial)
  550. {
  551. display.displayWindow(x, y, w, h);
  552. }
  553. else
  554. {
  555. display.display(false); // full update
  556. }
  557. //Serial.println("showBox done");
  558. }
  559. void drawCornerTest()
  560. {
  561. display.setFullWindow();
  562. display.setFont(&FreeMonoBold9pt7b);
  563. display.setTextColor(GxEPD_BLACK);
  564. for (uint16_t r = 0; r <= 4; r++)
  565. {
  566. display.setRotation(r);
  567. display.fillScreen(GxEPD_WHITE);
  568. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  569. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  570. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  571. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  572. display.setCursor(display.width() / 2, display.height() / 2);
  573. display.print(display.getRotation());
  574. display.display(false); // full update
  575. delay(2000);
  576. }
  577. }
  578. void showFont(const char name[], const GFXfont* f)
  579. {
  580. display.setFullWindow();
  581. display.setRotation(0);
  582. display.setTextColor(GxEPD_BLACK);
  583. drawFont(name, f);
  584. display.display(false); // full update
  585. }
  586. void drawFont(const char name[], const GFXfont* f)
  587. {
  588. //display.setRotation(0);
  589. display.fillScreen(GxEPD_WHITE);
  590. display.setTextColor(GxEPD_BLACK);
  591. display.setFont(f);
  592. display.setCursor(0, 0);
  593. display.println();
  594. display.println(name);
  595. display.println(" !\"#$%&'()*+,-./");
  596. display.println("0123456789:;<=>?");
  597. display.println("@ABCDEFGHIJKLMNO");
  598. display.println("PQRSTUVWXYZ[\\]^_");
  599. if (display.epd2.hasColor)
  600. {
  601. display.setTextColor(GxEPD_RED);
  602. }
  603. display.println("`abcdefghijklmno");
  604. display.println("pqrstuvwxyz{|}~ ");
  605. }
  606. // note for partial update window and setPartialWindow() method:
  607. // partial update window size and position is on byte boundary in physical x direction
  608. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  609. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  610. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  611. void showPartialUpdate()
  612. {
  613. // some useful background
  614. helloWorld();
  615. // use asymmetric values for test
  616. uint16_t box_x = 10;
  617. uint16_t box_y = 15;
  618. uint16_t box_w = 70;
  619. uint16_t box_h = 20;
  620. uint16_t cursor_y = box_y + box_h - 6;
  621. float value = 13.95;
  622. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  623. display.setFont(&FreeMonoBold9pt7b);
  624. display.setTextColor(GxEPD_BLACK);
  625. display.setFullWindow();
  626. // show where the update box is
  627. for (uint16_t r = 0; r < 4; r++)
  628. {
  629. display.setRotation(r);
  630. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  631. //display.fillScreen(GxEPD_BLACK);
  632. display.displayWindow(box_x, box_y, box_w, box_h);
  633. delay(2000);
  634. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  635. display.displayWindow(box_x, box_y, box_w, box_h);
  636. delay(1000);
  637. }
  638. //return;
  639. // show updates in the update box
  640. for (uint16_t r = 0; r < 4; r++)
  641. {
  642. display.setRotation(r);
  643. for (uint16_t i = 1; i <= 10; i += incr)
  644. {
  645. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  646. display.setCursor(box_x, cursor_y);
  647. display.print(value * i, 2);
  648. display.displayWindow(box_x, box_y, box_w, box_h);
  649. delay(500);
  650. }
  651. delay(1000);
  652. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  653. display.displayWindow(box_x, box_y, box_w, box_h);
  654. delay(1000);
  655. }
  656. }
  657. void drawBitmaps()
  658. {
  659. display.setFullWindow();
  660. #ifdef _GxBitmaps104x212_H_
  661. drawBitmaps104x212();
  662. #endif
  663. #ifdef _GxBitmaps128x250_H_
  664. drawBitmaps128x250();
  665. #endif
  666. #ifdef _GxBitmaps128x296_H_
  667. drawBitmaps128x296();
  668. #endif
  669. #ifdef _GxBitmaps176x264_H_
  670. drawBitmaps176x264();
  671. #endif
  672. #ifdef _GxBitmaps400x300_H_
  673. drawBitmaps400x300();
  674. #endif
  675. #ifdef _GxBitmaps640x384_H_
  676. drawBitmaps640x384();
  677. #endif
  678. #ifdef _WS_Bitmaps800x600_H_
  679. drawBitmaps800x600();
  680. #endif
  681. // 3-color
  682. #ifdef _GxBitmaps3c104x212_H_
  683. drawBitmaps3c104x212();
  684. #endif
  685. #ifdef _GxBitmaps3c128x296_H_
  686. drawBitmaps3c128x296();
  687. #endif
  688. #ifdef _GxBitmaps3c176x264_H_
  689. drawBitmaps3c176x264();
  690. #endif
  691. #ifdef _GxBitmaps3c400x300_H_
  692. drawBitmaps3c400x300();
  693. #endif
  694. // show these after the specific bitmaps
  695. #ifdef _GxBitmaps200x200_H_
  696. drawBitmaps200x200();
  697. #endif
  698. // 3-color
  699. #ifdef _GxBitmaps3c200x200_H_
  700. drawBitmaps3c200x200();
  701. #endif
  702. }
  703. #ifdef _GxBitmaps200x200_H_
  704. void drawBitmaps200x200()
  705. {
  706. #if defined(__AVR)
  707. const unsigned char* bitmaps[] =
  708. {
  709. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  710. };
  711. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  712. const unsigned char* bitmaps[] =
  713. {
  714. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  715. };
  716. #else
  717. const unsigned char* bitmaps[] =
  718. {
  719. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  720. };
  721. #endif
  722. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  723. {
  724. bool m = display.mirror(true);
  725. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  726. {
  727. display.fillScreen(GxEPD_WHITE);
  728. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  729. display.display();
  730. delay(2000);
  731. }
  732. display.mirror(m);
  733. }
  734. //else
  735. {
  736. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  737. display.clearScreen(); // use default for white
  738. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  739. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  740. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  741. {
  742. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  743. delay(2000);
  744. }
  745. }
  746. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  747. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  748. {
  749. int16_t x = -60;
  750. int16_t y = -60;
  751. for (uint16_t j = 0; j < 10; j++)
  752. {
  753. display.writeScreenBuffer(); // use default for white
  754. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  755. display.refresh(true);
  756. if (display.epd2.hasFastPartialUpdate)
  757. {
  758. // for differential update: set previous buffer equal to current buffer in controller
  759. display.epd2.writeScreenBufferAgain(); // use default for white
  760. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  761. }
  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. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  768. break; // comment out for full show
  769. }
  770. display.writeScreenBuffer(); // use default for white
  771. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  772. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  773. display.refresh(true);
  774. delay(2000);
  775. }
  776. #endif
  777. #ifdef _GxBitmaps104x212_H_
  778. void drawBitmaps104x212()
  779. {
  780. #if !defined(__AVR)
  781. const unsigned char* bitmaps[] =
  782. {
  783. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  784. };
  785. #else
  786. const unsigned char* bitmaps[] =
  787. {
  788. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  789. };
  790. #endif
  791. if (display.epd2.panel == GxEPD2::GDEW0213I5F)
  792. {
  793. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  794. {
  795. display.fillScreen(GxEPD_WHITE);
  796. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  797. display.display();
  798. delay(2000);
  799. }
  800. }
  801. }
  802. #endif
  803. #ifdef _GxBitmaps128x250_H_
  804. void drawBitmaps128x250()
  805. {
  806. #if !defined(__AVR)
  807. const unsigned char* bitmaps[] =
  808. {
  809. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  810. };
  811. #else
  812. const unsigned char* bitmaps[] =
  813. {
  814. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  815. };
  816. #endif
  817. if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
  818. {
  819. bool m = display.mirror(true);
  820. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  821. {
  822. display.fillScreen(GxEPD_WHITE);
  823. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  824. display.display();
  825. delay(2000);
  826. }
  827. display.mirror(m);
  828. }
  829. }
  830. #endif
  831. #ifdef _GxBitmaps128x296_H_
  832. void drawBitmaps128x296()
  833. {
  834. #if !defined(__AVR)
  835. const unsigned char* bitmaps[] =
  836. {
  837. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  838. };
  839. #else
  840. const unsigned char* bitmaps[] =
  841. {
  842. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  843. };
  844. #endif
  845. if (display.epd2.panel == GxEPD2::GDEH029A1)
  846. {
  847. bool m = display.mirror(true);
  848. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  849. {
  850. display.fillScreen(GxEPD_WHITE);
  851. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  852. display.display();
  853. delay(2000);
  854. }
  855. display.mirror(m);
  856. }
  857. }
  858. #endif
  859. #ifdef _GxBitmaps176x264_H_
  860. void drawBitmaps176x264()
  861. {
  862. #if !defined(__AVR)
  863. const unsigned char* bitmaps[] =
  864. {
  865. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  866. };
  867. #else
  868. const unsigned char* bitmaps[] =
  869. {
  870. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  871. };
  872. #endif
  873. if (display.epd2.panel == GxEPD2::GDEW027W3)
  874. {
  875. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  876. {
  877. display.fillScreen(GxEPD_WHITE);
  878. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  879. display.display();
  880. delay(2000);
  881. }
  882. }
  883. }
  884. #endif
  885. #ifdef _GxBitmaps400x300_H_
  886. void drawBitmaps400x300()
  887. {
  888. #if !defined(__AVR)
  889. const unsigned char* bitmaps[] =
  890. {
  891. Bitmap400x300_1, Bitmap400x300_2
  892. };
  893. #else
  894. const unsigned char* bitmaps[] = {}; // not enough code space
  895. #endif
  896. if (display.epd2.panel == GxEPD2::GDEW042T2)
  897. {
  898. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  899. {
  900. display.fillScreen(GxEPD_WHITE);
  901. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  902. display.display();
  903. delay(2000);
  904. }
  905. }
  906. }
  907. #endif
  908. #ifdef _GxBitmaps640x384_H_
  909. void drawBitmaps640x384()
  910. {
  911. #if !defined(__AVR)
  912. const unsigned char* bitmaps[] =
  913. {
  914. Bitmap640x384_1, Bitmap640x384_2
  915. };
  916. #else
  917. const unsigned char* bitmaps[] = {}; // not enough code space
  918. #endif
  919. if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
  920. {
  921. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  922. {
  923. display.fillScreen(GxEPD_WHITE);
  924. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  925. display.display();
  926. delay(2000);
  927. }
  928. }
  929. }
  930. #endif
  931. #ifdef _WS_Bitmaps800x600_H_
  932. void drawBitmaps800x600()
  933. {
  934. #if defined(ESP8266) || defined(ESP32)
  935. if (display.epd2.panel == GxEPD2::ED060SCT)
  936. {
  937. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  938. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  939. delay(2000);
  940. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  941. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  942. // delay(2000);
  943. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  944. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  945. // delay(2000);
  946. }
  947. #endif
  948. }
  949. #endif
  950. struct bitmap_pair
  951. {
  952. const unsigned char* black;
  953. const unsigned char* red;
  954. };
  955. #ifdef _GxBitmaps3c200x200_H_
  956. void drawBitmaps3c200x200()
  957. {
  958. bitmap_pair bitmap_pairs[] =
  959. {
  960. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  961. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  962. };
  963. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  964. {
  965. display.fillScreen(GxEPD_WHITE);
  966. // Bitmap3c200x200_black has 2 bits per pixel
  967. // taken from Adafruit_GFX.cpp, modified
  968. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  969. uint8_t byte = 0;
  970. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  971. {
  972. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  973. {
  974. if (i & 3) byte <<= 2;
  975. else
  976. {
  977. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  978. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  979. #else
  980. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  981. #endif
  982. }
  983. if (!(byte & 0x80))
  984. {
  985. display.drawPixel(i, j, GxEPD_BLACK);
  986. }
  987. }
  988. }
  989. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  990. display.display();
  991. delay(2000);
  992. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  993. {
  994. display.fillScreen(GxEPD_WHITE);
  995. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  996. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  997. display.display();
  998. delay(2000);
  999. }
  1000. }
  1001. if (display.epd2.hasColor)
  1002. {
  1003. display.clearScreen(); // use default for white
  1004. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  1005. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  1006. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1007. {
  1008. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1009. delay(2000);
  1010. }
  1011. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1012. {
  1013. int16_t x = -60;
  1014. int16_t y = -60;
  1015. for (uint16_t j = 0; j < 10; j++)
  1016. {
  1017. display.writeScreenBuffer(); // use default for white
  1018. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1019. display.refresh();
  1020. delay(1000);
  1021. x += 40;
  1022. y += 40;
  1023. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1024. }
  1025. }
  1026. display.writeScreenBuffer(); // use default for white
  1027. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  1028. 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);
  1029. display.refresh();
  1030. delay(2000);
  1031. }
  1032. }
  1033. #endif
  1034. #ifdef _GxBitmaps3c104x212_H_
  1035. void drawBitmaps3c104x212()
  1036. {
  1037. #if !defined(__AVR)
  1038. bitmap_pair bitmap_pairs[] =
  1039. {
  1040. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1041. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1042. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1043. };
  1044. #else
  1045. bitmap_pair bitmap_pairs[] =
  1046. {
  1047. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1048. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1049. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1050. };
  1051. #endif
  1052. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1053. {
  1054. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1055. {
  1056. display.fillScreen(GxEPD_WHITE);
  1057. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1058. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1059. {
  1060. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1061. }
  1062. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1063. display.display();
  1064. delay(2000);
  1065. }
  1066. }
  1067. }
  1068. #endif
  1069. #ifdef _GxBitmaps3c128x296_H_
  1070. void drawBitmaps3c128x296()
  1071. {
  1072. #if !defined(__AVR)
  1073. bitmap_pair bitmap_pairs[] =
  1074. {
  1075. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1076. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1077. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1078. };
  1079. #else
  1080. bitmap_pair bitmap_pairs[] =
  1081. {
  1082. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1083. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1084. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1085. };
  1086. #endif
  1087. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  1088. {
  1089. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1090. {
  1091. display.fillScreen(GxEPD_WHITE);
  1092. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1093. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1094. {
  1095. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1096. }
  1097. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1098. display.display();
  1099. delay(2000);
  1100. }
  1101. }
  1102. }
  1103. #endif
  1104. #ifdef _GxBitmaps3c176x264_H_
  1105. void drawBitmaps3c176x264()
  1106. {
  1107. bitmap_pair bitmap_pairs[] =
  1108. {
  1109. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1110. };
  1111. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1112. {
  1113. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1114. {
  1115. display.fillScreen(GxEPD_WHITE);
  1116. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1117. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1118. display.display();
  1119. delay(2000);
  1120. }
  1121. }
  1122. }
  1123. #endif
  1124. #ifdef _GxBitmaps3c400x300_H_
  1125. void drawBitmaps3c400x300()
  1126. {
  1127. #if !defined(__AVR)
  1128. bitmap_pair bitmap_pairs[] =
  1129. {
  1130. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1131. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1132. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1133. };
  1134. #else
  1135. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1136. #endif
  1137. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1138. {
  1139. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1140. {
  1141. display.fillScreen(GxEPD_WHITE);
  1142. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1143. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1144. display.display();
  1145. delay(2000);
  1146. }
  1147. }
  1148. }
  1149. #endif