GxEPD2_Example.ino 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703
  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. // Supporting Arduino Forum Topics:
  12. // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
  13. // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
  14. // see GxEPD2_wiring_examples.h for wiring suggestions and examples
  15. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  16. // enable or disable GxEPD2_GFX base class
  17. #define ENABLE_GxEPD2_GFX 0
  18. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  19. //#include <GFX.h>
  20. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  21. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  22. #include <GxEPD2_BW.h>
  23. #include <GxEPD2_3C.h>
  24. #include <GxEPD2_7C.h>
  25. #include <Fonts/FreeMonoBold9pt7b.h>
  26. // select the display constructor line in one of the following files (old style):
  27. #include "GxEPD2_display_selection.h"
  28. #include "GxEPD2_display_selection_added.h"
  29. //#include "GxEPD2_display_selection_more.h" // private
  30. // or select the display class and display driver class in the following file (new style):
  31. #include "GxEPD2_display_selection_new_style.h"
  32. #if !defined(__AVR) && !defined(_BOARD_GENERIC_STM32F103C_H_) && !defined(ARDUINO_BLUEPILL_F103C8)
  33. // note 16.11.2019: the compiler may exclude code based on constant if statements (display.epd2.panel == constant),
  34. // therefore bitmaps may get optimized out by the linker
  35. // comment out unused bitmaps to reduce code space used
  36. #include "bitmaps/Bitmaps80x128.h" // 1.02" b/w
  37. #include "bitmaps/Bitmaps152x152.h" // 1.54" b/w
  38. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  39. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  40. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  41. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  42. #include "bitmaps/Bitmaps152x296.h" // 2.6" b/w
  43. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  44. #include "bitmaps/Bitmaps240x416.h" // 3.71" b/w
  45. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  46. #include "bitmaps/Bitmaps648x480.h" // 5.38" b/w
  47. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  48. #include "bitmaps/Bitmaps800x480.h" // 7.5" b/w
  49. // 3-color
  50. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  51. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  52. #include "bitmaps/Bitmaps3c128x250.h" // 2.13" b/w/r
  53. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  54. #include "bitmaps/Bitmaps3c152x296.h" // 2.66" b/w/r
  55. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  56. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  57. #if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
  58. #include "bitmaps/Bitmaps3c648x480.h" // 5.83" b/w/r
  59. #include "bitmaps/Bitmaps3c800x480.h" // 7.5" b/w/r
  60. #include "bitmaps/Bitmaps3c880x528.h" // 7.5" b/w/r
  61. #include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
  62. #include "bitmaps/WS_Bitmaps7c192x143.h" // 5.65" 7-color
  63. #endif
  64. #if defined(ESP32)
  65. #include "bitmaps/Bitmaps1304x984.h" // 12.48" b/w
  66. #endif
  67. #else
  68. // select only one to fit in code space
  69. //#include "bitmaps/Bitmaps80x128.h" // 1.02" b/w
  70. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  71. //#include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  72. //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  73. //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  74. //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  75. ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
  76. ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
  77. // 3-color
  78. //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  79. //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  80. #include "bitmaps/Bitmaps3c128x250.h" // 2.13" b/w/r
  81. //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  82. //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  83. ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
  84. #endif
  85. #if defined(ARDUINO_ARCH_RP2040) && defined(ARDUINO_RASPBERRY_PI_PICO)
  86. // SPI pins used by GoodDisplay DESPI-PICO. note: steals standard I2C pins PIN_WIRE_SDA (6), PIN_WIRE_SCL (7)
  87. // uncomment next line for use with GoodDisplay DESPI-PICO.
  88. arduino::MbedSPI SPI0(4, 7, 6); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  89. #endif
  90. void setup()
  91. {
  92. Serial.begin(115200);
  93. Serial.println();
  94. Serial.println("setup");
  95. delay(100);
  96. #if defined(ARDUINO_ARCH_RP2040) && defined(ARDUINO_RASPBERRY_PI_PICO)
  97. // uncomment next line for use with GoodDisplay DESPI-PICO, or use the extended init method
  98. //display.epd2.selectSPI(SPI0, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  99. // uncomment next 2 lines to allow recovery from configuration failures
  100. pinMode(15, INPUT_PULLUP); // safety pin
  101. while (!digitalRead(15)) delay(100); // check safety pin for fail recovery
  102. #endif
  103. display.init(115200); // default 10ms reset pulse, e.g. for bare panels with DESPI-C02
  104. //display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
  105. //display.init(115200, true, 10, false, SPI0, SPISettings(4000000, MSBFIRST, SPI_MODE0)); // extended init method with SPI channel and/or settings selection
  106. // first update should be full refresh
  107. helloWorld();
  108. delay(1000);
  109. // partial refresh mode can be used to full screen,
  110. // effective if display panel hasFastPartialUpdate
  111. helloFullScreenPartialMode();
  112. delay(1000);
  113. //stripeTest(); return; // GDEH029Z13 issue
  114. helloArduino();
  115. delay(1000);
  116. helloEpaper();
  117. delay(1000);
  118. //helloValue(123.9, 1);
  119. //delay(1000);
  120. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  121. delay(1000);
  122. if (display.epd2.WIDTH < 104)
  123. {
  124. showFont("glcdfont", 0);
  125. delay(1000);
  126. }
  127. drawBitmaps();
  128. #if !defined(__AVR) // takes too long!
  129. if (display.epd2.panel == GxEPD2::ACeP565)
  130. {
  131. //draw7colorlines();
  132. //delay(2000);
  133. draw7colors();
  134. delay(4000);
  135. }
  136. #endif
  137. if (display.epd2.hasPartialUpdate)
  138. {
  139. showPartialUpdate();
  140. delay(1000);
  141. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  142. //drawCornerTest();
  143. //showBox(16, 16, 48, 32, false);
  144. //showBox(16, 56, 48, 32, true);
  145. display.powerOff();
  146. deepSleepTest();
  147. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  148. drawBitmaps1304x984();
  149. display.powerOff();
  150. #endif
  151. Serial.println("setup done");
  152. }
  153. void loop()
  154. {
  155. }
  156. // note for partial update window and setPartialWindow() method:
  157. // partial update window size and position is on byte boundary in physical x direction
  158. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  159. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  160. const char HelloWorld[] = "Hello World!";
  161. const char HelloArduino[] = "Hello Arduino!";
  162. const char HelloEpaper[] = "Hello E-Paper!";
  163. void helloWorld()
  164. {
  165. //Serial.println("helloWorld");
  166. display.setRotation(1);
  167. display.setFont(&FreeMonoBold9pt7b);
  168. if (display.epd2.WIDTH < 104) display.setFont(0);
  169. display.setTextColor(GxEPD_BLACK);
  170. int16_t tbx, tby; uint16_t tbw, tbh;
  171. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  172. // center bounding box by transposition of origin:
  173. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  174. uint16_t y = ((display.height() - tbh) / 2) - tby;
  175. display.setFullWindow();
  176. display.firstPage();
  177. do
  178. {
  179. display.fillScreen(GxEPD_WHITE);
  180. display.setCursor(x, y);
  181. display.print(HelloWorld);
  182. }
  183. while (display.nextPage());
  184. //Serial.println("helloWorld done");
  185. }
  186. void helloWorldForDummies()
  187. {
  188. //Serial.println("helloWorld");
  189. const char text[] = "Hello World!";
  190. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  191. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  192. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  193. display.setRotation(1);
  194. // select a suitable font in Adafruit_GFX
  195. display.setFont(&FreeMonoBold9pt7b);
  196. // on e-papers black on white is more pleasant to read
  197. display.setTextColor(GxEPD_BLACK);
  198. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  199. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  200. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  201. // center bounding box by transposition of origin:
  202. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  203. uint16_t y = ((display.height() - tbh) / 2) - tby;
  204. // full window mode is the initial mode, set it anyway
  205. display.setFullWindow();
  206. // here we use paged drawing, even if the processor has enough RAM for full buffer
  207. // so this can be used with any supported processor board.
  208. // the cost in code overhead and execution time penalty is marginal
  209. // tell the graphics class to use paged drawing mode
  210. display.firstPage();
  211. do
  212. {
  213. // this part of code is executed multiple times, as many as needed,
  214. // in case of full buffer it is executed once
  215. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  216. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  217. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  218. display.setCursor(x, y); // set the postition to start printing text
  219. display.print(text); // print some text
  220. // end of part executed multiple times
  221. }
  222. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  223. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  224. // returns true if more pages need be drawn and transferred
  225. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  226. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  227. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  228. while (display.nextPage());
  229. //Serial.println("helloWorld done");
  230. }
  231. void helloFullScreenPartialMode()
  232. {
  233. //Serial.println("helloFullScreenPartialMode");
  234. const char fullscreen[] = "full screen update";
  235. const char fpm[] = "fast partial mode";
  236. const char spm[] = "slow partial mode";
  237. const char npm[] = "no partial mode";
  238. display.setPartialWindow(0, 0, display.width(), display.height());
  239. display.setRotation(1);
  240. display.setFont(&FreeMonoBold9pt7b);
  241. if (display.epd2.WIDTH < 104) display.setFont(0);
  242. display.setTextColor(GxEPD_BLACK);
  243. const char* updatemode;
  244. if (display.epd2.hasFastPartialUpdate)
  245. {
  246. updatemode = fpm;
  247. }
  248. else if (display.epd2.hasPartialUpdate)
  249. {
  250. updatemode = spm;
  251. }
  252. else
  253. {
  254. updatemode = npm;
  255. }
  256. // do this outside of the loop
  257. int16_t tbx, tby; uint16_t tbw, tbh;
  258. // center update text
  259. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  260. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  261. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  262. // center update mode
  263. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  264. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  265. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  266. // center HelloWorld
  267. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  268. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  269. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  270. display.firstPage();
  271. do
  272. {
  273. display.fillScreen(GxEPD_WHITE);
  274. display.setCursor(hwx, hwy);
  275. display.print(HelloWorld);
  276. display.setCursor(utx, uty);
  277. display.print(fullscreen);
  278. display.setCursor(umx, umy);
  279. display.print(updatemode);
  280. }
  281. while (display.nextPage());
  282. //Serial.println("helloFullScreenPartialMode done");
  283. }
  284. void helloArduino()
  285. {
  286. //Serial.println("helloArduino");
  287. display.setRotation(1);
  288. display.setFont(&FreeMonoBold9pt7b);
  289. if (display.epd2.WIDTH < 104) display.setFont(0);
  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. if (display.epd2.WIDTH < 104) display.setFont(0);
  320. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  321. int16_t tbx, tby; uint16_t tbw, tbh;
  322. // align with centered HelloWorld
  323. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  324. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  325. // height might be different
  326. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  327. uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
  328. // make the window big enough to cover (overwrite) descenders of previous text
  329. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  330. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  331. display.setPartialWindow(0, wy, display.width(), wh);
  332. display.firstPage();
  333. do
  334. {
  335. display.fillScreen(GxEPD_WHITE);
  336. display.setCursor(x, y);
  337. display.print(HelloEpaper);
  338. }
  339. while (display.nextPage());
  340. //Serial.println("helloEpaper done");
  341. }
  342. // test partial window issue on GDEW0213Z19 and GDEH029Z13
  343. void stripeTest()
  344. {
  345. helloStripe(104);
  346. delay(2000);
  347. helloStripe(96);
  348. }
  349. const char HelloStripe[] = "Hello Stripe!";
  350. void helloStripe(uint16_t pw_xe) // end of partial window in physcal x direction
  351. {
  352. //Serial.print("HelloStripe("); Serial.print(pw_xe); Serial.println(")");
  353. display.setRotation(3);
  354. display.setFont(&FreeMonoBold9pt7b);
  355. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  356. int16_t tbx, tby; uint16_t tbw, tbh;
  357. display.getTextBounds(HelloStripe, 0, 0, &tbx, &tby, &tbw, &tbh);
  358. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  359. uint16_t wy = pw_xe - wh;
  360. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  361. uint16_t y = wy - tby;
  362. display.setPartialWindow(0, wy, display.width(), wh);
  363. display.firstPage();
  364. do
  365. {
  366. display.fillScreen(GxEPD_WHITE);
  367. display.setCursor(x, y);
  368. display.print(HelloStripe);
  369. }
  370. while (display.nextPage());
  371. //Serial.println("HelloStripe done");
  372. }
  373. #if defined(ESP8266) || defined(ESP32)
  374. #include <StreamString.h>
  375. #define PrintString StreamString
  376. #else
  377. class PrintString : public Print, public String
  378. {
  379. public:
  380. size_t write(uint8_t data) override
  381. {
  382. return concat(char(data));
  383. };
  384. };
  385. #endif
  386. void helloValue(double v, int digits)
  387. {
  388. //Serial.println("helloValue");
  389. display.setRotation(1);
  390. display.setFont(&FreeMonoBold9pt7b);
  391. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  392. PrintString valueString;
  393. valueString.print(v, digits);
  394. int16_t tbx, tby; uint16_t tbw, tbh;
  395. display.getTextBounds(valueString, 0, 0, &tbx, &tby, &tbw, &tbh);
  396. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  397. uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
  398. // show what happens, if we use the bounding box for partial window
  399. uint16_t wx = (display.width() - tbw) / 2;
  400. uint16_t wy = ((display.height() * 3 / 4) - tbh / 2);
  401. display.setPartialWindow(wx, wy, tbw, tbh);
  402. display.firstPage();
  403. do
  404. {
  405. display.fillScreen(GxEPD_WHITE);
  406. display.setCursor(x, y);
  407. display.print(valueString);
  408. }
  409. while (display.nextPage());
  410. delay(2000);
  411. // make the partial window big enough to cover the previous text
  412. uint16_t ww = tbw; // remember window width
  413. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  414. // adjust, because HelloEpaper was aligned, not centered (could calculate this to be precise)
  415. ww = max(ww, uint16_t(tbw + 12)); // 12 seems ok
  416. wx = (display.width() - tbw) / 2;
  417. // make the window big enough to cover (overwrite) descenders of previous text
  418. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  419. wy = (display.height() * 3 / 4) - wh / 2;
  420. display.setPartialWindow(wx, wy, ww, wh);
  421. // alternately use the whole width for partial window
  422. //display.setPartialWindow(0, wy, display.width(), wh);
  423. display.firstPage();
  424. do
  425. {
  426. display.fillScreen(GxEPD_WHITE);
  427. display.setCursor(x, y);
  428. display.print(valueString);
  429. }
  430. while (display.nextPage());
  431. //Serial.println("helloValue done");
  432. }
  433. void deepSleepTest()
  434. {
  435. //Serial.println("deepSleepTest");
  436. const char hibernating[] = "hibernating ...";
  437. const char wokeup[] = "woke up";
  438. const char from[] = "from deep sleep";
  439. const char again[] = "again";
  440. display.setRotation(1);
  441. display.setFont(&FreeMonoBold9pt7b);
  442. if (display.epd2.WIDTH < 104) display.setFont(0);
  443. display.setTextColor(GxEPD_BLACK);
  444. int16_t tbx, tby; uint16_t tbw, tbh;
  445. // center text
  446. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  447. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  448. uint16_t y = ((display.height() - tbh) / 2) - tby;
  449. display.setFullWindow();
  450. display.firstPage();
  451. do
  452. {
  453. display.fillScreen(GxEPD_WHITE);
  454. display.setCursor(x, y);
  455. display.print(hibernating);
  456. }
  457. while (display.nextPage());
  458. display.hibernate();
  459. delay(5000);
  460. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  461. uint16_t wx = (display.width() - tbw) / 2;
  462. uint16_t wy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  463. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  464. uint16_t fx = (display.width() - tbw) / 2;
  465. uint16_t fy = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  466. display.firstPage();
  467. do
  468. {
  469. display.fillScreen(GxEPD_WHITE);
  470. display.setCursor(wx, wy);
  471. display.print(wokeup);
  472. display.setCursor(fx, fy);
  473. display.print(from);
  474. }
  475. while (display.nextPage());
  476. delay(5000);
  477. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  478. uint16_t hx = (display.width() - tbw) / 2;
  479. uint16_t hy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  480. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  481. uint16_t ax = (display.width() - tbw) / 2;
  482. uint16_t ay = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  483. display.firstPage();
  484. do
  485. {
  486. display.fillScreen(GxEPD_WHITE);
  487. display.setCursor(hx, hy);
  488. display.print(hibernating);
  489. display.setCursor(ax, ay);
  490. display.print(again);
  491. }
  492. while (display.nextPage());
  493. display.hibernate();
  494. //Serial.println("deepSleepTest done");
  495. }
  496. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  497. {
  498. //Serial.println("showBox");
  499. display.setRotation(1);
  500. if (partial)
  501. {
  502. display.setPartialWindow(x, y, w, h);
  503. }
  504. else
  505. {
  506. display.setFullWindow();
  507. }
  508. display.firstPage();
  509. do
  510. {
  511. display.fillScreen(GxEPD_WHITE);
  512. display.fillRect(x, y, w, h, GxEPD_BLACK);
  513. }
  514. while (display.nextPage());
  515. //Serial.println("showBox done");
  516. }
  517. void drawCornerTest()
  518. {
  519. display.setFullWindow();
  520. display.setFont(&FreeMonoBold9pt7b);
  521. display.setTextColor(GxEPD_BLACK);
  522. for (uint16_t r = 0; r <= 4; r++)
  523. {
  524. display.setRotation(r);
  525. display.firstPage();
  526. do
  527. {
  528. display.fillScreen(GxEPD_WHITE);
  529. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  530. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  531. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  532. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  533. display.setCursor(display.width() / 2, display.height() / 2);
  534. display.print(display.getRotation());
  535. }
  536. while (display.nextPage());
  537. delay(2000);
  538. }
  539. }
  540. void showFont(const char name[], const GFXfont* f)
  541. {
  542. display.setFullWindow();
  543. display.setRotation(0);
  544. display.setTextColor(GxEPD_BLACK);
  545. display.firstPage();
  546. do
  547. {
  548. drawFont(name, f);
  549. }
  550. while (display.nextPage());
  551. }
  552. void drawFont(const char name[], const GFXfont* f)
  553. {
  554. //display.setRotation(0);
  555. display.fillScreen(GxEPD_WHITE);
  556. display.setTextColor(GxEPD_BLACK);
  557. display.setFont(f);
  558. display.setCursor(0, 0);
  559. display.println();
  560. display.println(name);
  561. display.println(" !\"#$%&'()*+,-./");
  562. display.println("0123456789:;<=>?");
  563. display.println("@ABCDEFGHIJKLMNO");
  564. display.println("PQRSTUVWXYZ[\\]^_");
  565. if (display.epd2.hasColor)
  566. {
  567. display.setTextColor(GxEPD_RED);
  568. }
  569. display.println("`abcdefghijklmno");
  570. display.println("pqrstuvwxyz{|}~ ");
  571. }
  572. // note for partial update window and setPartialWindow() method:
  573. // partial update window size and position is on byte boundary in physical x direction
  574. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  575. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  576. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  577. void showPartialUpdate()
  578. {
  579. // some useful background
  580. helloWorld();
  581. // use asymmetric values for test
  582. uint16_t box_x = 10;
  583. uint16_t box_y = 15;
  584. uint16_t box_w = 70;
  585. uint16_t box_h = 20;
  586. uint16_t cursor_y = box_y + box_h - 6;
  587. if (display.epd2.WIDTH < 104) cursor_y = box_y + 6;
  588. float value = 13.95;
  589. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  590. display.setFont(&FreeMonoBold9pt7b);
  591. if (display.epd2.WIDTH < 104) display.setFont(0);
  592. display.setTextColor(GxEPD_BLACK);
  593. // show where the update box is
  594. for (uint16_t r = 0; r < 4; r++)
  595. {
  596. display.setRotation(r);
  597. display.setPartialWindow(box_x, box_y, box_w, box_h);
  598. display.firstPage();
  599. do
  600. {
  601. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  602. //display.fillScreen(GxEPD_BLACK);
  603. }
  604. while (display.nextPage());
  605. delay(2000);
  606. display.firstPage();
  607. do
  608. {
  609. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  610. }
  611. while (display.nextPage());
  612. delay(1000);
  613. }
  614. //return;
  615. // show updates in the update box
  616. for (uint16_t r = 0; r < 4; r++)
  617. {
  618. display.setRotation(r);
  619. display.setPartialWindow(box_x, box_y, box_w, box_h);
  620. for (uint16_t i = 1; i <= 10; i += incr)
  621. {
  622. display.firstPage();
  623. do
  624. {
  625. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  626. display.setCursor(box_x, cursor_y);
  627. display.print(value * i, 2);
  628. }
  629. while (display.nextPage());
  630. delay(500);
  631. }
  632. delay(1000);
  633. display.firstPage();
  634. do
  635. {
  636. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  637. }
  638. while (display.nextPage());
  639. delay(1000);
  640. }
  641. }
  642. void drawBitmaps()
  643. {
  644. display.setFullWindow();
  645. #ifdef _GxBitmaps80x128_H_
  646. drawBitmaps80x128();
  647. #endif
  648. #ifdef _GxBitmaps152x152_H_
  649. drawBitmaps152x152();
  650. #endif
  651. #ifdef _GxBitmaps104x212_H_
  652. drawBitmaps104x212();
  653. #endif
  654. #ifdef _GxBitmaps128x250_H_
  655. drawBitmaps128x250();
  656. #endif
  657. #ifdef _GxBitmaps128x296_H_
  658. drawBitmaps128x296();
  659. #endif
  660. #ifdef _GxBitmaps152x296_H_
  661. drawBitmaps152x296();
  662. #endif
  663. #ifdef _GxBitmaps176x264_H_
  664. drawBitmaps176x264();
  665. #endif
  666. #ifdef _GxBitmaps240x416_H_
  667. drawBitmaps240x416();
  668. #endif
  669. #ifdef _GxBitmaps400x300_H_
  670. drawBitmaps400x300();
  671. #endif
  672. #ifdef _GxBitmaps640x384_H_
  673. drawBitmaps640x384();
  674. #endif
  675. #ifdef _GxBitmaps648x480_H_
  676. drawBitmaps648x480();
  677. #endif
  678. #ifdef _GxBitmaps800x480_H_
  679. drawBitmaps800x480();
  680. #endif
  681. #ifdef _WS_Bitmaps800x600_H_
  682. drawBitmaps800x600();
  683. #endif
  684. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  685. drawBitmaps1304x984();
  686. #endif
  687. // 3-color
  688. #ifdef _GxBitmaps3c104x212_H_
  689. drawBitmaps3c104x212();
  690. #endif
  691. #ifdef _GxBitmaps3c128x250_H_
  692. drawBitmaps3c128x250();
  693. #endif
  694. #ifdef _GxBitmaps3c128x296_H_
  695. drawBitmaps3c128x296();
  696. #endif
  697. #ifdef _GxBitmaps3c152x296_H_
  698. drawBitmaps3c152x296();
  699. #endif
  700. #ifdef _GxBitmaps3c176x264_H_
  701. drawBitmaps3c176x264();
  702. #endif
  703. #ifdef _GxBitmaps3c400x300_H_
  704. drawBitmaps3c400x300();
  705. #endif
  706. #ifdef _GxBitmaps3c648x480_H_
  707. drawBitmaps3c648x480();
  708. #endif
  709. #ifdef _GxBitmaps3c800x480_H_
  710. drawBitmaps3c800x480();
  711. #endif
  712. #ifdef _GxBitmaps3c880x528_H_
  713. drawBitmaps3c880x528();
  714. #endif
  715. #if defined(_WS_Bitmaps7c192x143_H_)
  716. drawBitmaps7c192x143();
  717. #endif
  718. if ((display.epd2.WIDTH >= 200) && (display.epd2.HEIGHT >= 200))
  719. {
  720. // show these after the specific bitmaps
  721. #ifdef _GxBitmaps200x200_H_
  722. drawBitmaps200x200();
  723. #endif
  724. // 3-color
  725. #ifdef _GxBitmaps3c200x200_H_
  726. drawBitmaps3c200x200();
  727. #endif
  728. }
  729. }
  730. #ifdef _GxBitmaps80x128_H_
  731. void drawBitmaps80x128()
  732. {
  733. #if !defined(__AVR)
  734. const unsigned char* bitmaps[] =
  735. {
  736. Bitmap80x128_1, Bitmap80x128_2, Bitmap80x128_3, Bitmap80x128_4, Bitmap80x128_5
  737. };
  738. #else
  739. const unsigned char* bitmaps[] =
  740. {
  741. Bitmap80x128_1, Bitmap80x128_2, Bitmap80x128_3, Bitmap80x128_4, Bitmap80x128_5
  742. };
  743. #endif
  744. if ((display.epd2.WIDTH == 80) && (display.epd2.HEIGHT == 128))
  745. {
  746. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  747. {
  748. display.firstPage();
  749. do
  750. {
  751. display.fillScreen(GxEPD_WHITE);
  752. display.drawInvertedBitmap(0, 0, bitmaps[i], 80, 128, GxEPD_BLACK);
  753. }
  754. while (display.nextPage());
  755. delay(2000);
  756. }
  757. display.firstPage();
  758. do
  759. {
  760. display.fillScreen(GxEPD_WHITE);
  761. display.drawBitmap(0, 0, WS_Bitmap80x128, 80, 128, GxEPD_BLACK);
  762. }
  763. while (display.nextPage());
  764. delay(2000);
  765. }
  766. }
  767. #endif
  768. #ifdef _GxBitmaps152x152_H_
  769. void drawBitmaps152x152()
  770. {
  771. #if !defined(__AVR)
  772. const unsigned char* bitmaps[] =
  773. {
  774. Bitmap152x152_1, Bitmap152x152_2, Bitmap152x152_3
  775. };
  776. #else
  777. const unsigned char* bitmaps[] =
  778. {
  779. Bitmap152x152_1, Bitmap152x152_2, Bitmap152x152_3
  780. };
  781. #endif
  782. if ((display.epd2.WIDTH == 152) && (display.epd2.HEIGHT == 152))
  783. {
  784. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  785. {
  786. display.firstPage();
  787. do
  788. {
  789. display.fillScreen(GxEPD_WHITE);
  790. display.drawInvertedBitmap(0, 0, bitmaps[i], 152, 152, GxEPD_BLACK);
  791. }
  792. while (display.nextPage());
  793. delay(2000);
  794. }
  795. }
  796. }
  797. #endif
  798. #ifdef _GxBitmaps200x200_H_
  799. void drawBitmaps200x200()
  800. {
  801. #if defined(ARDUINO_AVR_PRO)
  802. const unsigned char* bitmaps[] =
  803. {
  804. logo200x200
  805. };
  806. #elif defined(__AVR)
  807. const unsigned char* bitmaps[] =
  808. {
  809. logo200x200, //first200x200
  810. };
  811. #elif defined(_BOARD_GENERIC_STM32F103C_H_) || defined(STM32F1xx)
  812. const unsigned char* bitmaps[] =
  813. {
  814. logo200x200, first200x200, second200x200, third200x200, //fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  815. };
  816. #else
  817. const unsigned char* bitmaps[] =
  818. {
  819. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  820. //logo200x200, first200x200, second200x200, fourth200x200, third200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200 // ED037TC1 test
  821. };
  822. #endif
  823. if ((display.epd2.WIDTH == 200) && (display.epd2.HEIGHT == 200) && !display.epd2.hasColor)
  824. {
  825. bool m = display.mirror(true);
  826. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  827. {
  828. display.firstPage();
  829. do
  830. {
  831. display.fillScreen(GxEPD_WHITE);
  832. display.drawInvertedBitmap(0, 0, bitmaps[i], 200, 200, GxEPD_BLACK);
  833. }
  834. while (display.nextPage());
  835. delay(2000);
  836. }
  837. display.mirror(m);
  838. }
  839. //else
  840. {
  841. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  842. display.clearScreen(); // use default for white
  843. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  844. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  845. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  846. {
  847. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  848. delay(2000);
  849. }
  850. }
  851. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  852. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  853. {
  854. int16_t x = -60;
  855. int16_t y = -60;
  856. for (uint16_t j = 0; j < 10; j++)
  857. {
  858. display.writeScreenBuffer(); // use default for white
  859. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  860. display.refresh(true);
  861. if (display.epd2.hasFastPartialUpdate)
  862. {
  863. // for differential update: set previous buffer equal to current buffer in controller
  864. display.epd2.writeScreenBufferAgain(); // use default for white
  865. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  866. }
  867. delay(2000);
  868. x += display.epd2.WIDTH / 4;
  869. y += display.epd2.HEIGHT / 4;
  870. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  871. }
  872. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  873. break; // comment out for full show
  874. }
  875. display.writeScreenBuffer(); // use default for white
  876. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  877. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  878. display.refresh(true);
  879. // for differential update: set previous buffer equal to current buffer in controller
  880. display.epd2.writeScreenBufferAgain(); // use default for white
  881. display.epd2.writeImageAgain(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  882. display.epd2.writeImageAgain(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  883. delay(2000);
  884. }
  885. #endif
  886. #ifdef _GxBitmaps104x212_H_
  887. void drawBitmaps104x212()
  888. {
  889. #if !defined(__AVR)
  890. const unsigned char* bitmaps[] =
  891. {
  892. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  893. };
  894. #else
  895. const unsigned char* bitmaps[] =
  896. {
  897. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  898. };
  899. #endif
  900. if ((display.epd2.WIDTH == 104) && (display.epd2.HEIGHT == 212) && !display.epd2.hasColor)
  901. {
  902. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  903. {
  904. display.firstPage();
  905. do
  906. {
  907. display.fillScreen(GxEPD_WHITE);
  908. display.drawBitmap(0, 0, bitmaps[i], 104, 212, GxEPD_BLACK);
  909. }
  910. while (display.nextPage());
  911. delay(2000);
  912. }
  913. }
  914. }
  915. #endif
  916. #ifdef _GxBitmaps128x250_H_
  917. void drawBitmaps128x250()
  918. {
  919. #if !defined(__AVR)
  920. const unsigned char* bitmaps[] =
  921. {
  922. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  923. };
  924. #else
  925. const unsigned char* bitmaps[] =
  926. {
  927. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  928. };
  929. #endif
  930. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 250) && !display.epd2.hasColor)
  931. {
  932. bool m = display.mirror(true);
  933. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  934. {
  935. display.firstPage();
  936. do
  937. {
  938. display.fillScreen(GxEPD_WHITE);
  939. display.drawInvertedBitmap(0, 0, bitmaps[i], 128, 250, GxEPD_BLACK);
  940. }
  941. while (display.nextPage());
  942. delay(2000);
  943. }
  944. display.mirror(m);
  945. }
  946. }
  947. #endif
  948. #ifdef _GxBitmaps128x296_H_
  949. void drawBitmaps128x296()
  950. {
  951. #if !defined(__AVR)
  952. const unsigned char* bitmaps[] =
  953. {
  954. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  955. };
  956. #else
  957. const unsigned char* bitmaps[] =
  958. {
  959. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  960. };
  961. #endif
  962. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 296) && !display.epd2.hasColor)
  963. {
  964. bool m = display.mirror(true);
  965. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  966. {
  967. display.firstPage();
  968. do
  969. {
  970. display.fillScreen(GxEPD_WHITE);
  971. display.drawInvertedBitmap(0, 0, bitmaps[i], 128, 296, GxEPD_BLACK);
  972. }
  973. while (display.nextPage());
  974. delay(2000);
  975. }
  976. display.mirror(m);
  977. }
  978. }
  979. #endif
  980. #ifdef _GxBitmaps152x296_H_
  981. void drawBitmaps152x296()
  982. {
  983. #if !defined(__AVR)
  984. const unsigned char* bitmaps[] =
  985. {
  986. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  987. };
  988. #else
  989. const unsigned char* bitmaps[] =
  990. {
  991. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  992. };
  993. #endif
  994. if ((display.epd2.WIDTH == 152) && (display.epd2.HEIGHT == 296) && !display.epd2.hasColor)
  995. {
  996. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  997. {
  998. display.firstPage();
  999. do
  1000. {
  1001. display.fillScreen(GxEPD_WHITE);
  1002. display.drawInvertedBitmap(0, 0, bitmaps[i], 152, 296, GxEPD_BLACK);
  1003. }
  1004. while (display.nextPage());
  1005. delay(2000);
  1006. }
  1007. }
  1008. }
  1009. #endif
  1010. #ifdef _GxBitmaps176x264_H_
  1011. void drawBitmaps176x264()
  1012. {
  1013. #if !defined(__AVR)
  1014. const unsigned char* bitmaps[] =
  1015. {
  1016. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1017. };
  1018. #else
  1019. const unsigned char* bitmaps[] =
  1020. {
  1021. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1022. };
  1023. #endif
  1024. if ((display.epd2.WIDTH == 176) && (display.epd2.HEIGHT == 264) && !display.epd2.hasColor)
  1025. {
  1026. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1027. {
  1028. display.firstPage();
  1029. do
  1030. {
  1031. display.fillScreen(GxEPD_WHITE);
  1032. display.drawInvertedBitmap(0, 0, bitmaps[i], 176, 264, GxEPD_BLACK);
  1033. }
  1034. while (display.nextPage());
  1035. delay(2000);
  1036. }
  1037. }
  1038. }
  1039. #endif
  1040. #ifdef _GxBitmaps240x416_H_
  1041. void drawBitmaps240x416()
  1042. {
  1043. #if !defined(__AVR)
  1044. const unsigned char* bitmaps[] =
  1045. {
  1046. Bitmap240x416_1, Bitmap240x416_2, Bitmap240x416_3
  1047. };
  1048. #else
  1049. const unsigned char* bitmaps[] =
  1050. {
  1051. Bitmap240x460_1, Bitmap240x460_2, Bitmap240x460_3
  1052. };
  1053. #endif
  1054. if ((display.epd2.WIDTH == 240) && (display.epd2.HEIGHT == 416) && !display.epd2.hasColor)
  1055. {
  1056. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1057. {
  1058. display.firstPage();
  1059. do
  1060. {
  1061. display.fillScreen(GxEPD_WHITE);
  1062. display.drawInvertedBitmap(0, 0, bitmaps[i], 240, 416, GxEPD_BLACK);
  1063. }
  1064. while (display.nextPage());
  1065. delay(2000);
  1066. }
  1067. }
  1068. }
  1069. #endif
  1070. #ifdef _GxBitmaps400x300_H_
  1071. void drawBitmaps400x300()
  1072. {
  1073. #if !defined(__AVR)
  1074. const unsigned char* bitmaps[] =
  1075. {
  1076. Bitmap400x300_1, Bitmap400x300_2
  1077. };
  1078. #else
  1079. const unsigned char* bitmaps[] = {}; // not enough code space
  1080. #endif
  1081. if ((display.epd2.WIDTH == 400) && (display.epd2.HEIGHT == 300) && !display.epd2.hasColor)
  1082. {
  1083. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1084. {
  1085. display.firstPage();
  1086. do
  1087. {
  1088. display.fillScreen(GxEPD_WHITE);
  1089. display.drawInvertedBitmap(0, 0, bitmaps[i], 400, 300, GxEPD_BLACK);
  1090. }
  1091. while (display.nextPage());
  1092. delay(2000);
  1093. }
  1094. }
  1095. }
  1096. #endif
  1097. #ifdef _GxBitmaps640x384_H_
  1098. void drawBitmaps640x384()
  1099. {
  1100. #if !defined(__AVR)
  1101. const unsigned char* bitmaps[] =
  1102. {
  1103. Bitmap640x384_1, Bitmap640x384_2
  1104. };
  1105. #else
  1106. const unsigned char* bitmaps[] = {}; // not enough code space
  1107. #endif
  1108. if ((display.epd2.WIDTH == 640) && (display.epd2.HEIGHT == 384))
  1109. {
  1110. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1111. {
  1112. display.firstPage();
  1113. do
  1114. {
  1115. display.fillScreen(GxEPD_WHITE);
  1116. display.drawInvertedBitmap(0, 0, bitmaps[i], 640, 384, GxEPD_BLACK);
  1117. }
  1118. while (display.nextPage());
  1119. delay(2000);
  1120. }
  1121. }
  1122. }
  1123. #endif
  1124. #ifdef _GxBitmaps648x480_H_
  1125. void drawBitmaps648x480()
  1126. {
  1127. #if !defined(__AVR)
  1128. const unsigned char* bitmaps[] =
  1129. {
  1130. Bitmap648x480_1, Bitmap648x480_2, Bitmap648x480_3
  1131. };
  1132. #else
  1133. const unsigned char* bitmaps[] = {}; // not enough code space
  1134. #endif
  1135. if ((display.epd2.WIDTH == 648) && (display.epd2.HEIGHT == 480) && !display.epd2.hasColor)
  1136. {
  1137. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1138. {
  1139. display.firstPage();
  1140. do
  1141. {
  1142. display.fillScreen(GxEPD_WHITE);
  1143. display.drawBitmap(0, 0, bitmaps[i], 648, 480, GxEPD_BLACK);
  1144. }
  1145. while (display.nextPage());
  1146. delay(2000);
  1147. }
  1148. }
  1149. }
  1150. #endif
  1151. #ifdef _GxBitmaps800x480_H_
  1152. void drawBitmaps800x480()
  1153. {
  1154. #if !defined(__AVR)
  1155. const unsigned char* bitmaps[] =
  1156. {
  1157. Bitmap800x480_1, Bitmap800x480_2, Bitmap800x480_3, Bitmap800x480_4
  1158. };
  1159. #else
  1160. const unsigned char* bitmaps[] = {}; // not enough code space
  1161. #endif
  1162. if ((display.epd2.WIDTH == 800) && (display.epd2.HEIGHT == 480))
  1163. {
  1164. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1165. {
  1166. display.firstPage();
  1167. do
  1168. {
  1169. display.fillScreen(GxEPD_WHITE);
  1170. display.drawBitmap(0, 0, bitmaps[i], 800, 480, GxEPD_BLACK);
  1171. }
  1172. while (display.nextPage());
  1173. delay(2000);
  1174. }
  1175. if (display.epd2.panel == GxEPD2::GDEW075T7)
  1176. {
  1177. // avoid ghosting caused by OTP waveform
  1178. display.clearScreen();
  1179. display.refresh(false); // full update
  1180. }
  1181. }
  1182. }
  1183. #endif
  1184. #ifdef _WS_Bitmaps800x600_H_
  1185. void drawBitmaps800x600()
  1186. {
  1187. #if defined(ESP8266) || defined(ESP32)
  1188. if ((display.epd2.panel == GxEPD2::ED060SCT) || (display.epd2.panel == GxEPD2::ED060KC1) || (display.epd2.panel == GxEPD2::ED078KC2))
  1189. {
  1190. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  1191. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  1192. delay(2000);
  1193. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  1194. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  1195. // delay(2000);
  1196. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  1197. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  1198. // delay(2000);
  1199. }
  1200. #endif
  1201. }
  1202. #endif
  1203. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  1204. void drawBitmaps1304x984()
  1205. {
  1206. if (display.epd2.panel == GxEPD2::GDEW1248T3)
  1207. {
  1208. display.drawImage(Bitmap1304x984, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1209. }
  1210. }
  1211. #endif
  1212. struct bitmap_pair
  1213. {
  1214. const unsigned char* black;
  1215. const unsigned char* red;
  1216. };
  1217. #ifdef _GxBitmaps3c200x200_H_
  1218. void drawBitmaps3c200x200()
  1219. {
  1220. bitmap_pair bitmap_pairs[] =
  1221. {
  1222. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  1223. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  1224. };
  1225. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  1226. {
  1227. display.firstPage();
  1228. do
  1229. {
  1230. display.fillScreen(GxEPD_WHITE);
  1231. // Bitmap3c200x200_black has 2 bits per pixel
  1232. // taken from Adafruit_GFX.cpp, modified
  1233. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  1234. uint8_t byte = 0;
  1235. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  1236. {
  1237. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  1238. {
  1239. if (i & 3) byte <<= 2;
  1240. else
  1241. {
  1242. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  1243. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  1244. #else
  1245. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  1246. #endif
  1247. }
  1248. if (!(byte & 0x80))
  1249. {
  1250. display.drawPixel(i, j, GxEPD_BLACK);
  1251. }
  1252. }
  1253. }
  1254. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1255. }
  1256. while (display.nextPage());
  1257. delay(2000);
  1258. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1259. {
  1260. display.firstPage();
  1261. do
  1262. {
  1263. display.fillScreen(GxEPD_WHITE);
  1264. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1265. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1266. }
  1267. while (display.nextPage());
  1268. delay(2000);
  1269. }
  1270. }
  1271. if (display.epd2.hasColor)
  1272. {
  1273. display.clearScreen(); // use default for white
  1274. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  1275. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  1276. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1277. {
  1278. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1279. delay(2000);
  1280. }
  1281. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1282. {
  1283. int16_t x = -60;
  1284. int16_t y = -60;
  1285. for (uint16_t j = 0; j < 10; j++)
  1286. {
  1287. display.writeScreenBuffer(); // use default for white
  1288. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1289. display.refresh();
  1290. delay(1000);
  1291. x += display.epd2.WIDTH / 4;
  1292. y += display.epd2.HEIGHT / 4;
  1293. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1294. }
  1295. }
  1296. display.writeScreenBuffer(); // use default for white
  1297. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  1298. 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);
  1299. display.refresh();
  1300. delay(2000);
  1301. }
  1302. }
  1303. #endif
  1304. #ifdef _GxBitmaps3c104x212_H_
  1305. void drawBitmaps3c104x212()
  1306. {
  1307. #if !defined(__AVR)
  1308. bitmap_pair bitmap_pairs[] =
  1309. {
  1310. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1311. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1312. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1313. };
  1314. #else
  1315. bitmap_pair bitmap_pairs[] =
  1316. {
  1317. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1318. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1319. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1320. };
  1321. #endif
  1322. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1323. {
  1324. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1325. {
  1326. display.firstPage();
  1327. do
  1328. {
  1329. display.fillScreen(GxEPD_WHITE);
  1330. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1331. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1332. {
  1333. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1334. }
  1335. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1336. }
  1337. while (display.nextPage());
  1338. delay(2000);
  1339. }
  1340. }
  1341. }
  1342. #endif
  1343. #ifdef _GxBitmaps3c128x250_H_
  1344. void drawBitmaps3c128x250()
  1345. {
  1346. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 250) && display.epd2.hasColor)
  1347. {
  1348. bool mirrored = display.mirror(true);
  1349. display.firstPage();
  1350. do
  1351. {
  1352. display.fillScreen(GxEPD_WHITE);
  1353. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_1_black, 128, 250, GxEPD_BLACK);
  1354. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_1_red, 128, 250, GxEPD_RED);
  1355. }
  1356. while (display.nextPage());
  1357. delay(2000);
  1358. #if !defined(__AVR)
  1359. display.firstPage();
  1360. do
  1361. {
  1362. display.fillScreen(GxEPD_WHITE);
  1363. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_2_black, 128, 250, GxEPD_BLACK);
  1364. display.drawBitmap(0, 0, Bitmap3c128x250_2_red, 128, 250, GxEPD_RED);
  1365. }
  1366. while (display.nextPage());
  1367. delay(2000);
  1368. #endif
  1369. display.mirror(mirrored);
  1370. }
  1371. }
  1372. #endif
  1373. #ifdef _GxBitmaps3c128x296_H_
  1374. void drawBitmaps3c128x296()
  1375. {
  1376. #if !defined(__AVR)
  1377. bitmap_pair bitmap_pairs[] =
  1378. {
  1379. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1380. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1381. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1382. };
  1383. #else
  1384. bitmap_pair bitmap_pairs[] =
  1385. {
  1386. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1387. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1388. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1389. };
  1390. #endif
  1391. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 296) && display.epd2.hasColor)
  1392. {
  1393. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1394. {
  1395. display.firstPage();
  1396. do
  1397. {
  1398. display.fillScreen(GxEPD_WHITE);
  1399. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, 128, 296, GxEPD_BLACK);
  1400. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1401. {
  1402. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 128, 296, GxEPD_RED);
  1403. }
  1404. else display.drawBitmap(0, 0, bitmap_pairs[i].red, 128, 296, GxEPD_RED);
  1405. }
  1406. while (display.nextPage());
  1407. delay(2000);
  1408. }
  1409. }
  1410. }
  1411. #endif
  1412. #ifdef _GxBitmaps3c152x296_H_
  1413. void drawBitmaps3c152x296()
  1414. {
  1415. bitmap_pair bitmap_pairs[] =
  1416. {
  1417. {Bitmap3c152x296_black, Bitmap3c152x296_red}
  1418. };
  1419. if (display.epd2.panel == GxEPD2::GDEY0266Z90)
  1420. {
  1421. bool mirrored = display.mirror(true);
  1422. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1423. {
  1424. display.firstPage();
  1425. do
  1426. {
  1427. display.fillScreen(GxEPD_WHITE);
  1428. display.drawBitmap(0, 0, bitmap_pairs[i].black, 152, 296, GxEPD_BLACK);
  1429. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 152, 296, GxEPD_RED);
  1430. }
  1431. while (display.nextPage());
  1432. delay(2000);
  1433. }
  1434. display.mirror(mirrored);
  1435. }
  1436. }
  1437. #endif
  1438. #ifdef _GxBitmaps3c176x264_H_
  1439. void drawBitmaps3c176x264()
  1440. {
  1441. bitmap_pair bitmap_pairs[] =
  1442. {
  1443. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1444. };
  1445. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1446. {
  1447. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1448. {
  1449. display.firstPage();
  1450. do
  1451. {
  1452. display.fillScreen(GxEPD_WHITE);
  1453. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1454. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1455. }
  1456. while (display.nextPage());
  1457. delay(2000);
  1458. }
  1459. }
  1460. }
  1461. #endif
  1462. #ifdef _GxBitmaps3c400x300_H_
  1463. void drawBitmaps3c400x300()
  1464. {
  1465. #if !defined(__AVR)
  1466. bitmap_pair bitmap_pairs[] =
  1467. {
  1468. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1469. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1470. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
  1471. };
  1472. #else
  1473. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1474. #endif
  1475. if (display.epd2.panel == GxEPD2::GDEW042Z15)
  1476. {
  1477. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1478. {
  1479. display.firstPage();
  1480. do
  1481. {
  1482. display.fillScreen(GxEPD_WHITE);
  1483. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1484. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1485. }
  1486. while (display.nextPage());
  1487. delay(2000);
  1488. }
  1489. }
  1490. }
  1491. #endif
  1492. #ifdef _GxBitmaps3c648x480_H_
  1493. void drawBitmaps3c648x480()
  1494. {
  1495. #if !defined(__AVR)
  1496. bitmap_pair bitmap_pairs[] =
  1497. {
  1498. {Bitmap3c648x480_black, Bitmap3c648x480_red}
  1499. };
  1500. #else
  1501. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1502. #endif
  1503. if (display.epd2.panel == GxEPD2::GDEW0583Z83)
  1504. {
  1505. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1506. {
  1507. display.firstPage();
  1508. do
  1509. {
  1510. display.fillScreen(GxEPD_WHITE);
  1511. display.drawBitmap(0, 0, bitmap_pairs[i].black, 648, 480, GxEPD_BLACK);
  1512. display.drawBitmap(0, 0, bitmap_pairs[i].red, 648, 480, GxEPD_RED);
  1513. }
  1514. while (display.nextPage());
  1515. delay(2000);
  1516. }
  1517. }
  1518. }
  1519. #endif
  1520. #ifdef _GxBitmaps3c800x480_H_
  1521. void drawBitmaps3c800x480()
  1522. {
  1523. #if !defined(__AVR)
  1524. bitmap_pair bitmap_pairs[] =
  1525. {
  1526. {Bitmap3c800x480_1_black, Bitmap3c800x480_1_red}
  1527. };
  1528. #else
  1529. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1530. #endif
  1531. if (display.epd2.panel == GxEPD2::GDEW075Z08)
  1532. {
  1533. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1534. {
  1535. display.firstPage();
  1536. do
  1537. {
  1538. display.fillScreen(GxEPD_WHITE);
  1539. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1540. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1541. }
  1542. while (display.nextPage());
  1543. delay(2000);
  1544. }
  1545. }
  1546. }
  1547. #endif
  1548. #ifdef _GxBitmaps3c880x528_H_
  1549. void drawBitmaps3c880x528()
  1550. {
  1551. #if !defined(__AVR)
  1552. bitmap_pair bitmap_pairs[] =
  1553. {
  1554. {Bitmap3c880x528_black, Bitmap3c880x528_red}
  1555. };
  1556. #else
  1557. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1558. #endif
  1559. if (display.epd2.panel == GxEPD2::GDEH075Z90)
  1560. {
  1561. bool m = display.mirror(true);
  1562. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1563. {
  1564. display.firstPage();
  1565. do
  1566. {
  1567. display.fillScreen(GxEPD_WHITE);
  1568. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, 880, 528, GxEPD_BLACK);
  1569. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 880, 528, GxEPD_RED);
  1570. }
  1571. while (display.nextPage());
  1572. delay(2000);
  1573. }
  1574. display.mirror(m);
  1575. }
  1576. }
  1577. #endif
  1578. #if defined(_WS_Bitmaps7c192x143_H_)
  1579. void drawBitmaps7c192x143()
  1580. {
  1581. if (display.epd2.panel == GxEPD2::ACeP565)
  1582. {
  1583. display.drawNative(WS_Bitmap7c192x143, 0, (display.epd2.WIDTH - 192) / 2, (display.epd2.HEIGHT - 143) / 2, 192, 143, false, false, true);
  1584. delay(5000);
  1585. }
  1586. }
  1587. #endif
  1588. void draw7colors()
  1589. {
  1590. display.setRotation(0);
  1591. uint16_t h = display.height() / 7;
  1592. display.firstPage();
  1593. do
  1594. {
  1595. display.fillRect(0, 0, display.width(), h, GxEPD_BLACK);
  1596. display.fillRect(0, h, display.width(), h, GxEPD_WHITE);
  1597. display.fillRect(0, 2 * h, display.width(), h, GxEPD_GREEN);
  1598. display.fillRect(0, 3 * h, display.width(), h, GxEPD_BLUE);
  1599. display.fillRect(0, 4 * h, display.width(), h, GxEPD_RED);
  1600. display.fillRect(0, 5 * h, display.width(), h, GxEPD_YELLOW);
  1601. display.fillRect(0, 6 * h, display.width(), h, GxEPD_ORANGE);
  1602. }
  1603. while (display.nextPage());
  1604. }
  1605. void draw7colorlines()
  1606. {
  1607. display.setRotation(0);
  1608. uint16_t h = 2;
  1609. display.firstPage();
  1610. do
  1611. {
  1612. uint16_t y = 0;
  1613. do
  1614. {
  1615. display.fillRect(0, y, display.width(), h, GxEPD_BLACK); y += h;
  1616. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1617. display.fillRect(0, y, display.width(), h, GxEPD_GREEN); y += h;
  1618. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1619. display.fillRect(0, y, display.width(), h, GxEPD_BLUE); y += h;
  1620. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1621. display.fillRect(0, y, display.width(), h, GxEPD_RED); y += h;
  1622. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1623. display.fillRect(0, y, display.width(), h, GxEPD_YELLOW); y += h;
  1624. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1625. display.fillRect(0, y, display.width(), h, GxEPD_ORANGE); y += h;
  1626. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  1627. }
  1628. while ((y + 12 * h) < uint16_t(display.height()));
  1629. //display.drawPixel(0, y, GxEPD_BLACK); display.drawPixel(10, y, GxEPD_GREEN);
  1630. //display.drawPixel(20, y, GxEPD_BLUE); display.drawPixel(30, y, GxEPD_RED);
  1631. //display.drawPixel(40, y, GxEPD_YELLOW); display.drawPixel(50, y, GxEPD_ORANGE);
  1632. display.fillRect(0, y, 2, 2, GxEPD_BLACK); display.fillRect(10, y, 2, 2, GxEPD_GREEN);
  1633. display.fillRect(20, y, 2, 2, GxEPD_BLUE); display.fillRect(30, y, 2, 2, GxEPD_RED);
  1634. display.fillRect(40, y, 2, 2, GxEPD_YELLOW); display.fillRect(50, y, 2, 2, GxEPD_ORANGE);
  1635. }
  1636. while (display.nextPage());
  1637. }