GxEPD2_Example.ino 33 KB

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