GxEPD2_Example.ino 71 KB

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