GxEPD2_Example.ino 49 KB

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