GxEPD2_Example.ino 52 KB

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