GxEPD2_T_MultiDisplayExample.ino 36 KB

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