GxEPD2_Example.ino 63 KB

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