GxEPD2_PagedDisplayUsingCallback.ino 32 KB

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