GxEPD2_Example.ino 58 KB

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