GxEPD2_NotPagedExample.ino 54 KB

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