GxEPD2_NotPagedExample.ino 51 KB

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