GxEPD2_Example.ino 35 KB

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