GxEPD2_Example.ino 33 KB

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