GxEPD2_Example.ino 34 KB

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