GxEPD2_Example.ino 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  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 4.7k 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 4.7k 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 4k7 pull-down
  22. // mapping of Waveshare e-Paper ESP8266 Driver Board
  23. // BUSY -> GPIO16, RST -> GPIO5, 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, use different pin in case
  25. // mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board
  26. // NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD
  27. // BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V
  28. // new mapping suggestion for STM32F1, e.g. STM32F103C8T6 "BluePill"
  29. // BUSY -> A1, RST -> A2, DC -> A3, CS-> A4, CLK -> A5, DIN -> A7
  30. // mapping suggestion for AVR, UNO, NANO etc.
  31. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11
  32. // mapping of Waveshare Universal e-Paper Raw Panel Driver Shield for Arduino / NUCLEO
  33. // BUSY -> 7, RST -> 8, DC -> 9, CS-> 10, CLK -> 13, DIN -> 11
  34. // mapping suggestion for Arduino MEGA
  35. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 53, CLK -> 52, DIN -> 51
  36. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  37. // enable or disable GxEPD2_GFX base class
  38. #define ENABLE_GxEPD2_GFX 0
  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_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDE0213B1, phased out
  47. //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
  48. //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
  49. //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
  50. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  51. //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
  52. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  53. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  54. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  55. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  56. // can use only half buffer size
  57. //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  58. //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  59. //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
  60. // 3-color e-papers
  61. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  62. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  63. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  64. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  65. // can use only half buffer size
  66. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  67. // can use only quarter buffer size
  68. //GxEPD2_3C < GxEPD2_583c, GxEPD2_583c::HEIGHT / 4 > display(GxEPD2_583c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  69. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  70. //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
  71. // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
  72. // HRDY -> 4, RST -> 2, CS -> SS(15), SCK -> SCK(14), MOSI -> MOSI(D7(13)), MISO -> MISO(D6(12)), GND -> GND, 5V -> 5V
  73. // note: 5V supply needs to be exact and strong; 5V pin of USB powered Wemos D1 mini doesn't work!
  74. //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT / 8> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 0, /*RST=*/ 2, /*BUSY=*/ 4));
  75. // ***** for mapping of Waveshare e-Paper ESP8266 Driver Board *****
  76. // select one , can use full buffer size (full HEIGHT)
  77. //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
  78. //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
  79. //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
  80. //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
  81. //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
  82. //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
  83. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  84. //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
  85. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  86. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  87. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  88. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  89. // can use only half buffer size
  90. //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  91. //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  92. //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
  93. // 3-color e-papers
  94. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  95. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  96. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  97. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  98. // can use only half buffer size
  99. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  100. // can use only quarter buffer size
  101. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT / 4> display(GxEPD2_583c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  102. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  103. //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
  104. #endif
  105. #if defined(ESP32)
  106. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  107. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEP015OC1 no longer available
  108. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0154D67
  109. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDE0213B1, phased out
  110. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B72
  111. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B73
  112. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0213I5F
  113. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  114. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW029T5
  115. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  116. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  117. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  118. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  119. //GxEPD2_BW<GxEPD2_583, GxEPD2_583::HEIGHT> display(GxEPD2_583(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  120. //GxEPD2_BW<GxEPD2_750, GxEPD2_750::HEIGHT> display(GxEPD2_750(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  121. //GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(GxEPD2_750_T7(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW075T7 800x480
  122. // 3-color e-papers
  123. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  124. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  125. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  126. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  127. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  128. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT> display(GxEPD2_583c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  129. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT> display(GxEPD2_750c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  130. //GxEPD2_3C<GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT> display(GxEPD2_750c_Z08(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW075Z08 800x480
  131. // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
  132. // HRDY -> 4, RST -> 16, CS -> SS(5), SCK -> SCK(18), MOSI -> MOSI(23), MISO -> MISO(19), GND -> GND, 5V -> 5V
  133. // note: 5V supply needs to be exact and strong; 5V over diode from USB (e.g. Wemos D1 mini) doesn't work!
  134. //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  135. // Waveshare 12.48 b/w SPI display board and frame or Good Display 12.48 b/w panel GDEW1248T3
  136. // general constructor for use with all parameters, e.g. for Waveshare ESP32 driver board mounted on connection board
  137. //GxEPD2_BW < GxEPD2_1248, GxEPD2_1248::HEIGHT / 4 >
  138. //display(GxEPD2_1248(/*sck=*/ 13, /*miso=*/ 12, /*mosi=*/ 14, /*cs_m1=*/ 23, /*cs_s1=*/ 22, /*cs_m2=*/ 16, /*cs_s2=*/ 19,
  139. // /*dc1=*/ 25, /*dc2=*/ 17, /*rst1=*/ 33, /*rst2=*/ 5, /*busy_m1=*/ 32, /*busy_s1=*/ 26, /*busy_m2=*/ 18, /*busy_s2=*/ 4));
  140. #endif
  141. #if defined(_BOARD_GENERIC_STM32F103C_H_)
  142. #define MAX_DISPLAY_BUFFER_SIZE 15000ul // ~15k is a good compromise
  143. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  144. // select one and adapt to your mapping
  145. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEP015OC1 no longer available
  146. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0154D67
  147. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDE0213B1, phased out
  148. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B72
  149. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B73
  150. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0213I5F
  151. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  152. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW029T5
  153. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  154. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  155. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  156. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  157. //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  158. //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  159. //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
  160. // 3-color e-papers
  161. #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))
  162. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  163. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  164. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  165. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  166. //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  167. //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  168. //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  169. //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
  170. #endif
  171. #if defined(__AVR)
  172. #if defined (ARDUINO_AVR_MEGA2560)
  173. #define MAX_DISPLAY_BUFFER_SIZE 5000 // e.g. full height for 200x200
  174. #else
  175. #define MAX_DISPLAY_BUFFER_SIZE 800 //
  176. #endif
  177. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  178. // select one and adapt to your mapping
  179. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEP015OC1 no longer available
  180. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0154D67
  181. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDE0213B1, phased out
  182. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0213B72
  183. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0213B73
  184. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW0213I5F
  185. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  186. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW029T5
  187. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  188. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  189. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  190. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  191. //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  192. //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  193. //GxEPD2_BW<GxEPD2_750_T7, MAX_HEIGHT(GxEPD2_750_T7)> display(GxEPD2_750_T7(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW075T7 800x480
  194. // 3-color e-papers
  195. #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))
  196. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  197. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  198. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  199. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  200. //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  201. //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  202. //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  203. //GxEPD2_3C<GxEPD2_750c_Z08, MAX_HEIGHT_3C(GxEPD2_750c_Z08)> display(GxEPD2_750c_Z08(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW075Z08 800x480
  204. // ***** for mapping of Waveshare Universal e-Paper Raw Panel Driver Shield for Arduino / NUCLEO *****
  205. // the RST line is not connected through level converter, but has a pull up resistor and a pull down diode to the Arduino pin; this is safe for 5V Arduino
  206. // NOTE: the 11-pinholes for pin connectors are not through level converter, and the VCC pin is ~4.2V, only FCP connector pins are through level converter
  207. // NOTE: the VCC pin on the 11-pinholes for pin connectors shouldn't be used, it seems to get back-fed from Arduino data pins through protection diodes of the level converter
  208. // NOTE: the VCC pin should be fed from Arduino 5V pin for use on any 5V Arduino (did they forget to add this connection or add a jumper?)
  209. // select one and adapt to your mapping
  210. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEP015OC1 no longer available
  211. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0154D67
  212. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDE0213B1, phased out
  213. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0213B72
  214. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0213B73
  215. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW0213I5F
  216. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  217. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW029T5
  218. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  219. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  220. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  221. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  222. //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  223. //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  224. //GxEPD2_BW<GxEPD2_750_T7, MAX_HEIGHT(GxEPD2_750_T7)> display(GxEPD2_750_T7(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW075T7 800x480
  225. // 3-color e-papers
  226. #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))
  227. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  228. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  229. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  230. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  231. //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  232. //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  233. //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  234. //GxEPD2_3C<GxEPD2_750c_Z08, MAX_HEIGHT_3C(GxEPD2_750c_Z08)> display(GxEPD2_750c_Z08(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW075Z08 800x480
  235. // Waveshare 12.48 b/w SPI display board and frame or Good Display 12.48 b/w panel GDEW1248T3
  236. // general constructor for use with standard SPI pins, default SCK, MISO and MOSI, for UNO on UNO connectors
  237. //GxEPD2_BW < GxEPD2_1248, MAX_HEIGHT(GxEPD2_1248)>
  238. //display(GxEPD2_1248(/*cs_m1=*/ 2, /*cs_s1=*/ 3, /*cs_m2=*/ A4, /*cs_s2=*/ A0, /*dc1=*/ 6, /*dc2=*/ A3, /*rst1=*/ 5, /*rst2=*/ A2,
  239. // /*busy_m1=*/ 4, /*busy_s1=*/ 7, /*busy_m2=*/ A1, /*busy_s2=*/ A5));
  240. #endif
  241. #include "GxEPD2_boards_added.h"
  242. //#include "GxEPD2_more_boards_added.h" // private
  243. #if !defined(__AVR) && !defined(_BOARD_GENERIC_STM32F103C_H_)
  244. // note 16.11.2019: the compiler may exclude code based on constant if statements (display.epd2.panel == constant),
  245. // therefore bitmaps may get optimized out by the linker
  246. // comment out unused bitmaps to reduce code space used
  247. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  248. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  249. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  250. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  251. #include "bitmaps/Bitmaps152x296.h" // 2.6" b/w
  252. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  253. #include "bitmaps/Bitmaps240x416.h" // 3.71" b/w
  254. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  255. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  256. #include "bitmaps/Bitmaps800x480.h" // 7.5" b/w
  257. // 3-color
  258. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  259. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  260. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  261. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  262. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  263. #if defined(ESP8266) || defined(ESP32)
  264. #include "bitmaps/Bitmaps3c800x480.h" // 7.5" b/w/r
  265. #include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
  266. #endif
  267. #if defined(ESP32)
  268. #include "bitmaps/Bitmaps1304x984.h" // 12.48" b/w
  269. #endif
  270. #else
  271. // select only one to fit in code space
  272. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  273. //#include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  274. //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  275. //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  276. //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  277. ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
  278. ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
  279. // 3-color
  280. //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  281. //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  282. //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  283. //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  284. ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
  285. #endif
  286. void setup()
  287. {
  288. Serial.begin(115200);
  289. Serial.println();
  290. Serial.println("setup");
  291. delay(100);
  292. display.init(115200);
  293. // first update should be full refresh
  294. helloWorld();
  295. delay(1000);
  296. // partial refresh mode can be used to full screen,
  297. // effective if display panel hasFastPartialUpdate
  298. helloFullScreenPartialMode();
  299. delay(1000);
  300. helloArduino();
  301. delay(1000);
  302. helloEpaper();
  303. delay(1000);
  304. //helloValue(123.9, 1);
  305. //delay(1000);
  306. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  307. delay(1000);
  308. drawBitmaps();
  309. if (display.epd2.hasPartialUpdate)
  310. {
  311. showPartialUpdate();
  312. delay(1000);
  313. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  314. //drawCornerTest();
  315. //showBox(16, 16, 48, 32, false);
  316. //showBox(16, 56, 48, 32, true);
  317. display.powerOff();
  318. deepSleepTest();
  319. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  320. drawBitmaps1304x984();
  321. display.powerOff();
  322. #endif
  323. Serial.println("setup done");
  324. }
  325. void loop()
  326. {
  327. }
  328. // note for partial update window and setPartialWindow() method:
  329. // partial update window size and position is on byte boundary in physical x direction
  330. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  331. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  332. const char HelloWorld[] = "Hello World!";
  333. const char HelloArduino[] = "Hello Arduino!";
  334. const char HelloEpaper[] = "Hello E-Paper!";
  335. void helloWorld()
  336. {
  337. //Serial.println("helloWorld");
  338. display.setRotation(1);
  339. display.setFont(&FreeMonoBold9pt7b);
  340. display.setTextColor(GxEPD_BLACK);
  341. int16_t tbx, tby; uint16_t tbw, tbh;
  342. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  343. // center bounding box by transposition of origin:
  344. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  345. uint16_t y = ((display.height() - tbh) / 2) - tby;
  346. display.setFullWindow();
  347. display.firstPage();
  348. do
  349. {
  350. display.fillScreen(GxEPD_WHITE);
  351. display.setCursor(x, y);
  352. display.print(HelloWorld);
  353. }
  354. while (display.nextPage());
  355. //Serial.println("helloWorld done");
  356. }
  357. void helloWorldForDummies()
  358. {
  359. //Serial.println("helloWorld");
  360. const char text[] = "Hello World!";
  361. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  362. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  363. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  364. display.setRotation(1);
  365. // select a suitable font in Adafruit_GFX
  366. display.setFont(&FreeMonoBold9pt7b);
  367. // on e-papers black on white is more pleasant to read
  368. display.setTextColor(GxEPD_BLACK);
  369. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  370. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  371. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  372. // center bounding box by transposition of origin:
  373. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  374. uint16_t y = ((display.height() - tbh) / 2) - tby;
  375. // full window mode is the initial mode, set it anyway
  376. display.setFullWindow();
  377. // here we use paged drawing, even if the processor has enough RAM for full buffer
  378. // so this can be used with any supported processor board.
  379. // the cost in code overhead and execution time penalty is marginal
  380. // tell the graphics class to use paged drawing mode
  381. display.firstPage();
  382. do
  383. {
  384. // this part of code is executed multiple times, as many as needed,
  385. // in case of full buffer it is executed once
  386. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  387. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  388. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  389. display.setCursor(x, y); // set the postition to start printing text
  390. display.print(text); // print some text
  391. // end of part executed multiple times
  392. }
  393. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  394. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  395. // returns true if more pages need be drawn and transferred
  396. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  397. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  398. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  399. while (display.nextPage());
  400. //Serial.println("helloWorld done");
  401. }
  402. void helloFullScreenPartialMode()
  403. {
  404. //Serial.println("helloFullScreenPartialMode");
  405. const char fullscreen[] = "full screen update";
  406. const char fpm[] = "fast partial mode";
  407. const char spm[] = "slow partial mode";
  408. const char npm[] = "no partial mode";
  409. display.setPartialWindow(0, 0, display.width(), display.height());
  410. display.setRotation(1);
  411. display.setFont(&FreeMonoBold9pt7b);
  412. display.setTextColor(GxEPD_BLACK);
  413. const char* updatemode;
  414. if (display.epd2.hasFastPartialUpdate)
  415. {
  416. updatemode = fpm;
  417. }
  418. else if (display.epd2.hasPartialUpdate)
  419. {
  420. updatemode = spm;
  421. }
  422. else
  423. {
  424. updatemode = npm;
  425. }
  426. // do this outside of the loop
  427. int16_t tbx, tby; uint16_t tbw, tbh;
  428. // center update text
  429. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  430. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  431. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  432. // center update mode
  433. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  434. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  435. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  436. // center HelloWorld
  437. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  438. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  439. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  440. display.firstPage();
  441. do
  442. {
  443. display.fillScreen(GxEPD_WHITE);
  444. display.setCursor(hwx, hwy);
  445. display.print(HelloWorld);
  446. display.setCursor(utx, uty);
  447. display.print(fullscreen);
  448. display.setCursor(umx, umy);
  449. display.print(updatemode);
  450. }
  451. while (display.nextPage());
  452. //Serial.println("helloFullScreenPartialMode done");
  453. }
  454. void helloArduino()
  455. {
  456. //Serial.println("helloArduino");
  457. display.setRotation(1);
  458. display.setFont(&FreeMonoBold9pt7b);
  459. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  460. int16_t tbx, tby; uint16_t tbw, tbh;
  461. // align with centered HelloWorld
  462. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  463. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  464. // height might be different
  465. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  466. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  467. // make the window big enough to cover (overwrite) descenders of previous text
  468. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  469. uint16_t wy = (display.height() / 4) - wh / 2;
  470. display.setPartialWindow(0, wy, display.width(), wh);
  471. display.firstPage();
  472. do
  473. {
  474. display.fillScreen(GxEPD_WHITE);
  475. //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
  476. display.setCursor(x, y);
  477. display.print(HelloArduino);
  478. }
  479. while (display.nextPage());
  480. delay(1000);
  481. //Serial.println("helloArduino done");
  482. }
  483. void helloEpaper()
  484. {
  485. //Serial.println("helloEpaper");
  486. display.setRotation(1);
  487. display.setFont(&FreeMonoBold9pt7b);
  488. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  489. int16_t tbx, tby; uint16_t tbw, tbh;
  490. // align with centered HelloWorld
  491. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  492. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  493. // height might be different
  494. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  495. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  496. // make the window big enough to cover (overwrite) descenders of previous text
  497. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  498. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  499. display.setPartialWindow(0, wy, display.width(), wh);
  500. display.firstPage();
  501. do
  502. {
  503. display.fillScreen(GxEPD_WHITE);
  504. display.setCursor(x, y);
  505. display.print(HelloEpaper);
  506. }
  507. while (display.nextPage());
  508. //Serial.println("helloEpaper done");
  509. }
  510. #if defined(ESP8266) || defined(ESP32)
  511. #include <StreamString.h>
  512. #define PrintString StreamString
  513. #else
  514. class PrintString : public Print, public String
  515. {
  516. public:
  517. size_t write(uint8_t data) override
  518. {
  519. return concat(char(data));
  520. };
  521. };
  522. #endif
  523. void helloValue(double v, int digits)
  524. {
  525. //Serial.println("helloValue");
  526. display.setRotation(1);
  527. display.setFont(&FreeMonoBold9pt7b);
  528. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  529. PrintString valueString;
  530. valueString.print(v, digits);
  531. int16_t tbx, tby; uint16_t tbw, tbh;
  532. display.getTextBounds(valueString, 0, 0, &tbx, &tby, &tbw, &tbh);
  533. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  534. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  535. // show what happens, if we use the bounding box for partial window
  536. uint16_t wx = (display.width() - tbw) / 2;
  537. uint16_t wy = (display.height() * 3 / 4) - tbh / 2;
  538. display.setPartialWindow(wx, wy, tbw, tbh);
  539. display.firstPage();
  540. do
  541. {
  542. display.fillScreen(GxEPD_WHITE);
  543. display.setCursor(x, y);
  544. display.print(valueString);
  545. }
  546. while (display.nextPage());
  547. delay(2000);
  548. // make the partial window big enough to cover the previous text
  549. uint16_t ww = tbw; // remember window width
  550. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  551. // adjust, because HelloEpaper was aligned, not centered (could calculate this to be precise)
  552. ww = max(ww, uint16_t(tbw + 12)); // 12 seems ok
  553. wx = (display.width() - tbw) / 2;
  554. // make the window big enough to cover (overwrite) descenders of previous text
  555. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  556. wy = (display.height() * 3 / 4) - wh / 2;
  557. display.setPartialWindow(wx, wy, ww, wh);
  558. // alternately use the whole width for partial window
  559. //display.setPartialWindow(0, wy, display.width(), wh);
  560. display.firstPage();
  561. do
  562. {
  563. display.fillScreen(GxEPD_WHITE);
  564. display.setCursor(x, y);
  565. display.print(valueString);
  566. }
  567. while (display.nextPage());
  568. //Serial.println("helloValue done");
  569. }
  570. void deepSleepTest()
  571. {
  572. //Serial.println("deepSleepTest");
  573. const char hibernating[] = "hibernating ...";
  574. const char wokeup[] = "woke up";
  575. const char from[] = "from deep sleep";
  576. const char again[] = "again";
  577. display.setRotation(1);
  578. display.setFont(&FreeMonoBold9pt7b);
  579. display.setTextColor(GxEPD_BLACK);
  580. int16_t tbx, tby; uint16_t tbw, tbh;
  581. // center text
  582. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  583. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  584. uint16_t y = ((display.height() - tbh) / 2) - tby;
  585. display.setFullWindow();
  586. display.firstPage();
  587. do
  588. {
  589. display.fillScreen(GxEPD_WHITE);
  590. display.setCursor(x, y);
  591. display.print(hibernating);
  592. }
  593. while (display.nextPage());
  594. display.hibernate();
  595. delay(5000);
  596. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  597. uint16_t wx = (display.width() - tbw) / 2;
  598. uint16_t wy = (display.height() / 3) + tbh / 2; // y is base line!
  599. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  600. uint16_t fx = (display.width() - tbw) / 2;
  601. uint16_t fy = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  602. display.firstPage();
  603. do
  604. {
  605. display.fillScreen(GxEPD_WHITE);
  606. display.setCursor(wx, wy);
  607. display.print(wokeup);
  608. display.setCursor(fx, fy);
  609. display.print(from);
  610. }
  611. while (display.nextPage());
  612. delay(5000);
  613. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  614. uint16_t hx = (display.width() - tbw) / 2;
  615. uint16_t hy = (display.height() / 3) + tbh / 2; // y is base line!
  616. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  617. uint16_t ax = (display.width() - tbw) / 2;
  618. uint16_t ay = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  619. display.firstPage();
  620. do
  621. {
  622. display.fillScreen(GxEPD_WHITE);
  623. display.setCursor(hx, hy);
  624. display.print(hibernating);
  625. display.setCursor(ax, ay);
  626. display.print(again);
  627. }
  628. while (display.nextPage());
  629. display.hibernate();
  630. //Serial.println("deepSleepTest done");
  631. }
  632. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  633. {
  634. //Serial.println("showBox");
  635. display.setRotation(1);
  636. if (partial)
  637. {
  638. display.setPartialWindow(x, y, w, h);
  639. }
  640. else
  641. {
  642. display.setFullWindow();
  643. }
  644. display.firstPage();
  645. do
  646. {
  647. display.fillScreen(GxEPD_WHITE);
  648. display.fillRect(x, y, w, h, GxEPD_BLACK);
  649. }
  650. while (display.nextPage());
  651. //Serial.println("showBox done");
  652. }
  653. void drawCornerTest()
  654. {
  655. display.setFullWindow();
  656. display.setFont(&FreeMonoBold9pt7b);
  657. display.setTextColor(GxEPD_BLACK);
  658. for (uint16_t r = 0; r <= 4; r++)
  659. {
  660. display.setRotation(r);
  661. display.firstPage();
  662. do
  663. {
  664. display.fillScreen(GxEPD_WHITE);
  665. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  666. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  667. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  668. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  669. display.setCursor(display.width() / 2, display.height() / 2);
  670. display.print(display.getRotation());
  671. }
  672. while (display.nextPage());
  673. delay(2000);
  674. }
  675. }
  676. void showFont(const char name[], const GFXfont* f)
  677. {
  678. display.setFullWindow();
  679. display.setRotation(0);
  680. display.setTextColor(GxEPD_BLACK);
  681. display.firstPage();
  682. do
  683. {
  684. drawFont(name, f);
  685. }
  686. while (display.nextPage());
  687. }
  688. void drawFont(const char name[], const GFXfont* f)
  689. {
  690. //display.setRotation(0);
  691. display.fillScreen(GxEPD_WHITE);
  692. display.setTextColor(GxEPD_BLACK);
  693. display.setFont(f);
  694. display.setCursor(0, 0);
  695. display.println();
  696. display.println(name);
  697. display.println(" !\"#$%&'()*+,-./");
  698. display.println("0123456789:;<=>?");
  699. display.println("@ABCDEFGHIJKLMNO");
  700. display.println("PQRSTUVWXYZ[\\]^_");
  701. if (display.epd2.hasColor)
  702. {
  703. display.setTextColor(GxEPD_RED);
  704. }
  705. display.println("`abcdefghijklmno");
  706. display.println("pqrstuvwxyz{|}~ ");
  707. }
  708. // note for partial update window and setPartialWindow() method:
  709. // partial update window size and position is on byte boundary in physical x direction
  710. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  711. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  712. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  713. void showPartialUpdate()
  714. {
  715. // some useful background
  716. helloWorld();
  717. // use asymmetric values for test
  718. uint16_t box_x = 10;
  719. uint16_t box_y = 15;
  720. uint16_t box_w = 70;
  721. uint16_t box_h = 20;
  722. uint16_t cursor_y = box_y + box_h - 6;
  723. float value = 13.95;
  724. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  725. display.setFont(&FreeMonoBold9pt7b);
  726. display.setTextColor(GxEPD_BLACK);
  727. // show where the update box is
  728. for (uint16_t r = 0; r < 4; r++)
  729. {
  730. display.setRotation(r);
  731. display.setPartialWindow(box_x, box_y, box_w, box_h);
  732. display.firstPage();
  733. do
  734. {
  735. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  736. //display.fillScreen(GxEPD_BLACK);
  737. }
  738. while (display.nextPage());
  739. delay(2000);
  740. display.firstPage();
  741. do
  742. {
  743. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  744. }
  745. while (display.nextPage());
  746. delay(1000);
  747. }
  748. //return;
  749. // show updates in the update box
  750. for (uint16_t r = 0; r < 4; r++)
  751. {
  752. display.setRotation(r);
  753. display.setPartialWindow(box_x, box_y, box_w, box_h);
  754. for (uint16_t i = 1; i <= 10; i += incr)
  755. {
  756. display.firstPage();
  757. do
  758. {
  759. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  760. display.setCursor(box_x, cursor_y);
  761. display.print(value * i, 2);
  762. }
  763. while (display.nextPage());
  764. delay(500);
  765. }
  766. delay(1000);
  767. display.firstPage();
  768. do
  769. {
  770. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  771. }
  772. while (display.nextPage());
  773. delay(1000);
  774. }
  775. }
  776. void drawBitmaps()
  777. {
  778. display.setFullWindow();
  779. #ifdef _GxBitmaps104x212_H_
  780. drawBitmaps104x212();
  781. #endif
  782. #ifdef _GxBitmaps128x250_H_
  783. drawBitmaps128x250();
  784. #endif
  785. #ifdef _GxBitmaps128x296_H_
  786. drawBitmaps128x296();
  787. #endif
  788. #ifdef _GxBitmaps176x264_H_
  789. drawBitmaps176x264();
  790. #endif
  791. #ifdef _GxBitmaps400x300_H_
  792. drawBitmaps400x300();
  793. #endif
  794. #ifdef _GxBitmaps640x384_H_
  795. drawBitmaps640x384();
  796. #endif
  797. #ifdef _GxBitmaps800x480_H_
  798. drawBitmaps800x480();
  799. #endif
  800. #ifdef _WS_Bitmaps800x600_H_
  801. drawBitmaps800x600();
  802. #endif
  803. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  804. drawBitmaps1304x984();
  805. #endif
  806. // 3-color
  807. #ifdef _GxBitmaps3c104x212_H_
  808. drawBitmaps3c104x212();
  809. #endif
  810. #ifdef _GxBitmaps3c128x296_H_
  811. drawBitmaps3c128x296();
  812. #endif
  813. #ifdef _GxBitmaps152x296_H_
  814. drawBitmaps152x296();
  815. #endif
  816. #ifdef _GxBitmaps3c176x264_H_
  817. drawBitmaps3c176x264();
  818. #endif
  819. #ifdef _GxBitmaps240x416_H_
  820. drawBitmaps240x416();
  821. #endif
  822. #ifdef _GxBitmaps3c400x300_H_
  823. drawBitmaps3c400x300();
  824. #endif
  825. #ifdef _GxBitmaps3c800x480_H_
  826. drawBitmaps3c800x480();
  827. #endif
  828. // show these after the specific bitmaps
  829. #ifdef _GxBitmaps200x200_H_
  830. drawBitmaps200x200();
  831. #endif
  832. // 3-color
  833. #ifdef _GxBitmaps3c200x200_H_
  834. drawBitmaps3c200x200();
  835. #endif
  836. }
  837. #ifdef _GxBitmaps200x200_H_
  838. void drawBitmaps200x200()
  839. {
  840. #if defined(ARDUINO_AVR_PRO)
  841. const unsigned char* bitmaps[] =
  842. {
  843. logo200x200
  844. };
  845. #elif defined(__AVR)
  846. const unsigned char* bitmaps[] =
  847. {
  848. logo200x200, first200x200
  849. };
  850. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  851. const unsigned char* bitmaps[] =
  852. {
  853. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  854. };
  855. #else
  856. const unsigned char* bitmaps[] =
  857. {
  858. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  859. };
  860. #endif
  861. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  862. {
  863. bool m = display.mirror(true);
  864. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  865. {
  866. display.firstPage();
  867. do
  868. {
  869. display.fillScreen(GxEPD_WHITE);
  870. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  871. }
  872. while (display.nextPage());
  873. delay(2000);
  874. }
  875. display.mirror(m);
  876. }
  877. //else
  878. {
  879. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  880. display.clearScreen(); // use default for white
  881. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  882. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  883. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  884. {
  885. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  886. delay(2000);
  887. }
  888. }
  889. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  890. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  891. {
  892. int16_t x = -60;
  893. int16_t y = -60;
  894. for (uint16_t j = 0; j < 10; j++)
  895. {
  896. display.writeScreenBuffer(); // use default for white
  897. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  898. display.refresh(true);
  899. if (display.epd2.hasFastPartialUpdate)
  900. {
  901. // for differential update: set previous buffer equal to current buffer in controller
  902. display.epd2.writeScreenBufferAgain(); // use default for white
  903. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  904. }
  905. delay(2000);
  906. x += 40;
  907. y += 40;
  908. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  909. }
  910. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  911. break; // comment out for full show
  912. }
  913. display.writeScreenBuffer(); // use default for white
  914. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  915. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  916. display.refresh(true);
  917. // for differential update: set previous buffer equal to current buffer in controller
  918. display.epd2.writeScreenBufferAgain(); // use default for white
  919. display.epd2.writeImageAgain(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  920. display.epd2.writeImageAgain(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  921. delay(2000);
  922. }
  923. #endif
  924. #ifdef _GxBitmaps104x212_H_
  925. void drawBitmaps104x212()
  926. {
  927. #if !defined(__AVR)
  928. const unsigned char* bitmaps[] =
  929. {
  930. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  931. };
  932. #else
  933. const unsigned char* bitmaps[] =
  934. {
  935. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  936. };
  937. #endif
  938. if (display.epd2.panel == GxEPD2::GDEW0213I5F)
  939. {
  940. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  941. {
  942. display.firstPage();
  943. do
  944. {
  945. display.fillScreen(GxEPD_WHITE);
  946. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  947. }
  948. while (display.nextPage());
  949. delay(2000);
  950. }
  951. }
  952. }
  953. #endif
  954. #ifdef _GxBitmaps128x250_H_
  955. void drawBitmaps128x250()
  956. {
  957. #if !defined(__AVR)
  958. const unsigned char* bitmaps[] =
  959. {
  960. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  961. };
  962. #else
  963. const unsigned char* bitmaps[] =
  964. {
  965. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  966. };
  967. #endif
  968. if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
  969. {
  970. bool m = display.mirror(true);
  971. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  972. {
  973. display.firstPage();
  974. do
  975. {
  976. display.fillScreen(GxEPD_WHITE);
  977. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  978. }
  979. while (display.nextPage());
  980. delay(2000);
  981. }
  982. display.mirror(m);
  983. }
  984. }
  985. #endif
  986. #ifdef _GxBitmaps128x296_H_
  987. void drawBitmaps128x296()
  988. {
  989. #if !defined(__AVR)
  990. const unsigned char* bitmaps[] =
  991. {
  992. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  993. };
  994. #else
  995. const unsigned char* bitmaps[] =
  996. {
  997. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  998. };
  999. #endif
  1000. if (display.epd2.panel == GxEPD2::GDEH029A1)
  1001. {
  1002. bool m = display.mirror(true);
  1003. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1004. {
  1005. display.firstPage();
  1006. do
  1007. {
  1008. display.fillScreen(GxEPD_WHITE);
  1009. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1010. }
  1011. while (display.nextPage());
  1012. delay(2000);
  1013. }
  1014. display.mirror(m);
  1015. }
  1016. }
  1017. #endif
  1018. #ifdef _GxBitmaps152x296_H_
  1019. void drawBitmaps152x296()
  1020. {
  1021. #if !defined(__AVR)
  1022. const unsigned char* bitmaps[] =
  1023. {
  1024. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  1025. };
  1026. #else
  1027. const unsigned char* bitmaps[] =
  1028. {
  1029. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  1030. };
  1031. #endif
  1032. if (display.epd2.panel == GxEPD2::GDEW026T0)
  1033. {
  1034. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1035. {
  1036. display.firstPage();
  1037. do
  1038. {
  1039. display.fillScreen(GxEPD_WHITE);
  1040. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1041. }
  1042. while (display.nextPage());
  1043. delay(2000);
  1044. }
  1045. }
  1046. }
  1047. #endif
  1048. #ifdef _GxBitmaps176x264_H_
  1049. void drawBitmaps176x264()
  1050. {
  1051. #if !defined(__AVR)
  1052. const unsigned char* bitmaps[] =
  1053. {
  1054. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1055. };
  1056. #else
  1057. const unsigned char* bitmaps[] =
  1058. {
  1059. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1060. };
  1061. #endif
  1062. if (display.epd2.panel == GxEPD2::GDEW027W3)
  1063. {
  1064. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1065. {
  1066. display.firstPage();
  1067. do
  1068. {
  1069. display.fillScreen(GxEPD_WHITE);
  1070. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1071. }
  1072. while (display.nextPage());
  1073. delay(2000);
  1074. }
  1075. }
  1076. }
  1077. #endif
  1078. #ifdef _GxBitmaps240x416_H_
  1079. void drawBitmaps240x416()
  1080. {
  1081. #if !defined(__AVR)
  1082. const unsigned char* bitmaps[] =
  1083. {
  1084. Bitmap240x416_1, Bitmap240x416_2, Bitmap240x416_3
  1085. };
  1086. #else
  1087. const unsigned char* bitmaps[] =
  1088. {
  1089. Bitmap240x460_1, Bitmap240x460_2, Bitmap240x460_3
  1090. };
  1091. #endif
  1092. if (display.epd2.panel == GxEPD2::GDEW0371W7)
  1093. {
  1094. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1095. {
  1096. display.firstPage();
  1097. do
  1098. {
  1099. display.fillScreen(GxEPD_WHITE);
  1100. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1101. }
  1102. while (display.nextPage());
  1103. delay(2000);
  1104. }
  1105. }
  1106. }
  1107. #endif
  1108. #ifdef _GxBitmaps400x300_H_
  1109. void drawBitmaps400x300()
  1110. {
  1111. #if !defined(__AVR)
  1112. const unsigned char* bitmaps[] =
  1113. {
  1114. Bitmap400x300_1, Bitmap400x300_2
  1115. };
  1116. #else
  1117. const unsigned char* bitmaps[] = {}; // not enough code space
  1118. #endif
  1119. if (display.epd2.panel == GxEPD2::GDEW042T2)
  1120. {
  1121. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1122. {
  1123. display.firstPage();
  1124. do
  1125. {
  1126. display.fillScreen(GxEPD_WHITE);
  1127. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1128. }
  1129. while (display.nextPage());
  1130. delay(2000);
  1131. }
  1132. }
  1133. }
  1134. #endif
  1135. #ifdef _GxBitmaps640x384_H_
  1136. void drawBitmaps640x384()
  1137. {
  1138. #if !defined(__AVR)
  1139. const unsigned char* bitmaps[] =
  1140. {
  1141. Bitmap640x384_1, Bitmap640x384_2
  1142. };
  1143. #else
  1144. const unsigned char* bitmaps[] = {}; // not enough code space
  1145. #endif
  1146. if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
  1147. {
  1148. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1149. {
  1150. display.firstPage();
  1151. do
  1152. {
  1153. display.fillScreen(GxEPD_WHITE);
  1154. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1155. }
  1156. while (display.nextPage());
  1157. delay(2000);
  1158. }
  1159. }
  1160. }
  1161. #endif
  1162. #ifdef _GxBitmaps800x480_H_
  1163. void drawBitmaps800x480()
  1164. {
  1165. #if !defined(__AVR)
  1166. const unsigned char* bitmaps[] =
  1167. {
  1168. Bitmap800x480_1, Bitmap800x480_2, Bitmap800x480_3, Bitmap800x480_4
  1169. };
  1170. #else
  1171. const unsigned char* bitmaps[] = {}; // not enough code space
  1172. #endif
  1173. if ((display.epd2.panel == GxEPD2::GDEW075T7) || (display.epd2.panel == GxEPD2::GDEW075Z08))
  1174. {
  1175. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1176. {
  1177. display.firstPage();
  1178. do
  1179. {
  1180. display.fillScreen(GxEPD_WHITE);
  1181. //display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1182. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1183. }
  1184. while (display.nextPage());
  1185. delay(2000);
  1186. }
  1187. if (display.epd2.panel == GxEPD2::GDEW075T7)
  1188. {
  1189. // avoid ghosting caused by OTP waveform
  1190. display.clearScreen();
  1191. display.refresh(false); // full update
  1192. }
  1193. }
  1194. }
  1195. #endif
  1196. #ifdef _WS_Bitmaps800x600_H_
  1197. void drawBitmaps800x600()
  1198. {
  1199. #if defined(ESP8266) || defined(ESP32)
  1200. if (display.epd2.panel == GxEPD2::ED060SCT)
  1201. {
  1202. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  1203. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  1204. delay(2000);
  1205. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  1206. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  1207. // delay(2000);
  1208. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  1209. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  1210. // delay(2000);
  1211. }
  1212. #endif
  1213. }
  1214. #endif
  1215. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  1216. void drawBitmaps1304x984()
  1217. {
  1218. if (display.epd2.panel == GxEPD2::GDEW1248T3)
  1219. {
  1220. display.drawImage(Bitmap1304x984, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1221. }
  1222. }
  1223. #endif
  1224. struct bitmap_pair
  1225. {
  1226. const unsigned char* black;
  1227. const unsigned char* red;
  1228. };
  1229. #ifdef _GxBitmaps3c200x200_H_
  1230. void drawBitmaps3c200x200()
  1231. {
  1232. bitmap_pair bitmap_pairs[] =
  1233. {
  1234. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  1235. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  1236. };
  1237. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  1238. {
  1239. display.firstPage();
  1240. do
  1241. {
  1242. display.fillScreen(GxEPD_WHITE);
  1243. // Bitmap3c200x200_black has 2 bits per pixel
  1244. // taken from Adafruit_GFX.cpp, modified
  1245. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  1246. uint8_t byte = 0;
  1247. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  1248. {
  1249. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  1250. {
  1251. if (i & 3) byte <<= 2;
  1252. else
  1253. {
  1254. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  1255. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  1256. #else
  1257. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  1258. #endif
  1259. }
  1260. if (!(byte & 0x80))
  1261. {
  1262. display.drawPixel(i, j, GxEPD_BLACK);
  1263. }
  1264. }
  1265. }
  1266. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1267. }
  1268. while (display.nextPage());
  1269. delay(2000);
  1270. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1271. {
  1272. display.firstPage();
  1273. do
  1274. {
  1275. display.fillScreen(GxEPD_WHITE);
  1276. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1277. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1278. }
  1279. while (display.nextPage());
  1280. delay(2000);
  1281. }
  1282. }
  1283. if (display.epd2.hasColor)
  1284. {
  1285. display.clearScreen(); // use default for white
  1286. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  1287. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  1288. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1289. {
  1290. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1291. delay(2000);
  1292. }
  1293. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1294. {
  1295. int16_t x = -60;
  1296. int16_t y = -60;
  1297. for (uint16_t j = 0; j < 10; j++)
  1298. {
  1299. display.writeScreenBuffer(); // use default for white
  1300. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1301. display.refresh();
  1302. delay(1000);
  1303. x += 40;
  1304. y += 40;
  1305. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1306. }
  1307. }
  1308. display.writeScreenBuffer(); // use default for white
  1309. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  1310. 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);
  1311. display.refresh();
  1312. delay(2000);
  1313. }
  1314. }
  1315. #endif
  1316. #ifdef _GxBitmaps3c104x212_H_
  1317. void drawBitmaps3c104x212()
  1318. {
  1319. #if !defined(__AVR)
  1320. bitmap_pair bitmap_pairs[] =
  1321. {
  1322. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1323. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1324. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1325. };
  1326. #else
  1327. bitmap_pair bitmap_pairs[] =
  1328. {
  1329. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1330. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1331. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1332. };
  1333. #endif
  1334. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1335. {
  1336. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1337. {
  1338. display.firstPage();
  1339. do
  1340. {
  1341. display.fillScreen(GxEPD_WHITE);
  1342. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1343. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1344. {
  1345. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1346. }
  1347. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1348. }
  1349. while (display.nextPage());
  1350. delay(2000);
  1351. }
  1352. }
  1353. }
  1354. #endif
  1355. #ifdef _GxBitmaps3c128x296_H_
  1356. void drawBitmaps3c128x296()
  1357. {
  1358. #if !defined(__AVR)
  1359. bitmap_pair bitmap_pairs[] =
  1360. {
  1361. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1362. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1363. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1364. };
  1365. #else
  1366. bitmap_pair bitmap_pairs[] =
  1367. {
  1368. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1369. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1370. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1371. };
  1372. #endif
  1373. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  1374. {
  1375. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1376. {
  1377. display.firstPage();
  1378. do
  1379. {
  1380. display.fillScreen(GxEPD_WHITE);
  1381. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1382. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1383. {
  1384. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1385. }
  1386. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1387. }
  1388. while (display.nextPage());
  1389. delay(2000);
  1390. }
  1391. }
  1392. }
  1393. #endif
  1394. #ifdef _GxBitmaps3c176x264_H_
  1395. void drawBitmaps3c176x264()
  1396. {
  1397. bitmap_pair bitmap_pairs[] =
  1398. {
  1399. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1400. };
  1401. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1402. {
  1403. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1404. {
  1405. display.firstPage();
  1406. do
  1407. {
  1408. display.fillScreen(GxEPD_WHITE);
  1409. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1410. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1411. }
  1412. while (display.nextPage());
  1413. delay(2000);
  1414. }
  1415. }
  1416. }
  1417. #endif
  1418. #ifdef _GxBitmaps3c400x300_H_
  1419. void drawBitmaps3c400x300()
  1420. {
  1421. #if !defined(__AVR)
  1422. bitmap_pair bitmap_pairs[] =
  1423. {
  1424. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1425. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1426. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1427. };
  1428. #else
  1429. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1430. #endif
  1431. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1432. {
  1433. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1434. {
  1435. display.firstPage();
  1436. do
  1437. {
  1438. display.fillScreen(GxEPD_WHITE);
  1439. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1440. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1441. }
  1442. while (display.nextPage());
  1443. delay(2000);
  1444. }
  1445. }
  1446. }
  1447. #endif
  1448. #ifdef _GxBitmaps3c800x480_H_
  1449. void drawBitmaps3c800x480()
  1450. {
  1451. #if !defined(__AVR)
  1452. bitmap_pair bitmap_pairs[] =
  1453. {
  1454. {Bitmap3c800x480_1_black, Bitmap3c800x480_1_red}
  1455. };
  1456. #else
  1457. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1458. #endif
  1459. if (display.epd2.panel == GxEPD2::GDEW075Z08)
  1460. {
  1461. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1462. {
  1463. display.firstPage();
  1464. do
  1465. {
  1466. display.fillScreen(GxEPD_WHITE);
  1467. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1468. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1469. }
  1470. while (display.nextPage());
  1471. delay(2000);
  1472. }
  1473. }
  1474. }
  1475. #endif