GxEPD2_Example.ino 33 KB

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