GxEPD2_WS_ESP32_Driver.ino 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  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: the e-paper panels require 3.3V supply AND data lines!
  3. //
  4. // Display Library based on Demo Example from Good Display: http://www.e-paper-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. // GxEPD2_WS_ESP32_Driver : GxEPD2_Example variant for Universal e-Paper Raw Panel Driver Board, ESP32 WiFi / Bluetooth Wireless
  12. // https://www.waveshare.com/product/e-paper-esp32-driver-board.htm
  13. // Supporting Arduino Forum Topics:
  14. // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
  15. // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
  16. // mapping of Waveshare ESP32 Driver Board
  17. // BUSY -> 25, RST -> 26, DC -> 27, CS-> 15, CLK -> 13, DIN -> 14
  18. // NOTE: this board uses "unusual" SPI pins and requires re-mapping of HW SPI to these pins in SPIClass
  19. // this example shows how this can be done easily
  20. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  21. // enable or disable GxEPD2_GFX base class
  22. #define ENABLE_GxEPD2_GFX 0
  23. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  24. //#include <GFX.h>
  25. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  26. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  27. #include <GxEPD2_BW.h>
  28. #include <GxEPD2_3C.h>
  29. #include <Fonts/FreeMonoBold9pt7b.h>
  30. // select the display class (only one), matching the kind of display panel
  31. #define GxEPD2_DISPLAY_CLASS GxEPD2_BW
  32. //#define GxEPD2_DISPLAY_CLASS GxEPD2_3C
  33. //#define GxEPD2_DISPLAY_CLASS GxEPD2_7C
  34. // select the display driver class (only one) for your panel
  35. //#define GxEPD2_DRIVER_CLASS GxEPD2_154 // GDEP015OC1 200x200, no longer available
  36. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_D67 // GDEH0154D67 200x200
  37. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_T8 // GDEW0154T8 152x152
  38. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_M09 // GDEW0154M09 200x200
  39. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_M10 // GDEW0154M10 152x152
  40. //#define GxEPD2_DRIVER_CLASS GxEPD2_213 // GDE0213B1 128x250, phased out
  41. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_B72 // GDEH0213B72 128x250
  42. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_B73 // GDEH0213B73 128x250
  43. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_flex // GDEW0213I5F 104x212
  44. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_M21 // GDEW0213M21 104x212
  45. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_T5D // GDEW0213T5D 104x212
  46. //#define GxEPD2_DRIVER_CLASS GxEPD2_290 // GDEH029A1 128x296
  47. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T5 // GDEW029T5 128x296
  48. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T5D // GDEW029T5D 128x296
  49. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_T94 // GDEM029T94 128x296
  50. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_M06 // GDEW029M06 128x296
  51. //#define GxEPD2_DRIVER_CLASS GxEPD2_260 // GDEW026T0 152x296
  52. //#define GxEPD2_DRIVER_CLASS GxEPD2_260_M01 // GDEW026M01 152x296
  53. //#define GxEPD2_DRIVER_CLASS GxEPD2_270 // GDEW027W3 176x264
  54. //#define GxEPD2_DRIVER_CLASS GxEPD2_371 // GDEW0371W7 240x416
  55. //#define GxEPD2_DRIVER_CLASS GxEPD2_420 // GDEW042T2 400x300
  56. //#define GxEPD2_DRIVER_CLASS GxEPD2_420_M01 // GDEW042M01 400x300
  57. //#define GxEPD2_DRIVER_CLASS GxEPD2_583 // GDEW0583T7 600x448
  58. //#define GxEPD2_DRIVER_CLASS GxEPD2_583_T8 // GDEW0583T8 648x480
  59. //#define GxEPD2_DRIVER_CLASS GxEPD2_750 // GDEW075T8 640x384
  60. //#define GxEPD2_DRIVER_CLASS GxEPD2_750_T7 // GDEW075T7 800x480
  61. //#define GxEPD2_DRIVER_CLASS GxEPD2_1160_T91 // GDEH116T91 960x640, SSD1677
  62. // 3-color e-papers
  63. //#define GxEPD2_DRIVER_CLASS GxEPD2_154c // GDEW0154Z04 200x200, no longer available
  64. //#define GxEPD2_DRIVER_CLASS GxEPD2_154_Z90c // GDEH0154Z90 200x200
  65. //#define GxEPD2_DRIVER_CLASS GxEPD2_213c // GDEW0213Z16 104x212
  66. //#define GxEPD2_DRIVER_CLASS GxEPD2_213_Z19c // GDEW0213Z19 104x212
  67. //#define GxEPD2_DRIVER_CLASS GxEPD2_290c // GDEW029Z10 128x296
  68. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_Z13c // GDEH029Z13 128x296
  69. //#define GxEPD2_DRIVER_CLASS GxEPD2_290_C90c // GDEM029C90 128x296
  70. //#define GxEPD2_DRIVER_CLASS GxEPD2_270c // GDEW027C44 176x264
  71. //#define GxEPD2_DRIVER_CLASS GxEPD2_420c // GDEW042Z15 400x300
  72. //#define GxEPD2_DRIVER_CLASS GxEPD2_583c // GDEW0583Z21 600x448
  73. //#define GxEPD2_DRIVER_CLASS GxEPD2_750c // GDEW075Z09 600x384
  74. //#define GxEPD2_DRIVER_CLASS GxEPD2_750c_Z08 // GDEW075Z08 800x480
  75. //#define GxEPD2_DRIVER_CLASS GxEPD2_750c_Z90 // GDEH075Z90 880x528
  76. //#define GxEPD2_DRIVER_CLASS GxEPD2_1248 // GDEW1248T3 1303x984
  77. // 7-color e-paper
  78. //#define GxEPD2_DRIVER_CLASS GxEPD2_565c // Waveshare 5.65" 7-color (3C graphics)
  79. // somehow there should be an easier way to do this
  80. #define GxEPD2_BW_IS_GxEPD2_BW true
  81. #define GxEPD2_3C_IS_GxEPD2_3C true
  82. #define GxEPD2_7C_IS_GxEPD2_7C true
  83. #define GxEPD2_1248_IS_GxEPD2_1248 true
  84. #define IS_GxEPD(c, x) (c##x)
  85. #define IS_GxEPD2_BW(x) IS_GxEPD(GxEPD2_BW_IS_, x)
  86. #define IS_GxEPD2_3C(x) IS_GxEPD(GxEPD2_3C_IS_, x)
  87. #define IS_GxEPD2_7C(x) IS_GxEPD(GxEPD2_7C_IS_, x)
  88. #define IS_GxEPD2_1248(x) IS_GxEPD(GxEPD2_1248_IS_, x)
  89. #if defined(ESP32)
  90. #define MAX_DISPLAY_BUFFER_SIZE 65536ul // e.g.
  91. #if IS_GxEPD2_BW(GxEPD2_DISPLAY_CLASS)
  92. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
  93. #elif IS_GxEPD2_3C(GxEPD2_DISPLAY_CLASS)
  94. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
  95. #elif IS_GxEPD2_7C(GxEPD2_DISPLAY_CLASS)
  96. #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2))
  97. #endif
  98. GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_HEIGHT(GxEPD2_DRIVER_CLASS)> display(GxEPD2_DRIVER_CLASS(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));
  99. #endif
  100. // alternately you can copy the constructor from GxEPD2_display_selection.h of GxEPD_Example to here
  101. // and adapt it to the ESP32 Driver wiring, e.g.
  102. //GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEH0154D67
  103. // comment out unused bitmaps to reduce code space used
  104. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  105. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  106. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  107. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  108. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  109. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  110. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  111. // 3-color
  112. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  113. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  114. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  115. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  116. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  117. void setup()
  118. {
  119. Serial.begin(115200);
  120. Serial.println();
  121. Serial.println("setup");
  122. display.init(115200); // uses standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
  123. // *** special handling for Waveshare ESP32 Driver board *** //
  124. // ********************************************************* //
  125. SPI.end(); // release standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
  126. //SPI: void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
  127. SPI.begin(13, 12, 14, 15); // map and init SPI pins SCK(13), MISO(12), MOSI(14), SS(15)
  128. // *** end of special handling for Waveshare ESP32 Driver board *** //
  129. // **************************************************************** //
  130. // first update should be full refresh
  131. helloWorld();
  132. delay(1000);
  133. // partial refresh mode can be used to full screen,
  134. // effective if display panel hasFastPartialUpdate
  135. helloFullScreenPartialMode();
  136. delay(1000);
  137. helloArduino();
  138. delay(1000);
  139. helloEpaper();
  140. delay(1000);
  141. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  142. delay(1000);
  143. drawBitmaps();
  144. if (display.epd2.hasPartialUpdate)
  145. {
  146. showPartialUpdate();
  147. delay(1000);
  148. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  149. //drawCornerTest();
  150. //showBox(16, 16, 48, 32, false);
  151. //showBox(16, 56, 48, 32, true);
  152. display.powerOff();
  153. deepSleepTest();
  154. Serial.println("setup done");
  155. }
  156. void loop()
  157. {
  158. }
  159. // note for partial update window and setPartialWindow() method:
  160. // partial update window size and position is on byte boundary in physical x direction
  161. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  162. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  163. const char HelloWorld[] = "Hello World!";
  164. const char HelloArduino[] = "Hello Arduino!";
  165. const char HelloEpaper[] = "Hello E-Paper!";
  166. void helloWorld()
  167. {
  168. //Serial.println("helloWorld");
  169. display.setRotation(1);
  170. display.setFont(&FreeMonoBold9pt7b);
  171. display.setTextColor(GxEPD_BLACK);
  172. int16_t tbx, tby; uint16_t tbw, tbh;
  173. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  174. // center bounding box by transposition of origin:
  175. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  176. uint16_t y = ((display.height() - tbh) / 2) - tby;
  177. display.setFullWindow();
  178. display.firstPage();
  179. do
  180. {
  181. display.fillScreen(GxEPD_WHITE);
  182. display.setCursor(x, y);
  183. display.print(HelloWorld);
  184. }
  185. while (display.nextPage());
  186. //Serial.println("helloWorld done");
  187. }
  188. void helloWorldForDummies()
  189. {
  190. //Serial.println("helloWorld");
  191. const char text[] = "Hello World!";
  192. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  193. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  194. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  195. display.setRotation(1);
  196. // select a suitable font in Adafruit_GFX
  197. display.setFont(&FreeMonoBold9pt7b);
  198. // on e-papers black on white is more pleasant to read
  199. display.setTextColor(GxEPD_BLACK);
  200. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  201. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  202. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  203. // center bounding box by transposition of origin:
  204. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  205. uint16_t y = ((display.height() - tbh) / 2) - tby;
  206. // full window mode is the initial mode, set it anyway
  207. display.setFullWindow();
  208. // here we use paged drawing, even if the processor has enough RAM for full buffer
  209. // so this can be used with any supported processor board.
  210. // the cost in code overhead and execution time penalty is marginal
  211. // tell the graphics class to use paged drawing mode
  212. display.firstPage();
  213. do
  214. {
  215. // this part of code is executed multiple times, as many as needed,
  216. // in case of full buffer it is executed once
  217. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  218. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  219. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  220. display.setCursor(x, y); // set the postition to start printing text
  221. display.print(text); // print some text
  222. // end of part executed multiple times
  223. }
  224. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  225. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  226. // returns true if more pages need be drawn and transferred
  227. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  228. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  229. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  230. while (display.nextPage());
  231. //Serial.println("helloWorld done");
  232. }
  233. void helloFullScreenPartialMode()
  234. {
  235. //Serial.println("helloFullScreenPartialMode");
  236. const char fullscreen[] = "full screen update";
  237. const char fpm[] = "fast partial mode";
  238. const char spm[] = "slow partial mode";
  239. const char npm[] = "no partial mode";
  240. display.setPartialWindow(0, 0, display.width(), display.height());
  241. display.setRotation(1);
  242. display.setFont(&FreeMonoBold9pt7b);
  243. display.setTextColor(GxEPD_BLACK);
  244. const char* updatemode;
  245. if (display.epd2.hasFastPartialUpdate)
  246. {
  247. updatemode = fpm;
  248. }
  249. else if (display.epd2.hasPartialUpdate)
  250. {
  251. updatemode = spm;
  252. }
  253. else
  254. {
  255. updatemode = npm;
  256. }
  257. // do this outside of the loop
  258. int16_t tbx, tby; uint16_t tbw, tbh;
  259. // center update text
  260. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  261. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  262. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  263. // center update mode
  264. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  265. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  266. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  267. // center HelloWorld
  268. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  269. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  270. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  271. display.firstPage();
  272. do
  273. {
  274. display.fillScreen(GxEPD_WHITE);
  275. display.setCursor(hwx, hwy);
  276. display.print(HelloWorld);
  277. display.setCursor(utx, uty);
  278. display.print(fullscreen);
  279. display.setCursor(umx, umy);
  280. display.print(updatemode);
  281. }
  282. while (display.nextPage());
  283. //Serial.println("helloFullScreenPartialMode done");
  284. }
  285. void helloArduino()
  286. {
  287. //Serial.println("helloArduino");
  288. display.setRotation(1);
  289. display.setFont(&FreeMonoBold9pt7b);
  290. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  291. int16_t tbx, tby; uint16_t tbw, tbh;
  292. // align with centered HelloWorld
  293. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  294. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  295. // height might be different
  296. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  297. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  298. // make the window big enough to cover (overwrite) descenders of previous text
  299. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  300. uint16_t wy = (display.height() / 4) - wh / 2;
  301. display.setPartialWindow(0, wy, display.width(), wh);
  302. display.firstPage();
  303. do
  304. {
  305. display.fillScreen(GxEPD_WHITE);
  306. //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
  307. display.setCursor(x, y);
  308. display.print(HelloArduino);
  309. }
  310. while (display.nextPage());
  311. delay(1000);
  312. //Serial.println("helloArduino done");
  313. }
  314. void helloEpaper()
  315. {
  316. //Serial.println("helloEpaper");
  317. display.setRotation(1);
  318. display.setFont(&FreeMonoBold9pt7b);
  319. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  320. int16_t tbx, tby; uint16_t tbw, tbh;
  321. // align with centered HelloWorld
  322. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  323. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  324. // height might be different
  325. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  326. uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
  327. // make the window big enough to cover (overwrite) descenders of previous text
  328. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  329. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  330. display.setPartialWindow(0, wy, display.width(), wh);
  331. display.firstPage();
  332. do
  333. {
  334. display.fillScreen(GxEPD_WHITE);
  335. display.setCursor(x, y);
  336. display.print(HelloEpaper);
  337. }
  338. while (display.nextPage());
  339. //Serial.println("helloEpaper done");
  340. }
  341. void deepSleepTest()
  342. {
  343. //Serial.println("deepSleepTest");
  344. const char hibernating[] = "hibernating ...";
  345. const char wokeup[] = "woke up";
  346. const char from[] = "from deep sleep";
  347. const char again[] = "again";
  348. display.setRotation(1);
  349. display.setFont(&FreeMonoBold9pt7b);
  350. display.setTextColor(GxEPD_BLACK);
  351. int16_t tbx, tby; uint16_t tbw, tbh;
  352. // center text
  353. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  354. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  355. uint16_t y = ((display.height() - tbh) / 2) - tby;
  356. display.setFullWindow();
  357. display.firstPage();
  358. do
  359. {
  360. display.fillScreen(GxEPD_WHITE);
  361. display.setCursor(x, y);
  362. display.print(hibernating);
  363. }
  364. while (display.nextPage());
  365. display.hibernate();
  366. delay(5000);
  367. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  368. uint16_t wx = (display.width() - tbw) / 2;
  369. uint16_t wy = (display.height() / 3) + tbh / 2; // y is base line!
  370. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  371. uint16_t fx = (display.width() - tbw) / 2;
  372. uint16_t fy = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  373. display.firstPage();
  374. do
  375. {
  376. display.fillScreen(GxEPD_WHITE);
  377. display.setCursor(wx, wy);
  378. display.print(wokeup);
  379. display.setCursor(fx, fy);
  380. display.print(from);
  381. }
  382. while (display.nextPage());
  383. delay(5000);
  384. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  385. uint16_t hx = (display.width() - tbw) / 2;
  386. uint16_t hy = (display.height() / 3) + tbh / 2; // y is base line!
  387. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  388. uint16_t ax = (display.width() - tbw) / 2;
  389. uint16_t ay = (display.height() * 2 / 3) + tbh / 2; // y is base line!
  390. display.firstPage();
  391. do
  392. {
  393. display.fillScreen(GxEPD_WHITE);
  394. display.setCursor(hx, hy);
  395. display.print(hibernating);
  396. display.setCursor(ax, ay);
  397. display.print(again);
  398. }
  399. while (display.nextPage());
  400. display.hibernate();
  401. //Serial.println("deepSleepTest done");
  402. }
  403. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  404. {
  405. //Serial.println("showBox");
  406. display.setRotation(1);
  407. if (partial)
  408. {
  409. display.setPartialWindow(x, y, w, h);
  410. }
  411. else
  412. {
  413. display.setFullWindow();
  414. }
  415. display.firstPage();
  416. do
  417. {
  418. display.fillScreen(GxEPD_WHITE);
  419. display.fillRect(x, y, w, h, GxEPD_BLACK);
  420. }
  421. while (display.nextPage());
  422. //Serial.println("showBox done");
  423. }
  424. void drawCornerTest()
  425. {
  426. display.setFullWindow();
  427. display.setFont(&FreeMonoBold9pt7b);
  428. display.setTextColor(GxEPD_BLACK);
  429. for (uint16_t r = 0; r <= 4; r++)
  430. {
  431. display.setRotation(r);
  432. display.firstPage();
  433. do
  434. {
  435. display.fillScreen(GxEPD_WHITE);
  436. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  437. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  438. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  439. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  440. display.setCursor(display.width() / 2, display.height() / 2);
  441. display.print(display.getRotation());
  442. }
  443. while (display.nextPage());
  444. delay(2000);
  445. }
  446. }
  447. void showFont(const char name[], const GFXfont* f)
  448. {
  449. display.setFullWindow();
  450. display.setRotation(0);
  451. display.setTextColor(GxEPD_BLACK);
  452. display.firstPage();
  453. do
  454. {
  455. drawFont(name, f);
  456. }
  457. while (display.nextPage());
  458. }
  459. void drawFont(const char name[], const GFXfont* f)
  460. {
  461. //display.setRotation(0);
  462. display.fillScreen(GxEPD_WHITE);
  463. display.setTextColor(GxEPD_BLACK);
  464. display.setFont(f);
  465. display.setCursor(0, 0);
  466. display.println();
  467. display.println(name);
  468. display.println(" !\"#$%&'()*+,-./");
  469. display.println("0123456789:;<=>?");
  470. display.println("@ABCDEFGHIJKLMNO");
  471. display.println("PQRSTUVWXYZ[\\]^_");
  472. if (display.epd2.hasColor)
  473. {
  474. display.setTextColor(GxEPD_RED);
  475. }
  476. display.println("`abcdefghijklmno");
  477. display.println("pqrstuvwxyz{|}~ ");
  478. }
  479. // note for partial update window and setPartialWindow() method:
  480. // partial update window size and position is on byte boundary in physical x direction
  481. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  482. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  483. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  484. void showPartialUpdate()
  485. {
  486. // some useful background
  487. helloWorld();
  488. // use asymmetric values for test
  489. uint16_t box_x = 10;
  490. uint16_t box_y = 15;
  491. uint16_t box_w = 70;
  492. uint16_t box_h = 20;
  493. uint16_t cursor_y = box_y + box_h - 6;
  494. float value = 13.95;
  495. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  496. display.setFont(&FreeMonoBold9pt7b);
  497. display.setTextColor(GxEPD_BLACK);
  498. // show where the update box is
  499. for (uint16_t r = 0; r < 4; r++)
  500. {
  501. display.setRotation(r);
  502. display.setPartialWindow(box_x, box_y, box_w, box_h);
  503. display.firstPage();
  504. do
  505. {
  506. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  507. //display.fillScreen(GxEPD_BLACK);
  508. }
  509. while (display.nextPage());
  510. delay(2000);
  511. display.firstPage();
  512. do
  513. {
  514. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  515. }
  516. while (display.nextPage());
  517. delay(1000);
  518. }
  519. //return;
  520. // show updates in the update box
  521. for (uint16_t r = 0; r < 4; r++)
  522. {
  523. display.setRotation(r);
  524. display.setPartialWindow(box_x, box_y, box_w, box_h);
  525. for (uint16_t i = 1; i <= 10; i += incr)
  526. {
  527. display.firstPage();
  528. do
  529. {
  530. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  531. display.setCursor(box_x, cursor_y);
  532. display.print(value * i, 2);
  533. }
  534. while (display.nextPage());
  535. delay(500);
  536. }
  537. delay(1000);
  538. display.firstPage();
  539. do
  540. {
  541. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  542. }
  543. while (display.nextPage());
  544. delay(1000);
  545. }
  546. }
  547. void drawBitmaps()
  548. {
  549. display.setFullWindow();
  550. #ifdef _GxBitmaps104x212_H_
  551. drawBitmaps104x212();
  552. #endif
  553. #ifdef _GxBitmaps128x250_H_
  554. drawBitmaps128x250();
  555. #endif
  556. #ifdef _GxBitmaps128x296_H_
  557. drawBitmaps128x296();
  558. #endif
  559. #ifdef _GxBitmaps176x264_H_
  560. drawBitmaps176x264();
  561. #endif
  562. #ifdef _GxBitmaps400x300_H_
  563. drawBitmaps400x300();
  564. #endif
  565. #ifdef _GxBitmaps640x384_H_
  566. drawBitmaps640x384();
  567. #endif
  568. #ifdef _WS_Bitmaps800x600_H_
  569. drawBitmaps800x600();
  570. #endif
  571. // 3-color
  572. #ifdef _GxBitmaps3c104x212_H_
  573. drawBitmaps3c104x212();
  574. #endif
  575. #ifdef _GxBitmaps3c128x296_H_
  576. drawBitmaps3c128x296();
  577. #endif
  578. #ifdef _GxBitmaps3c176x264_H_
  579. drawBitmaps3c176x264();
  580. #endif
  581. #ifdef _GxBitmaps3c400x300_H_
  582. drawBitmaps3c400x300();
  583. #endif
  584. // show these after the specific bitmaps
  585. #ifdef _GxBitmaps200x200_H_
  586. drawBitmaps200x200();
  587. #endif
  588. // 3-color
  589. #ifdef _GxBitmaps3c200x200_H_
  590. drawBitmaps3c200x200();
  591. #endif
  592. }
  593. #ifdef _GxBitmaps200x200_H_
  594. void drawBitmaps200x200()
  595. {
  596. #if defined(__AVR)
  597. const unsigned char* bitmaps[] =
  598. {
  599. logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  600. };
  601. #elif defined(_BOARD_GENERIC_STM32F103C_H_)
  602. const unsigned char* bitmaps[] =
  603. {
  604. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
  605. };
  606. #else
  607. const unsigned char* bitmaps[] =
  608. {
  609. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  610. };
  611. #endif
  612. if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67))
  613. {
  614. bool m = display.mirror(true);
  615. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  616. {
  617. display.firstPage();
  618. do
  619. {
  620. display.fillScreen(GxEPD_WHITE);
  621. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  622. }
  623. while (display.nextPage());
  624. delay(2000);
  625. }
  626. display.mirror(m);
  627. }
  628. //else
  629. {
  630. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  631. display.clearScreen(); // use default for white
  632. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  633. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  634. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  635. {
  636. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  637. delay(2000);
  638. }
  639. }
  640. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  641. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  642. {
  643. int16_t x = -60;
  644. int16_t y = -60;
  645. for (uint16_t j = 0; j < 10; j++)
  646. {
  647. display.writeScreenBuffer(); // use default for white
  648. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  649. display.refresh(true);
  650. if (display.epd2.hasFastPartialUpdate)
  651. {
  652. // for differential update: set previous buffer equal to current buffer in controller
  653. display.epd2.writeScreenBufferAgain(); // use default for white
  654. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  655. }
  656. delay(2000);
  657. x += 40;
  658. y += 40;
  659. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  660. }
  661. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  662. break; // comment out for full show
  663. }
  664. display.writeScreenBuffer(); // use default for white
  665. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  666. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  667. display.refresh(true);
  668. delay(2000);
  669. }
  670. #endif
  671. #ifdef _GxBitmaps104x212_H_
  672. void drawBitmaps104x212()
  673. {
  674. #if !defined(__AVR)
  675. const unsigned char* bitmaps[] =
  676. {
  677. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  678. };
  679. #else
  680. const unsigned char* bitmaps[] =
  681. {
  682. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  683. };
  684. #endif
  685. if (display.epd2.panel == GxEPD2::GDEW0213I5F)
  686. {
  687. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  688. {
  689. display.firstPage();
  690. do
  691. {
  692. display.fillScreen(GxEPD_WHITE);
  693. display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  694. }
  695. while (display.nextPage());
  696. delay(2000);
  697. }
  698. }
  699. }
  700. #endif
  701. #ifdef _GxBitmaps128x250_H_
  702. void drawBitmaps128x250()
  703. {
  704. #if !defined(__AVR)
  705. const unsigned char* bitmaps[] =
  706. {
  707. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  708. };
  709. #else
  710. const unsigned char* bitmaps[] =
  711. {
  712. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  713. };
  714. #endif
  715. if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
  716. {
  717. bool m = display.mirror(true);
  718. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  719. {
  720. display.firstPage();
  721. do
  722. {
  723. display.fillScreen(GxEPD_WHITE);
  724. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  725. }
  726. while (display.nextPage());
  727. delay(2000);
  728. }
  729. display.mirror(m);
  730. }
  731. }
  732. #endif
  733. #ifdef _GxBitmaps128x296_H_
  734. void drawBitmaps128x296()
  735. {
  736. #if !defined(__AVR)
  737. const unsigned char* bitmaps[] =
  738. {
  739. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  740. };
  741. #else
  742. const unsigned char* bitmaps[] =
  743. {
  744. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  745. };
  746. #endif
  747. if (display.epd2.panel == GxEPD2::GDEH029A1)
  748. {
  749. bool m = display.mirror(true);
  750. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  751. {
  752. display.firstPage();
  753. do
  754. {
  755. display.fillScreen(GxEPD_WHITE);
  756. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  757. }
  758. while (display.nextPage());
  759. delay(2000);
  760. }
  761. display.mirror(m);
  762. }
  763. }
  764. #endif
  765. #ifdef _GxBitmaps176x264_H_
  766. void drawBitmaps176x264()
  767. {
  768. #if !defined(__AVR)
  769. const unsigned char* bitmaps[] =
  770. {
  771. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  772. };
  773. #else
  774. const unsigned char* bitmaps[] =
  775. {
  776. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  777. };
  778. #endif
  779. if (display.epd2.panel == GxEPD2::GDEW027W3)
  780. {
  781. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  782. {
  783. display.firstPage();
  784. do
  785. {
  786. display.fillScreen(GxEPD_WHITE);
  787. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  788. }
  789. while (display.nextPage());
  790. delay(2000);
  791. }
  792. }
  793. }
  794. #endif
  795. #ifdef _GxBitmaps400x300_H_
  796. void drawBitmaps400x300()
  797. {
  798. #if !defined(__AVR)
  799. const unsigned char* bitmaps[] =
  800. {
  801. Bitmap400x300_1, Bitmap400x300_2
  802. };
  803. #else
  804. const unsigned char* bitmaps[] = {}; // not enough code space
  805. #endif
  806. if (display.epd2.panel == GxEPD2::GDEW042T2)
  807. {
  808. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  809. {
  810. display.firstPage();
  811. do
  812. {
  813. display.fillScreen(GxEPD_WHITE);
  814. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  815. }
  816. while (display.nextPage());
  817. delay(2000);
  818. }
  819. }
  820. }
  821. #endif
  822. #ifdef _GxBitmaps640x384_H_
  823. void drawBitmaps640x384()
  824. {
  825. #if !defined(__AVR)
  826. const unsigned char* bitmaps[] =
  827. {
  828. Bitmap640x384_1, Bitmap640x384_2
  829. };
  830. #else
  831. const unsigned char* bitmaps[] = {}; // not enough code space
  832. #endif
  833. if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
  834. {
  835. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  836. {
  837. display.firstPage();
  838. do
  839. {
  840. display.fillScreen(GxEPD_WHITE);
  841. display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  842. }
  843. while (display.nextPage());
  844. delay(2000);
  845. }
  846. }
  847. }
  848. #endif
  849. #ifdef _WS_Bitmaps800x600_H_
  850. void drawBitmaps800x600()
  851. {
  852. #if defined(ESP8266) || defined(ESP32)
  853. if (display.epd2.panel == GxEPD2::ED060SCT)
  854. {
  855. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  856. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  857. delay(2000);
  858. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  859. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  860. // delay(2000);
  861. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  862. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  863. // delay(2000);
  864. }
  865. #endif
  866. }
  867. #endif
  868. struct bitmap_pair
  869. {
  870. const unsigned char* black;
  871. const unsigned char* red;
  872. };
  873. #ifdef _GxBitmaps3c200x200_H_
  874. void drawBitmaps3c200x200()
  875. {
  876. bitmap_pair bitmap_pairs[] =
  877. {
  878. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  879. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  880. };
  881. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  882. {
  883. display.firstPage();
  884. do
  885. {
  886. display.fillScreen(GxEPD_WHITE);
  887. // Bitmap3c200x200_black has 2 bits per pixel
  888. // taken from Adafruit_GFX.cpp, modified
  889. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  890. uint8_t byte = 0;
  891. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  892. {
  893. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  894. {
  895. if (i & 3) byte <<= 2;
  896. else
  897. {
  898. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  899. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  900. #else
  901. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  902. #endif
  903. }
  904. if (!(byte & 0x80))
  905. {
  906. display.drawPixel(i, j, GxEPD_BLACK);
  907. }
  908. }
  909. }
  910. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  911. }
  912. while (display.nextPage());
  913. delay(2000);
  914. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  915. {
  916. display.firstPage();
  917. do
  918. {
  919. display.fillScreen(GxEPD_WHITE);
  920. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  921. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  922. }
  923. while (display.nextPage());
  924. delay(2000);
  925. }
  926. }
  927. if (display.epd2.hasColor)
  928. {
  929. display.clearScreen(); // use default for white
  930. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  931. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  932. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  933. {
  934. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  935. delay(2000);
  936. }
  937. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  938. {
  939. int16_t x = -60;
  940. int16_t y = -60;
  941. for (uint16_t j = 0; j < 10; j++)
  942. {
  943. display.writeScreenBuffer(); // use default for white
  944. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  945. display.refresh();
  946. delay(1000);
  947. x += 40;
  948. y += 40;
  949. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  950. }
  951. }
  952. display.writeScreenBuffer(); // use default for white
  953. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  954. 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);
  955. display.refresh();
  956. delay(2000);
  957. }
  958. }
  959. #endif
  960. #ifdef _GxBitmaps3c104x212_H_
  961. void drawBitmaps3c104x212()
  962. {
  963. #if !defined(__AVR)
  964. bitmap_pair bitmap_pairs[] =
  965. {
  966. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  967. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  968. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  969. };
  970. #else
  971. bitmap_pair bitmap_pairs[] =
  972. {
  973. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  974. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  975. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  976. };
  977. #endif
  978. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  979. {
  980. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  981. {
  982. display.firstPage();
  983. do
  984. {
  985. display.fillScreen(GxEPD_WHITE);
  986. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  987. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  988. {
  989. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  990. }
  991. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  992. }
  993. while (display.nextPage());
  994. delay(2000);
  995. }
  996. }
  997. }
  998. #endif
  999. #ifdef _GxBitmaps3c128x296_H_
  1000. void drawBitmaps3c128x296()
  1001. {
  1002. #if !defined(__AVR)
  1003. bitmap_pair bitmap_pairs[] =
  1004. {
  1005. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1006. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1007. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1008. };
  1009. #else
  1010. bitmap_pair bitmap_pairs[] =
  1011. {
  1012. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1013. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1014. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1015. };
  1016. #endif
  1017. if (display.epd2.panel == GxEPD2::GDEW029Z10)
  1018. {
  1019. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1020. {
  1021. display.firstPage();
  1022. do
  1023. {
  1024. display.fillScreen(GxEPD_WHITE);
  1025. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1026. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1027. {
  1028. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1029. }
  1030. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1031. }
  1032. while (display.nextPage());
  1033. delay(2000);
  1034. }
  1035. }
  1036. }
  1037. #endif
  1038. #ifdef _GxBitmaps3c176x264_H_
  1039. void drawBitmaps3c176x264()
  1040. {
  1041. bitmap_pair bitmap_pairs[] =
  1042. {
  1043. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1044. };
  1045. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1046. {
  1047. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1048. {
  1049. display.firstPage();
  1050. do
  1051. {
  1052. display.fillScreen(GxEPD_WHITE);
  1053. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1054. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1055. }
  1056. while (display.nextPage());
  1057. delay(2000);
  1058. }
  1059. }
  1060. }
  1061. #endif
  1062. #ifdef _GxBitmaps3c400x300_H_
  1063. void drawBitmaps3c400x300()
  1064. {
  1065. #if !defined(__AVR)
  1066. bitmap_pair bitmap_pairs[] =
  1067. {
  1068. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1069. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1070. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1071. };
  1072. #else
  1073. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1074. #endif
  1075. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1076. {
  1077. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1078. {
  1079. display.firstPage();
  1080. do
  1081. {
  1082. display.fillScreen(GxEPD_WHITE);
  1083. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1084. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1085. }
  1086. while (display.nextPage());
  1087. delay(2000);
  1088. }
  1089. }
  1090. }
  1091. #endif