GxEPD2_Example.ino 26 KB

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