GxEPD2_NotPagedExample.ino 55 KB

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