GxEPD2_NotPagedExample.ino 53 KB

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