GxEPD2_PagedDisplayUsingCallback.ino 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  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. // mapping suggestion from Waveshare SPI e-Paper to generic ESP8266
  17. // BUSY -> GPIO4, RST -> GPIO2, DC -> GPIO0, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
  18. // mapping of Waveshare e-Paper ESP8266 Driver Board
  19. // BUSY -> GPIO16, RST -> GPIO5, DC -> GPIO4, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
  20. // mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board
  21. // NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD
  22. // BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V
  23. // new mapping suggestion for STM32F1, e.g. STM32F103C8T6 "BluePill"
  24. // BUSY -> A1, RST -> A2, DC -> A3, CS-> A4, CLK -> A5, DIN -> A7
  25. // mapping suggestion for AVR, UNO, NANO etc.
  26. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11
  27. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  28. // enable or disable GxEPD2_GFX base class
  29. #define ENABLE_GxEPD2_GFX 0
  30. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  31. //#include <GFX.h>
  32. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  33. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  34. #include <GxEPD2_BW.h>
  35. #include <GxEPD2_3C.h>
  36. #include <Fonts/FreeMonoBold9pt7b.h>
  37. #if defined (ESP8266)
  38. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  39. //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
  40. //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
  41. //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
  42. //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
  43. //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
  44. //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
  45. //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
  46. //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
  47. //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
  48. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  49. //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
  50. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  51. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  52. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  53. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  54. // can use only half buffer size
  55. //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  56. //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));
  57. //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  58. //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
  59. // 3-color e-papers
  60. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  61. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  62. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  63. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  64. // can use only half buffer size
  65. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  66. // can use only quarter buffer size
  67. //GxEPD2_3C < GxEPD2_583c, GxEPD2_583c::HEIGHT / 4 > display(GxEPD2_583c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  68. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
  69. //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
  70. // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
  71. // HRDY -> 4, RST -> 2, CS -> SS(15), SCK -> SCK(14), MOSI -> MOSI(D7(13)), MISO -> MISO(D6(12)), GND -> GND, 5V -> 5V
  72. // note: 5V supply needs to be exact and strong; 5V pin of USB powered Wemos D1 mini doesn't work!
  73. //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT / 8> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 0, /*RST=*/ 2, /*BUSY=*/ 4));
  74. // ***** for mapping of Waveshare e-Paper ESP8266 Driver Board *****
  75. // select one , can use full buffer size (full HEIGHT)
  76. //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
  77. //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
  78. //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
  79. //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
  80. //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
  81. //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
  82. //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
  83. //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
  84. //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
  85. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  86. //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
  87. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  88. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  89. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  90. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  91. // can use only half buffer size
  92. //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  93. //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));
  94. //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  95. //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
  96. // 3-color e-papers
  97. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  98. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  99. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  100. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  101. // can use only half buffer size
  102. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  103. // can use only quarter buffer size
  104. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT / 4> display(GxEPD2_583c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  105. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
  106. //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
  107. #endif
  108. #if defined(ESP32)
  109. // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
  110. //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEP015OC1 no longer available
  111. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0154D67
  112. //GxEPD2_BW<GxEPD2_154_T8, GxEPD2_154_T8::HEIGHT> display(GxEPD2_154_T8(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154T8 152x152
  113. //GxEPD2_BW<GxEPD2_154_M09, GxEPD2_154_M09::HEIGHT> display(GxEPD2_154_M09(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154M09 200x200
  114. //GxEPD2_BW<GxEPD2_154_M10, GxEPD2_154_M10::HEIGHT> display(GxEPD2_154_M10(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0154M10 152x152
  115. //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDE0213B1, phased out
  116. //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B72
  117. //GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B73
  118. //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0213I5F
  119. //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  120. //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW029T5
  121. //GxEPD2_BW<GxEPD2_260, GxEPD2_260::HEIGHT> display(GxEPD2_260(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  122. //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  123. //GxEPD2_BW<GxEPD2_371, GxEPD2_371::HEIGHT> display(GxEPD2_371(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  124. //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  125. //GxEPD2_BW<GxEPD2_583, GxEPD2_583::HEIGHT> display(GxEPD2_583(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  126. //GxEPD2_BW<GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT> display(GxEPD2_583_T8(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  127. //GxEPD2_BW<GxEPD2_750, GxEPD2_750::HEIGHT> display(GxEPD2_750(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  128. //GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(GxEPD2_750_T7(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW075T7 800x480
  129. // 3-color e-papers
  130. //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  131. //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  132. //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  133. //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  134. //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  135. //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT> display(GxEPD2_583c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  136. //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT> display(GxEPD2_750c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  137. //GxEPD2_3C<GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT> display(GxEPD2_750c_Z08(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW075Z08 800x480
  138. // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
  139. // HRDY -> 4, RST -> 16, CS -> SS(5), SCK -> SCK(18), MOSI -> MOSI(23), MISO -> MISO(19), GND -> GND, 5V -> 5V
  140. // note: 5V supply needs to be exact and strong; 5V over diode from USB (e.g. Wemos D1 mini) doesn't work!
  141. //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
  142. // Waveshare 12.48 b/w SPI display board and frame or Good Display 12.48 b/w panel GDEW1248T3
  143. // general constructor for use with all parameters, e.g. for Waveshare ESP32 driver board mounted on connection board
  144. //GxEPD2_BW < GxEPD2_1248, GxEPD2_1248::HEIGHT / 4 >
  145. //display(GxEPD2_1248(/*sck=*/ 13, /*miso=*/ 12, /*mosi=*/ 14, /*cs_m1=*/ 23, /*cs_s1=*/ 22, /*cs_m2=*/ 16, /*cs_s2=*/ 19,
  146. // /*dc1=*/ 25, /*dc2=*/ 17, /*rst1=*/ 33, /*rst2=*/ 5, /*busy_m1=*/ 32, /*busy_s1=*/ 26, /*busy_m2=*/ 18, /*busy_s2=*/ 4));
  147. #endif
  148. #if defined(_BOARD_GENERIC_STM32F103C_H_)
  149. #define MAX_DISPLAY_BUFFER_SIZE 15000ul // ~15k is a good compromise
  150. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  151. // select one and adapt to your mapping
  152. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEP015OC1 no longer available
  153. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0154D67
  154. //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
  155. //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
  156. //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
  157. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDE0213B1, phased out
  158. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B72
  159. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B73
  160. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0213I5F
  161. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  162. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW029T5
  163. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  164. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  165. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  166. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  167. //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  168. //GxEPD2_BW <GxEPD2_583_T8, MAX_HEIGHT(GxEPD2_583_T8)> display(GxEPD2_583_T8(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  169. //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  170. //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
  171. // 3-color e-papers
  172. #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))
  173. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  174. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  175. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  176. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  177. //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  178. //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  179. //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
  180. //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
  181. #endif
  182. #if defined(__AVR)
  183. #if defined (ARDUINO_AVR_MEGA2560)
  184. #define MAX_DISPLAY_BUFFER_SIZE 5000 // e.g. full height for 200x200
  185. #else
  186. #define MAX_DISPLAY_BUFFER_SIZE 800 //
  187. #endif
  188. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  189. // select one and adapt to your mapping
  190. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEP015OC1 no longer available
  191. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0154D67
  192. //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
  193. //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
  194. //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
  195. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDE0213B1, phased out
  196. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0213B72
  197. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0213B73
  198. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW0213I5F
  199. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  200. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW029T5
  201. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  202. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  203. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  204. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  205. //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  206. //GxEPD2_BW <GxEPD2_583_T8, MAX_HEIGHT(GxEPD2_583_T8)> display(GxEPD2_583_T8(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  207. //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  208. //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
  209. // 3-color e-papers
  210. #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))
  211. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  212. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  213. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  214. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  215. //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  216. //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  217. //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
  218. //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
  219. // ***** for mapping of Waveshare Universal e-Paper Raw Panel Driver Shield for Arduino / NUCLEO *****
  220. // 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
  221. // 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
  222. // 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
  223. // 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?)
  224. // select one and adapt to your mapping
  225. //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEP015OC1 no longer available
  226. //GxEPD2_BW<GxEPD2_154_D67, MAX_HEIGHT(GxEPD2_154_D67)> display(GxEPD2_154_D67(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0154D67
  227. //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
  228. //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
  229. //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
  230. //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDE0213B1, phased out
  231. //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0213B72
  232. //GxEPD2_BW<GxEPD2_213_B73, MAX_HEIGHT(GxEPD2_213_B73)> display(GxEPD2_213_B73(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0213B73
  233. //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW0213I5F
  234. //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  235. //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW029T5
  236. //GxEPD2_BW<GxEPD2_260, MAX_HEIGHT(GxEPD2_260)> display(GxEPD2_260(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  237. //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  238. //GxEPD2_BW<GxEPD2_371, MAX_HEIGHT(GxEPD2_371)> display(GxEPD2_371(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  239. //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  240. //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  241. //GxEPD2_BW <GxEPD2_583_T8, MAX_HEIGHT(GxEPD2_583_T8)> display(GxEPD2_583_T8(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  242. //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  243. //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
  244. // 3-color e-papers
  245. #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))
  246. //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  247. //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  248. //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  249. //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  250. //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  251. //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  252. //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
  253. //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
  254. // Waveshare 12.48 b/w SPI display board and frame or Good Display 12.48 b/w panel GDEW1248T3
  255. // general constructor for use with standard SPI pins, default SCK, MISO and MOSI, for UNO on UNO connectors
  256. //GxEPD2_BW < GxEPD2_1248, MAX_HEIGHT(GxEPD2_1248)>
  257. //display(GxEPD2_1248(/*cs_m1=*/ 2, /*cs_s1=*/ 3, /*cs_m2=*/ A4, /*cs_s2=*/ A0, /*dc1=*/ 6, /*dc2=*/ A3, /*rst1=*/ 5, /*rst2=*/ A2,
  258. // /*busy_m1=*/ 4, /*busy_s1=*/ 7, /*busy_m2=*/ A1, /*busy_s2=*/ A5));
  259. #endif
  260. #if !defined(__AVR)
  261. // comment out unused bitmaps to reduce code space used
  262. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  263. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  264. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  265. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  266. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  267. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  268. // 3-color
  269. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  270. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  271. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  272. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  273. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  274. #else
  275. // select only one to fit in code space
  276. //#include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  277. //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  278. //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  279. //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  280. ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
  281. ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
  282. // 3-color
  283. //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  284. //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  285. //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  286. //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  287. ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
  288. #endif
  289. void setup()
  290. {
  291. Serial.begin(115200);
  292. Serial.println();
  293. Serial.println("setup");
  294. display.init(115200);
  295. // first update should be full refresh
  296. helloWorld();
  297. delay(1000);
  298. // partial refresh mode can be used to full screen,
  299. // effective if display panel hasFastPartialUpdate
  300. helloFullScreenPartialMode();
  301. delay(1000);
  302. helloArduino();
  303. delay(1000);
  304. helloEpaper();
  305. delay(1000);
  306. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  307. delay(1000);
  308. drawBitmaps();
  309. if (display.epd2.hasPartialUpdate)
  310. {
  311. showPartialUpdate();
  312. delay(1000);
  313. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  314. //drawCornerTest();
  315. //showBox(16, 16, 48, 32, false);
  316. //showBox(16, 56, 48, 32, true);
  317. display.powerOff();
  318. Serial.println("setup done");
  319. }
  320. void loop()
  321. {
  322. }
  323. void helloWorldCallback(const void*)
  324. {
  325. uint16_t x = (display.width() - 160) / 2;
  326. uint16_t y = display.height() / 2;
  327. display.fillScreen(GxEPD_WHITE);
  328. display.setCursor(x, y);
  329. display.println("Hello World!");
  330. }
  331. void helloWorld()
  332. {
  333. //Serial.println("helloWorld");
  334. uint16_t x = (display.width() - 160) / 2;
  335. uint16_t y = display.height() / 2;
  336. display.setRotation(1);
  337. display.setFont(&FreeMonoBold9pt7b);
  338. display.setTextColor(GxEPD_BLACK);
  339. display.setFullWindow();
  340. display.drawPaged(helloWorldCallback, 0);
  341. //Serial.println("helloWorld done");
  342. }
  343. void helloFullScreenPartialModeCallback(const void*)
  344. {
  345. uint16_t x = (display.width() - 160) / 2;
  346. uint16_t y = display.height() / 2;
  347. display.fillScreen(GxEPD_WHITE);
  348. display.setCursor(x, y);
  349. display.println("Hello World!");
  350. y = display.height() / 4;
  351. display.setCursor(x, y);
  352. display.println("full screen");
  353. y = display.height() * 3 / 4;
  354. if (display.width() <= 200) x = 0;
  355. display.setCursor(x, y);
  356. if (display.epd2.hasFastPartialUpdate)
  357. {
  358. display.println("fast partial mode");
  359. }
  360. else if (display.epd2.hasPartialUpdate)
  361. {
  362. display.println("slow partial mode");
  363. }
  364. else
  365. {
  366. display.println("no partial mode");
  367. }
  368. }
  369. void helloFullScreenPartialMode()
  370. {
  371. //Serial.println("helloFullScreenPartialMode");
  372. display.setPartialWindow(0, 0, display.width(), display.height());
  373. display.setRotation(1);
  374. display.setFont(&FreeMonoBold9pt7b);
  375. display.setTextColor(GxEPD_BLACK);
  376. display.drawPaged(helloFullScreenPartialModeCallback, 0);
  377. //Serial.println("helloFullScreenPartialMode done");
  378. }
  379. void helloArduinoCallback(const void*)
  380. {
  381. uint16_t x = (display.width() - 160) / 2;
  382. uint16_t y = display.height() / 4;
  383. display.fillScreen(GxEPD_WHITE);
  384. display.setCursor(x, y);
  385. display.println("Hello Arduino!");
  386. }
  387. void helloArduino()
  388. {
  389. //Serial.println("helloArduino");
  390. uint16_t x = (display.width() - 160) / 2;
  391. uint16_t y = display.height() / 4;
  392. display.setRotation(1);
  393. display.setFont(&FreeMonoBold9pt7b);
  394. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  395. display.setPartialWindow(0, y - 14, display.width(), 20);
  396. display.drawPaged(helloArduinoCallback, 0);
  397. delay(1000);
  398. //Serial.println("helloArduino done");
  399. }
  400. void helloEpaperCallback(const void*)
  401. {
  402. uint16_t x = (display.width() - 160) / 2;
  403. uint16_t y = display.height() * 3 / 4;
  404. display.fillScreen(GxEPD_WHITE);
  405. display.setCursor(x, y);
  406. display.println("Hello E-Paper!");
  407. }
  408. void helloEpaper()
  409. {
  410. //Serial.println("helloEpaper");
  411. uint16_t x = (display.width() - 160) / 2;
  412. uint16_t y = display.height() * 3 / 4;
  413. display.setRotation(1);
  414. display.setFont(&FreeMonoBold9pt7b);
  415. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  416. display.setPartialWindow(0, y - 14, display.width(), 20);
  417. display.drawPaged(helloEpaperCallback, 0);
  418. //Serial.println("helloEpaper done");
  419. }
  420. struct DrawFontParameters
  421. {
  422. const char* name;
  423. const GFXfont* f;
  424. };
  425. void showFont(const char name[], const GFXfont* f)
  426. {
  427. DrawFontParameters fontParameters{name, f};
  428. display.setFullWindow();
  429. display.setRotation(0);
  430. display.setTextColor(GxEPD_BLACK);
  431. display.drawPaged(drawFontCallback, &fontParameters);
  432. }
  433. void drawFontCallback(const void* parameters)
  434. {
  435. const DrawFontParameters* p = reinterpret_cast<const DrawFontParameters*>(parameters);
  436. //display.setRotation(0);
  437. display.fillScreen(GxEPD_WHITE);
  438. display.setTextColor(GxEPD_BLACK);
  439. display.setFont(p->f);
  440. display.setCursor(0, 0);
  441. display.println();
  442. display.println(p->name);
  443. display.println(" !\"#$%&'()*+,-./");
  444. display.println("0123456789:;<=>?");
  445. display.println("@ABCDEFGHIJKLMNO");
  446. display.println("PQRSTUVWXYZ[\\]^_");
  447. if (display.epd2.hasColor)
  448. {
  449. display.setTextColor(GxEPD_RED);
  450. }
  451. display.println("`abcdefghijklmno");
  452. display.println("pqrstuvwxyz{|}~ ");
  453. }
  454. struct ShowBoxParameters
  455. {
  456. uint16_t x, y, w, h;
  457. uint16_t color;
  458. };
  459. struct ShowValueParameters
  460. {
  461. uint16_t x, y, w, h, cursor_y;
  462. float value;
  463. };
  464. void showBoxCallback(const void* parameters)
  465. {
  466. const ShowBoxParameters* p = reinterpret_cast<const ShowBoxParameters*>(parameters);
  467. display.fillRect(p->x, p->y, p->w, p->h, p->color);
  468. }
  469. void showValueBoxCallback(const void* parameters)
  470. {
  471. const ShowValueParameters* p = reinterpret_cast<const ShowValueParameters*>(parameters);
  472. display.fillRect(p->x, p->y, p->w, p->h, GxEPD_WHITE);
  473. display.setCursor(p->x, p->cursor_y);
  474. display.print(p->value);
  475. }
  476. void showPartialUpdate()
  477. {
  478. // some useful background
  479. helloWorld();
  480. // use asymmetric values for test
  481. ShowBoxParameters boxParameters{10, 15, 70, 20, GxEPD_WHITE};
  482. ShowValueParameters valueParameters{10, 15, 70, 20, 13.95};
  483. valueParameters.cursor_y = valueParameters.y + valueParameters.h - 6;
  484. float value = 13.95;
  485. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  486. display.setFont(&FreeMonoBold9pt7b);
  487. display.setTextColor(GxEPD_BLACK);
  488. // show where the update box is
  489. for (uint16_t r = 0; r < 4; r++)
  490. {
  491. display.setRotation(r);
  492. display.setPartialWindow(boxParameters.x, boxParameters.y, boxParameters.w, boxParameters.h);
  493. boxParameters.color = GxEPD_BLACK;
  494. display.drawPaged(showBoxCallback, &boxParameters);
  495. delay(2000);
  496. boxParameters.color = GxEPD_WHITE;
  497. display.drawPaged(showBoxCallback, &boxParameters);
  498. while (display.nextPage());
  499. delay(1000);
  500. }
  501. // show updates in the update box
  502. for (uint16_t r = 0; r < 4; r++)
  503. {
  504. display.setRotation(r);
  505. display.setPartialWindow(boxParameters.x, boxParameters.y, boxParameters.w, boxParameters.h);
  506. for (uint16_t i = 1; i <= 10; i += incr)
  507. {
  508. valueParameters.value = value * i;
  509. display.drawPaged(showValueBoxCallback, &valueParameters);
  510. delay(500);
  511. }
  512. delay(1000);
  513. boxParameters.color = GxEPD_WHITE;
  514. display.drawPaged(showBoxCallback, &boxParameters);
  515. delay(1000);
  516. }
  517. }
  518. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  519. {
  520. //Serial.println("showBox");
  521. ShowBoxParameters boxParameters{x, y, w, h, GxEPD_BLACK};
  522. display.setRotation(1);
  523. if (partial)
  524. {
  525. display.setPartialWindow(x, y, w, h);
  526. }
  527. else
  528. {
  529. display.setFullWindow();
  530. }
  531. display.drawPaged(showBoxCallback, &boxParameters);
  532. //Serial.println("showBox done");
  533. }
  534. void drawCornerTestCallback(const void*)
  535. {
  536. display.fillScreen(GxEPD_WHITE);
  537. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  538. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  539. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  540. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  541. display.setCursor(display.width() / 2, display.height() / 2);
  542. display.print(display.getRotation());
  543. }
  544. void drawCornerTest()
  545. {
  546. display.setFullWindow();
  547. display.setFont(&FreeMonoBold9pt7b);
  548. display.setTextColor(GxEPD_BLACK);
  549. for (uint16_t r = 0; r <= 4; r++)
  550. {
  551. display.setRotation(r);
  552. display.drawPaged(drawCornerTestCallback, 0);
  553. delay(2000);
  554. }
  555. }
  556. void drawBitmaps()
  557. {
  558. display.setFullWindow();
  559. #ifdef _GxBitmaps128x250_H_
  560. drawBitmaps128x250();
  561. #endif
  562. #ifdef _GxBitmaps128x296_H_
  563. drawBitmaps128x296();
  564. #endif
  565. #ifdef _GxBitmaps176x264_H_
  566. drawBitmaps176x264();
  567. #endif
  568. #ifdef _GxBitmaps400x300_H_
  569. drawBitmaps400x300();
  570. #endif
  571. #ifdef _GxBitmaps640x384_H_
  572. drawBitmaps640x384();
  573. #endif
  574. // 3-color
  575. #ifdef _GxBitmaps3c104x212_H_
  576. drawBitmaps3c104x212();
  577. #endif
  578. #ifdef _GxBitmaps3c128x296_H_
  579. drawBitmaps3c128x296();
  580. #endif
  581. #ifdef _GxBitmaps3c176x264_H_
  582. drawBitmaps3c176x264();
  583. #endif
  584. #ifdef _GxBitmaps3c400x300_H_
  585. drawBitmaps3c400x300();
  586. #endif
  587. // show these after the specific bitmaps
  588. #ifdef _GxBitmaps200x200_H_
  589. drawBitmaps200x200();
  590. #endif
  591. // 3-color
  592. #ifdef _GxBitmaps3c200x200_H_
  593. drawBitmaps3c200x200();
  594. #endif
  595. }
  596. void drawInvertedBitmapCallback(const void* parameter)
  597. {
  598. const uint8_t* bitmap = reinterpret_cast<const uint8_t*>(parameter);
  599. display.fillScreen(GxEPD_WHITE);
  600. display.drawInvertedBitmap(0, 0, bitmap, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  601. }
  602. #ifdef _GxBitmaps200x200_H_
  603. void drawBitmaps200x200()
  604. {
  605. #if defined(__AVR)
  606. const unsigned char* bitmaps[] =
  607. {
  608. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  609. };
  610. #else
  611. const unsigned char* bitmaps[] =
  612. {
  613. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  614. };
  615. #endif
  616. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  617. {
  618. bool m = display.mirror(true);
  619. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  620. {
  621. display.drawPaged(drawInvertedBitmapCallback, bitmaps[i]);
  622. delay(2000);
  623. }
  624. display.mirror(m);
  625. }
  626. //else
  627. {
  628. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  629. display.clearScreen(); // use default for white
  630. uint16_t x = (display.epd2.WIDTH - 200) / 2;
  631. uint16_t y = (display.epd2.HEIGHT - 200) / 2;
  632. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  633. {
  634. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  635. delay(2000);
  636. }
  637. }
  638. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  639. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  640. {
  641. int16_t x = -60;
  642. int16_t y = -60;
  643. for (uint16_t j = 0; j < 10; j++)
  644. {
  645. display.writeScreenBuffer(); // use default for white
  646. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  647. display.refresh(true);
  648. if (display.epd2.hasFastPartialUpdate)
  649. {
  650. // for differential update: set previous buffer equal to current buffer in controller
  651. display.epd2.writeScreenBufferAgain(); // use default for white
  652. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  653. }
  654. delay(2000);
  655. x += 40;
  656. y += 40;
  657. if ((x >= display.epd2.WIDTH) || (y >= display.epd2.HEIGHT)) break;
  658. }
  659. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  660. break; // comment out for full show
  661. }
  662. display.writeScreenBuffer(); // use default for white
  663. display.writeImage(bitmaps[0], 0, 0, 200, 200, false, mirror_y, true);
  664. display.writeImage(bitmaps[0], display.epd2.WIDTH - 200, display.epd2.HEIGHT - 200, 200, 200, false, mirror_y, true);
  665. display.refresh(true);
  666. delay(2000);
  667. }
  668. #endif
  669. #ifdef _GxBitmaps128x250_H_
  670. void drawBitmaps128x250()
  671. {
  672. const unsigned char* bitmaps[] =
  673. {
  674. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  675. };
  676. if (display.epd2.panel == GxEPD2::GDE0213B1)
  677. {
  678. bool m = display.mirror(true);
  679. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  680. {
  681. display.drawPaged(drawInvertedBitmapCallback, bitmaps[i]);
  682. delay(2000);
  683. }
  684. display.mirror(m);
  685. }
  686. }
  687. #endif
  688. #ifdef _GxBitmaps128x296_H_
  689. void drawBitmaps128x296()
  690. {
  691. #if !defined(__AVR)
  692. const unsigned char* bitmaps[] =
  693. {
  694. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  695. };
  696. #else
  697. const unsigned char* bitmaps[] =
  698. {
  699. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  700. };
  701. #endif
  702. if (display.epd2.panel == GxEPD2::GDEH029A1)
  703. {
  704. bool m = display.mirror(true);
  705. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  706. {
  707. display.drawPaged(drawInvertedBitmapCallback, bitmaps[i]);
  708. delay(2000);
  709. }
  710. display.mirror(m);
  711. }
  712. }
  713. #endif
  714. #ifdef _GxBitmaps176x264_H_
  715. void drawBitmaps176x264()
  716. {
  717. const unsigned char* bitmaps[] =
  718. {
  719. Bitmap176x264_1, Bitmap176x264_2
  720. };
  721. if (display.epd2.panel == GxEPD2::GDEW027W3)
  722. {
  723. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  724. {
  725. display.drawPaged(drawInvertedBitmapCallback, bitmaps[i]);
  726. delay(2000);
  727. }
  728. }
  729. }
  730. #endif
  731. #ifdef _GxBitmaps400x300_H_
  732. void drawBitmaps400x300()
  733. {
  734. const unsigned char* bitmaps[] =
  735. {
  736. Bitmap400x300_1, Bitmap400x300_2
  737. };
  738. if (display.epd2.panel == GxEPD2::GDEW042T2)
  739. {
  740. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  741. {
  742. display.drawPaged(drawInvertedBitmapCallback, bitmaps[i]);
  743. delay(2000);
  744. }
  745. }
  746. }
  747. #endif
  748. #ifdef _GxBitmaps640x384_H_
  749. void drawBitmaps640x384()
  750. {
  751. const unsigned char* bitmaps[] =
  752. {
  753. Bitmap640x384_1, Bitmap640x384_2
  754. };
  755. if (display.epd2.panel == GxEPD2::GDEW075T8)
  756. {
  757. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  758. {
  759. display.drawPaged(drawInvertedBitmapCallback, bitmaps[i]);
  760. delay(2000);
  761. }
  762. }
  763. }
  764. #endif
  765. struct bitmap_pair
  766. {
  767. const unsigned char* black;
  768. const unsigned char* red;
  769. };
  770. void drawBitmapPairCallback(const void* parameters)
  771. {
  772. const bitmap_pair* bitmaps = reinterpret_cast<const bitmap_pair*>(parameters);
  773. display.fillScreen(GxEPD_WHITE);
  774. display.drawBitmap(0, 0, bitmaps->black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  775. display.drawBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  776. }
  777. void drawInvertedBitmapPairCallback(const void* parameters)
  778. {
  779. const bitmap_pair* bitmaps = reinterpret_cast<const bitmap_pair*>(parameters);
  780. display.fillScreen(GxEPD_WHITE);
  781. display.drawInvertedBitmap(0, 0, bitmaps->black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  782. display.drawInvertedBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  783. }
  784. void drawSpecialBitmapPairCallback(const void* parameters)
  785. {
  786. const bitmap_pair* bitmaps = reinterpret_cast<const bitmap_pair*>(parameters);
  787. display.fillScreen(GxEPD_WHITE);
  788. // Bitmap3c200x200_black has 2 bits per pixel
  789. // taken from Adafruit_GFX.cpp, modified
  790. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  791. uint8_t byte = 0;
  792. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  793. {
  794. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  795. {
  796. if (i & 3) byte <<= 2;
  797. else
  798. {
  799. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  800. byte = pgm_read_byte(&bitmaps->black[j * byteWidth * 2 + i / 4]);
  801. #else
  802. byte = bitmaps->black[j * byteWidth * 2 + i / 4];
  803. #endif
  804. }
  805. if (!(byte & 0x80))
  806. {
  807. display.drawPixel(i, j, GxEPD_BLACK);
  808. }
  809. }
  810. }
  811. display.drawInvertedBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  812. }
  813. #ifdef _GxBitmaps3c200x200_H_
  814. void drawBitmaps3c200x200()
  815. {
  816. bitmap_pair bitmap_pairs[] =
  817. {
  818. //{Bitmap3c200x200_black, Bitmap3c200x200_red}, // special
  819. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  820. };
  821. bitmap_pair special_bitmap{Bitmap3c200x200_black, Bitmap3c200x200_red};
  822. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  823. {
  824. display.drawPaged(drawSpecialBitmapPairCallback, &special_bitmap);
  825. delay(2000);
  826. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  827. {
  828. display.drawPaged(drawInvertedBitmapPairCallback, &bitmap_pairs[i]);
  829. delay(2000);
  830. }
  831. }
  832. if (display.epd2.hasColor)
  833. {
  834. display.clearScreen(); // use default for white
  835. uint16_t x = (display.epd2.WIDTH - 200) / 2;
  836. uint16_t y = (display.epd2.HEIGHT - 200) / 2;
  837. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  838. {
  839. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  840. delay(2000);
  841. }
  842. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  843. {
  844. int16_t x = -60;
  845. int16_t y = -60;
  846. for (uint16_t j = 0; j < 10; j++)
  847. {
  848. display.writeScreenBuffer(); // use default for white
  849. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  850. display.refresh();
  851. delay(2000);
  852. x += 40;
  853. y += 40;
  854. if ((x >= display.epd2.WIDTH) || (y >= display.epd2.HEIGHT)) break;
  855. }
  856. }
  857. display.writeScreenBuffer(); // use default for white
  858. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  859. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, display.epd2.WIDTH - 200, display.epd2.HEIGHT - 200, 200, 200, false, false, true);
  860. display.refresh();
  861. delay(2000);
  862. }
  863. }
  864. #endif
  865. #ifdef _GxBitmaps3c104x212_H_
  866. void drawBitmapPairCallback3c104x212(const void* parameters)
  867. {
  868. const bitmap_pair* bitmaps = reinterpret_cast<const bitmap_pair*>(parameters);
  869. display.fillScreen(GxEPD_WHITE);
  870. display.drawInvertedBitmap(0, 0, bitmaps->black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  871. if (bitmaps->red == WS_Bitmap3c104x212_red)
  872. {
  873. display.drawInvertedBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  874. }
  875. else display.drawBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  876. }
  877. void drawBitmaps3c104x212()
  878. {
  879. #if !defined(__AVR)
  880. bitmap_pair bitmap_pairs[] =
  881. {
  882. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  883. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  884. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  885. };
  886. #else
  887. bitmap_pair bitmap_pairs[] =
  888. {
  889. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  890. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  891. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  892. };
  893. #endif
  894. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  895. {
  896. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  897. {
  898. display.drawPaged(drawBitmapPairCallback3c104x212, &bitmap_pairs[i]);
  899. delay(2000);
  900. }
  901. }
  902. }
  903. #endif
  904. #ifdef _GxBitmaps3c128x296_H_
  905. void drawBitmapPairCallback3c128x296(const void* parameters)
  906. {
  907. const bitmap_pair* bitmaps = reinterpret_cast<const bitmap_pair*>(parameters);
  908. display.fillScreen(GxEPD_WHITE);
  909. display.drawInvertedBitmap(0, 0, bitmaps->black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  910. if (bitmaps->red == WS_Bitmap3c128x296_red)
  911. {
  912. display.drawInvertedBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  913. }
  914. else display.drawBitmap(0, 0, bitmaps->red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  915. }
  916. void drawBitmaps3c128x296()
  917. {
  918. #if !defined(__AVR)
  919. bitmap_pair bitmap_pairs[] =
  920. {
  921. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  922. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  923. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  924. };
  925. #else
  926. bitmap_pair bitmap_pairs[] =
  927. {
  928. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  929. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  930. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  931. };
  932. #endif
  933. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  934. {
  935. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  936. {
  937. display.drawPaged(drawBitmapPairCallback3c128x296, &bitmap_pairs[i]);
  938. delay(2000);
  939. }
  940. }
  941. }
  942. #endif
  943. #ifdef _GxBitmaps3c176x264_H_
  944. void drawBitmaps3c176x264()
  945. {
  946. bitmap_pair bitmap_pairs[] =
  947. {
  948. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  949. };
  950. if (display.epd2.panel == GxEPD2::GDEW027C44)
  951. {
  952. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  953. {
  954. display.drawPaged(drawBitmapPairCallback, &bitmap_pairs[i]);
  955. delay(2000);
  956. }
  957. }
  958. }
  959. #endif
  960. #ifdef _GxBitmaps3c400x300_H_
  961. void drawBitmaps3c400x300()
  962. {
  963. #if !defined(__AVR)
  964. bitmap_pair bitmap_pairs[] =
  965. {
  966. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  967. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  968. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  969. };
  970. #else
  971. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  972. #endif
  973. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  974. {
  975. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  976. {
  977. display.drawPaged(drawInvertedBitmapPairCallback, &bitmap_pairs[i]);
  978. delay(2000);
  979. }
  980. }
  981. }
  982. #endif