GxEPD2_Example.ino 69 KB

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