GxEPD2_PagedDisplayUsingCallback.ino 32 KB

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