GxEPD2_Example.ino 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426
  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: https://www.good-display.com/companyfile/32/
  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 (closed, read only):
  12. // Good Display ePaper for Arduino: https://forum.arduino.cc/t/good-display-epaper-for-arduino/419657
  13. // Waveshare e-paper displays with SPI: https://forum.arduino.cc/t/waveshare-e-paper-displays-with-spi/467865
  14. //
  15. // Add new topics in https://forum.arduino.cc/c/using-arduino/displays/23 for new questions and issues
  16. // see GxEPD2_wiring_examples.h for wiring suggestions and examples
  17. // NOTE for use with Waveshare ESP32 Driver Board:
  18. // **** also need to select the constructor with the parameters for this board in GxEPD2_display_selection_new_style.h ****
  19. //
  20. // The Wavehare ESP32 Driver Board uses uncommon SPI pins for the FPC connector. It uses HSPI pins, but SCK and MOSI are swapped.
  21. // 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.
  22. // 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.
  23. // The logical configuration would be to use the e-paper connection on HSPI with re-mapped pins, and use VSPI for other SPI clients.
  24. // VSPI with standard VSPI pins is used by the global SPI instance of the Arduino IDE ESP32 package.
  25. // uncomment next line to use HSPI for EPD (and e.g VSPI for SD), e.g. with Waveshare ESP32 Driver Board
  26. //#define USE_HSPI_FOR_EPD
  27. // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
  28. // enable or disable GxEPD2_GFX base class
  29. #define ENABLE_GxEPD2_GFX 0
  30. // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
  31. //#include <GFX.h>
  32. // Note: if you use this with ENABLE_GxEPD2_GFX 1:
  33. // uncomment it in GxEPD2_GFX.h too, or add #include <GFX.h> before any #include <GxEPD2_GFX.h>
  34. #include <GxEPD2_BW.h>
  35. #include <GxEPD2_3C.h>
  36. #include <GxEPD2_4C.h>
  37. #include <GxEPD2_7C.h>
  38. #include <Fonts/FreeMonoBold9pt7b.h>
  39. #include <Fonts/FreeMonoBold12pt7b.h>
  40. #include <Fonts/FreeSansBold24pt7b.h>
  41. // select the display constructor line in one of the following files (old style):
  42. #include "GxEPD2_display_selection.h"
  43. #include "GxEPD2_display_selection_added.h"
  44. // or select the display class and display driver class in the following file (new style):
  45. #include "GxEPD2_display_selection_new_style.h"
  46. //#define WITHOUT_BITMAPS
  47. #ifndef WITHOUT_BITMAPS
  48. #if !defined(__AVR) && !defined(STM32F1xx)
  49. // note 16.11.2019: the compiler may exclude code based on constant if statements (display.epd2.panel == constant),
  50. // therefore bitmaps may get optimized out by the linker
  51. // comment out unused bitmaps to reduce code space used
  52. #include "bitmaps/Bitmaps80x128.h" // 1.02" b/w
  53. #include "bitmaps/Bitmaps152x152.h" // 1.54" b/w
  54. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  55. #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  56. #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  57. #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  58. #include "bitmaps/Bitmaps168x384.h" // 2.9" b/w
  59. #include "bitmaps/Bitmaps152x296.h" // 2.6" b/w
  60. #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  61. #include "bitmaps/Bitmaps240x360.h" // 3.1" b/w
  62. #include "bitmaps/Bitmaps240x416.h" // 3.71" b/w
  63. #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
  64. #include "bitmaps/Bitmaps648x480.h" // 5.38" b/w
  65. #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
  66. #include "bitmaps/Bitmaps800x276.h" // 5.79" b/w
  67. #include "bitmaps/Bitmaps800x480.h" // 7.5" b/w
  68. #include "bitmaps/Bitmaps960x640.h" // 10.2" b/w
  69. #include "bitmaps/Bitmaps960x680.h" // 13.3" b/w
  70. // 3-color
  71. #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  72. #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  73. #include "bitmaps/Bitmaps3c128x250.h" // 2.13" b/w/r
  74. #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  75. #include "bitmaps/Bitmaps3c152x296.h" // 2.66" b/w/r
  76. #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  77. #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
  78. #if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
  79. #include "bitmaps/Bitmaps3c800x276.h" // 5.79" b/w/r
  80. #include "bitmaps/Bitmaps3c648x480.h" // 5.83" b/w/r
  81. #include "bitmaps/Bitmaps3c800x480.h" // 7.5" b/w/r
  82. #include "bitmaps/Bitmaps3c880x528.h" // 7.5" b/w/r
  83. #include "bitmaps/Bitmaps3c960x640.h" // 11.6" b/w/r
  84. #include "bitmaps/Bitmaps3c960x680.h" // 13.3" b/w/r
  85. #include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
  86. // 4-color
  87. #include "bitmaps/Bitmaps4c200x200.h" // 1.54" 4-color
  88. #include "bitmaps/Bitmaps4c128x250.h" // 2.13" 4-color
  89. #include "bitmaps/Bitmaps4c184x360.h" // 2.66" 4-color
  90. #include "bitmaps/Bitmaps4c168x384.h" // 2.9" 4-color
  91. #include "bitmaps/WS_Bitmaps4c168x168.h" // 4.37" 4-color
  92. #include "bitmaps/WS_Bitmaps4c168x400.h" // 3.00" 4-color
  93. #include "bitmaps/Bitmaps4c184x384.h" // 3.5" 4-color
  94. #include "bitmaps/Bitmaps4c800x480.h" // 3.97" 4-color
  95. #include "bitmaps/Bitmaps4c400x300.h" // 4.2" 4-color
  96. #include "bitmaps/Bitmaps4c792x272.h" // 5.79" 4-color
  97. #include "bitmaps/Bitmaps4c960x640.h" // 11.6" 4-color
  98. // 7-color
  99. #include "bitmaps/Bitmaps7c600x448.h" // 5.65" 7-color
  100. #include "bitmaps/WS_Bitmaps7c192x143.h" // 5.65" 7-color
  101. #include "bitmaps/WS_Bitmaps7c300x180.h" // 7.3" 7-color
  102. #endif
  103. #if defined(ESP32) || defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_RP2040)
  104. #include "bitmaps/Bitmaps1304x984.h" // 12.48" b/w
  105. #include "bitmaps/Bitmaps1360x480.h" // 10.85" b/w
  106. #include "bitmaps/Bitmaps3c1304x984.h" // 12.48" b/w/r
  107. #include "bitmaps/Bitmaps7c800x480.h" // 7.3" 7-color
  108. #endif
  109. #else
  110. // select only one to fit in code space
  111. //#include "bitmaps/Bitmaps80x128.h" // 1.02" b/w
  112. #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
  113. //#include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
  114. //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
  115. //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
  116. #include "bitmaps/Bitmaps168x384.h" // 2.9" b/w
  117. //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
  118. ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
  119. ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
  120. ////#include "bitmaps/Bitmaps800x480.h" // 7.5" b/w // not enough code space
  121. // 3-color
  122. //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
  123. //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
  124. #include "bitmaps/Bitmaps3c128x250.h" // 2.13" b/w/r
  125. //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
  126. //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
  127. ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
  128. #endif
  129. #endif
  130. #if defined(ARDUINO_ARCH_RP2040) && (defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W))
  131. #if defined(__MBED__)
  132. // SPI pins used by GoodDisplay DESPI-PICO. note: steals standard I2C pins PIN_WIRE_SDA (6), PIN_WIRE_SCL (7)
  133. // uncomment next line for use with GoodDisplay DESPI-PICO. // MbedSPI(int miso, int mosi, int sck);
  134. arduino::MbedSPI SPIn(4, 7, 6); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  135. // uncomment next line for use with my proto board. // MbedSPI(int miso, int mosi, int sck);
  136. //arduino::MbedSPI SPIn(4, 3, 2); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  137. // uncomment next line for use with Waveshare Pico-ePaper-2.9. // MbedSPI(int miso, int mosi, int sck);
  138. // note: doesn't work with Waveshare PhotoPainter, conflict on pin 12. use philhower package instead.
  139. //arduino::MbedSPI SPIn(12, 11, 10); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  140. #else // package https://github.com/earlephilhower/arduino-pico
  141. // SPIClassRP2040(spi_inst_t *spi, pin_size_t rx, pin_size_t cs, pin_size_t sck, pin_size_t tx);
  142. // uncomment next line for use with my proto board.
  143. //SPIClassRP2040 SPIn(spi0, 4, 5, 2, 3); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  144. // uncomment next line for use with Waveshare Pico-ePaper-2.9 or Waveshare PhotoPainter module
  145. SPIClassRP2040 SPIn(spi1, 12, 13, 10, 11); // need be valid pins for same SPI channel, else fails blinking 4 long 4 short
  146. #endif
  147. #endif
  148. #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  149. SPIClass hspi(HSPI);
  150. #endif
  151. void setup()
  152. {
  153. Serial.begin(115200);
  154. //delay(5000);
  155. Serial.println();
  156. Serial.println("setup");
  157. delay(100);
  158. #if defined(ARDUINO_ARCH_RP2040) && (defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W))
  159. // uncomment next line for use with GoodDisplay DESPI-PICO or my proto board, or Waveshare RPi boards
  160. display.epd2.selectSPI(SPIn, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  161. // uncomment next 2 lines to allow recovery from configuration failures
  162. pinMode(15, INPUT_PULLUP); // safety pin
  163. while (!digitalRead(15)) delay(100); // check safety pin for fail recovery
  164. // recovery can be done also by holding BOOTSEL during power-up.
  165. // uncomment next line for Waveshare PhotoPainter module
  166. pinMode(16, OUTPUT); digitalWrite(16, HIGH); // power to the paper
  167. #endif
  168. #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  169. hspi.begin(13, 12, 14, 15); // remap hspi for EPD (swap pins)
  170. display.epd2.selectSPI(hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  171. #elif (defined(ARDUINO_ARCH_ESP32) && defined(ARDUINO_LOLIN_S2_MINI))
  172. // SPI.begin(sck, miso, mosi, ss); // preset for remapped pins
  173. SPI.begin(18, -1, 16, 33); // my LOLIN ESP32 S2 mini connection
  174. #endif
  175. #if defined(ESP32) && defined(ARDUINO_ESP32S3_DEV) && true // CrowPanel
  176. pinMode(7, OUTPUT);
  177. digitalWrite(7, HIGH); // enable power to the panel
  178. #endif
  179. //display.init(115200); // default 10ms reset pulse, e.g. for bare panels with DESPI-C02
  180. display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
  181. //display.init(115200, true, 10, false, SPIn, SPISettings(4000000, MSBFIRST, SPI_MODE0)); // extended init method with SPI channel and/or settings selection
  182. if (display.pages() > 1)
  183. {
  184. delay(100);
  185. Serial.print("pages = "); Serial.print(display.pages()); Serial.print(" page height = "); Serial.println(display.pageHeight());
  186. delay(1000);
  187. }
  188. //display.clearScreen(); return;
  189. // first update should be full refresh
  190. helloWorld();
  191. delay(1000);
  192. // partial refresh mode can be used to full screen,
  193. // effective if display panel hasFastPartialUpdate
  194. helloFullScreenPartialMode();
  195. delay(1000);
  196. //stripeTest(); return; // GDEH029Z13 issue
  197. helloArduino();
  198. delay(1000);
  199. helloEpaper();
  200. delay(1000);
  201. //helloValue(123.9, 1);
  202. //delay(1000);
  203. showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
  204. //showFont("FreeMonoBold12pt7b", &FreeMonoBold12pt7b);
  205. delay(1000);
  206. if (display.epd2.WIDTH < 104)
  207. {
  208. showFont("glcdfont", 0);
  209. delay(1000);
  210. }
  211. //drawGrid(); return;
  212. //drawCornerTest(); return;
  213. display.writeScreenBuffer();
  214. drawBitmaps();
  215. //display.powerOff(); return;
  216. drawGraphics();
  217. if ((display.epd2.panel == GxEPD2::GDEM035F51) || (display.epd2.panel == GxEPD2::GDEM0397F81))
  218. {
  219. draw4colors();
  220. delay(4000);
  221. }
  222. //display.powerOff(); return;
  223. #if !defined(__AVR) // takes too long!
  224. if ((display.epd2.panel == GxEPD2::ACeP565) || (display.epd2.panel == GxEPD2::GDEY073D46) || (display.epd2.panel == GxEPD2::ACeP730) ||
  225. (display.epd2.panel == GxEPD2::GDEP0565D90) || (display.epd2.panel == GxEPD2::GDEP073E01))
  226. {
  227. //draw7colorlines();
  228. //delay(2000);
  229. draw7colors();
  230. delay(4000);
  231. display.epd2.drawNativeColors(); delay(2000);
  232. //return;
  233. }
  234. #endif
  235. if (display.epd2.hasPartialUpdate)
  236. {
  237. showPartialUpdate();
  238. delay(1000);
  239. } // else // on GDEW0154Z04 only full update available, doesn't look nice
  240. //drawCornerTest();
  241. //showBox(16, 16, 48, 32, false);
  242. //showBox(16, 56, 48, 32, true);
  243. display.powerOff();
  244. deepSleepTest();
  245. //deepSleepTestPartialUpdate();
  246. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  247. drawBitmaps1304x984();
  248. display.powerOff();
  249. #endif
  250. Serial.println("setup done");
  251. display.end();
  252. }
  253. void loop()
  254. {
  255. }
  256. // note for partial update window and setPartialWindow() method:
  257. // partial update window size and position is on byte boundary in physical x direction
  258. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  259. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  260. const char HelloWorld[] = "Hello World!";
  261. const char HelloArduino[] = "Hello Arduino!";
  262. const char HelloEpaper[] = "Hello E-Paper!";
  263. void helloWorld()
  264. {
  265. //Serial.println("helloWorld");
  266. display.setRotation(1);
  267. display.setFont(&FreeMonoBold9pt7b);
  268. if (display.epd2.WIDTH < 104) display.setFont(0);
  269. display.setTextColor(GxEPD_BLACK);
  270. int16_t tbx, tby; uint16_t tbw, tbh;
  271. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  272. // center bounding box by transposition of origin:
  273. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  274. uint16_t y = ((display.height() - tbh) / 2) - tby;
  275. display.setFullWindow();
  276. display.firstPage();
  277. do
  278. {
  279. display.fillScreen(GxEPD_WHITE);
  280. display.setCursor(x, y);
  281. display.print(HelloWorld);
  282. }
  283. while (display.nextPage());
  284. //Serial.println("helloWorld done");
  285. }
  286. void helloWorldForDummies()
  287. {
  288. //Serial.println("helloWorld");
  289. const char text[] = "Hello World!";
  290. // most e-papers have width < height (portrait) as native orientation, especially the small ones
  291. // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
  292. // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
  293. display.setRotation(1);
  294. // select a suitable font in Adafruit_GFX
  295. display.setFont(&FreeMonoBold9pt7b);
  296. // on e-papers black on white is more pleasant to read
  297. display.setTextColor(GxEPD_BLACK);
  298. // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
  299. int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
  300. display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
  301. // center bounding box by transposition of origin:
  302. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  303. uint16_t y = ((display.height() - tbh) / 2) - tby;
  304. // full window mode is the initial mode, set it anyway
  305. display.setFullWindow();
  306. // here we use paged drawing, even if the processor has enough RAM for full buffer
  307. // so this can be used with any supported processor board.
  308. // the cost in code overhead and execution time penalty is marginal
  309. // tell the graphics class to use paged drawing mode
  310. display.firstPage();
  311. do
  312. {
  313. // this part of code is executed multiple times, as many as needed,
  314. // in case of full buffer it is executed once
  315. // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
  316. // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
  317. display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
  318. display.setCursor(x, y); // set the postition to start printing text
  319. display.print(text); // print some text
  320. // end of part executed multiple times
  321. }
  322. // tell the graphics class to transfer the buffer content (page) to the controller buffer
  323. // the graphics class will command the controller to refresh to the screen when the last page has been transferred
  324. // returns true if more pages need be drawn and transferred
  325. // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
  326. // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
  327. // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
  328. while (display.nextPage());
  329. //Serial.println("helloWorld done");
  330. }
  331. void helloFullScreenPartialMode()
  332. {
  333. //Serial.println("helloFullScreenPartialMode");
  334. const char fullscreen[] = "full screen update";
  335. const char fpm[] = "fast partial mode";
  336. const char spm[] = "slow partial mode";
  337. const char npm[] = "no partial mode";
  338. display.setPartialWindow(0, 0, display.width(), display.height());
  339. display.setRotation(1);
  340. display.setFont(&FreeMonoBold9pt7b);
  341. if (display.epd2.WIDTH < 104) display.setFont(0);
  342. display.setTextColor(GxEPD_BLACK);
  343. const char* updatemode;
  344. if (display.epd2.hasFastPartialUpdate)
  345. {
  346. updatemode = fpm;
  347. }
  348. else if (display.epd2.hasPartialUpdate)
  349. {
  350. updatemode = spm;
  351. }
  352. else
  353. {
  354. updatemode = npm;
  355. }
  356. // do this outside of the loop
  357. int16_t tbx, tby; uint16_t tbw, tbh;
  358. // center update text
  359. display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
  360. uint16_t utx = ((display.width() - tbw) / 2) - tbx;
  361. uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
  362. // center update mode
  363. display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
  364. uint16_t umx = ((display.width() - tbw) / 2) - tbx;
  365. uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
  366. // center HelloWorld
  367. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  368. uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
  369. uint16_t hwy = ((display.height() - tbh) / 2) - tby;
  370. display.firstPage();
  371. do
  372. {
  373. display.fillScreen(GxEPD_WHITE);
  374. display.setCursor(hwx, hwy);
  375. display.print(HelloWorld);
  376. display.setCursor(utx, uty);
  377. display.print(fullscreen);
  378. display.setCursor(umx, umy);
  379. display.print(updatemode);
  380. }
  381. while (display.nextPage());
  382. //Serial.println("helloFullScreenPartialMode done");
  383. }
  384. void helloArduino()
  385. {
  386. //Serial.println("helloArduino");
  387. display.setRotation(1);
  388. display.setFont(&FreeMonoBold9pt7b);
  389. if (display.epd2.WIDTH < 104) display.setFont(0);
  390. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  391. int16_t tbx, tby; uint16_t tbw, tbh;
  392. // align with centered HelloWorld
  393. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  394. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  395. // height might be different
  396. display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
  397. uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
  398. // make the window big enough to cover (overwrite) descenders of previous text
  399. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  400. uint16_t wy = (display.height() / 4) - wh / 2;
  401. display.setPartialWindow(0, wy, display.width(), wh);
  402. display.firstPage();
  403. do
  404. {
  405. display.fillScreen(GxEPD_WHITE);
  406. //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
  407. display.setCursor(x, y);
  408. display.print(HelloArduino);
  409. }
  410. while (display.nextPage());
  411. delay(1000);
  412. //Serial.println("helloArduino done");
  413. }
  414. void helloEpaper()
  415. {
  416. //Serial.println("helloEpaper");
  417. display.setRotation(1);
  418. display.setFont(&FreeMonoBold9pt7b);
  419. if (display.epd2.WIDTH < 104) display.setFont(0);
  420. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  421. int16_t tbx, tby; uint16_t tbw, tbh;
  422. // align with centered HelloWorld
  423. display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  424. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  425. // height might be different
  426. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  427. uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
  428. // make the window big enough to cover (overwrite) descenders of previous text
  429. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  430. uint16_t wy = (display.height() * 3 / 4) - wh / 2;
  431. display.setPartialWindow(0, wy, display.width(), wh);
  432. display.firstPage();
  433. do
  434. {
  435. display.fillScreen(GxEPD_WHITE);
  436. display.setCursor(x, y);
  437. display.print(HelloEpaper);
  438. }
  439. while (display.nextPage());
  440. //Serial.println("helloEpaper done");
  441. }
  442. // test partial window issue on GDEW0213Z19 and GDEH029Z13
  443. void stripeTest()
  444. {
  445. helloStripe(104);
  446. delay(2000);
  447. helloStripe(96);
  448. }
  449. const char HelloStripe[] = "Hello Stripe!";
  450. void helloStripe(uint16_t pw_xe) // end of partial window in physcal x direction
  451. {
  452. //Serial.print("HelloStripe("); Serial.print(pw_xe); Serial.println(")");
  453. display.setRotation(3);
  454. display.setFont(&FreeMonoBold9pt7b);
  455. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  456. int16_t tbx, tby; uint16_t tbw, tbh;
  457. display.getTextBounds(HelloStripe, 0, 0, &tbx, &tby, &tbw, &tbh);
  458. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  459. uint16_t wy = pw_xe - wh;
  460. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  461. uint16_t y = wy - tby;
  462. display.setPartialWindow(0, wy, display.width(), wh);
  463. display.firstPage();
  464. do
  465. {
  466. display.fillScreen(GxEPD_WHITE);
  467. display.setCursor(x, y);
  468. display.print(HelloStripe);
  469. }
  470. while (display.nextPage());
  471. //Serial.println("HelloStripe done");
  472. }
  473. #if defined(ESP8266) || defined(ESP32)
  474. #include <StreamString.h>
  475. #define PrintString StreamString
  476. #else
  477. class PrintString : public Print, public String
  478. {
  479. public:
  480. size_t write(uint8_t data) override
  481. {
  482. return concat(char(data));
  483. };
  484. };
  485. #endif
  486. void helloValue(double v, int digits)
  487. {
  488. //Serial.println("helloValue");
  489. display.setRotation(1);
  490. display.setFont(&FreeMonoBold9pt7b);
  491. display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
  492. PrintString valueString;
  493. valueString.print(v, digits);
  494. int16_t tbx, tby; uint16_t tbw, tbh;
  495. display.getTextBounds(valueString, 0, 0, &tbx, &tby, &tbw, &tbh);
  496. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  497. uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
  498. // show what happens, if we use the bounding box for partial window
  499. uint16_t wx = (display.width() - tbw) / 2;
  500. uint16_t wy = ((display.height() * 3 / 4) - tbh / 2);
  501. display.setPartialWindow(wx, wy, tbw, tbh);
  502. display.firstPage();
  503. do
  504. {
  505. display.fillScreen(GxEPD_WHITE);
  506. display.setCursor(x, y);
  507. display.print(valueString);
  508. }
  509. while (display.nextPage());
  510. delay(2000);
  511. // make the partial window big enough to cover the previous text
  512. uint16_t ww = tbw; // remember window width
  513. display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
  514. // adjust, because HelloEpaper was aligned, not centered (could calculate this to be precise)
  515. ww = max(ww, uint16_t(tbw + 12)); // 12 seems ok
  516. wx = (display.width() - tbw) / 2;
  517. // make the window big enough to cover (overwrite) descenders of previous text
  518. uint16_t wh = FreeMonoBold9pt7b.yAdvance;
  519. wy = (display.height() * 3 / 4) - wh / 2;
  520. display.setPartialWindow(wx, wy, ww, wh);
  521. // alternately use the whole width for partial window
  522. //display.setPartialWindow(0, wy, display.width(), wh);
  523. display.firstPage();
  524. do
  525. {
  526. display.fillScreen(GxEPD_WHITE);
  527. display.setCursor(x, y);
  528. display.print(valueString);
  529. }
  530. while (display.nextPage());
  531. //Serial.println("helloValue done");
  532. }
  533. void deepSleepTest()
  534. {
  535. //Serial.println("deepSleepTest");
  536. const char hibernating[] = "hibernating ...";
  537. const char wokeup[] = "woke up";
  538. const char from[] = "from deep sleep";
  539. const char again[] = "again";
  540. display.setRotation(1);
  541. display.setFont(&FreeMonoBold9pt7b);
  542. if (display.epd2.WIDTH < 104) display.setFont(0);
  543. display.setTextColor(GxEPD_BLACK);
  544. int16_t tbx, tby; uint16_t tbw, tbh;
  545. // center text
  546. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  547. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  548. uint16_t y = ((display.height() - tbh) / 2) - tby;
  549. display.setFullWindow();
  550. display.firstPage();
  551. do
  552. {
  553. display.fillScreen(GxEPD_WHITE);
  554. display.setCursor(x, y);
  555. display.print(hibernating);
  556. }
  557. while (display.nextPage());
  558. display.hibernate();
  559. delay(5000);
  560. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  561. uint16_t wx = (display.width() - tbw) / 2;
  562. uint16_t wy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  563. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  564. uint16_t fx = (display.width() - tbw) / 2;
  565. uint16_t fy = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  566. display.firstPage();
  567. do
  568. {
  569. display.fillScreen(GxEPD_WHITE);
  570. display.setCursor(wx, wy);
  571. display.print(wokeup);
  572. display.setCursor(fx, fy);
  573. display.print(from);
  574. }
  575. while (display.nextPage());
  576. delay(5000);
  577. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  578. uint16_t hx = (display.width() - tbw) / 2;
  579. uint16_t hy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  580. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  581. uint16_t ax = (display.width() - tbw) / 2;
  582. uint16_t ay = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  583. display.firstPage();
  584. do
  585. {
  586. display.fillScreen(GxEPD_WHITE);
  587. display.setCursor(hx, hy);
  588. display.print(hibernating);
  589. display.setCursor(ax, ay);
  590. display.print(again);
  591. }
  592. while (display.nextPage());
  593. display.hibernate();
  594. //Serial.println("deepSleepTest done");
  595. }
  596. void deepSleepTestPartialUpdate()
  597. {
  598. if (display.epd2.panel != GxEPD2::GDEY075T7) return; // so far only implemented for GxEPD2_750_GDEY075T7
  599. //Serial.println("deepSleepTestPartialUpdate");
  600. const char hibernating[] = "hibernating ...";
  601. const char wokeup[] = "woke up";
  602. const char from[] = "from deep sleep";
  603. const char again[] = "again";
  604. display.setRotation(1);
  605. display.setFont(&FreeSansBold24pt7b);
  606. if (display.epd2.WIDTH < 104) display.setFont(0);
  607. display.setTextColor(GxEPD_BLACK);
  608. int16_t tbx, tby; uint16_t tbw, tbh;
  609. // center text
  610. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  611. uint16_t x = ((display.width() - tbw) / 2) - tbx;
  612. uint16_t y = ((display.height() - tbh) / 2) - tby;
  613. display.setFullWindow();
  614. display.firstPage();
  615. do
  616. {
  617. display.fillScreen(GxEPD_WHITE);
  618. display.setCursor(x, y);
  619. display.print(hibernating);
  620. }
  621. while (display.nextPage());
  622. display.hibernate();
  623. delay(10000);
  624. // Restore previous buffer
  625. // so far only implemented for GxEPD2_750_GDEY075T7
  626. display.firstPage();
  627. do
  628. {
  629. display.fillScreen(GxEPD_WHITE);
  630. display.setCursor(x, y);
  631. display.print(hibernating);
  632. }
  633. while (display.nextPageToPrevious());
  634. display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
  635. uint16_t wx = (display.width() - tbw) / 2;
  636. uint16_t wy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  637. display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
  638. uint16_t fx = (display.width() - tbw) / 2;
  639. uint16_t fy = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  640. display.setPartialWindow(0, 0, display.width(), display.height());
  641. display.firstPage();
  642. do
  643. {
  644. display.fillScreen(GxEPD_WHITE);
  645. display.setCursor(wx, wy);
  646. display.print(wokeup);
  647. display.setCursor(fx, fy);
  648. display.print(from);
  649. }
  650. while (display.nextPage());
  651. delay(5000);
  652. display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
  653. uint16_t hx = (display.width() - tbw) / 2;
  654. uint16_t hy = ((display.height() / 3) - tbh / 2) - tby; // y is base line!
  655. display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
  656. uint16_t ax = (display.width() - tbw) / 2;
  657. uint16_t ay = ((display.height() * 2 / 3) - tbh / 2) - tby; // y is base line!
  658. display.firstPage();
  659. do
  660. {
  661. display.fillScreen(GxEPD_WHITE);
  662. display.setCursor(hx, hy);
  663. display.print(hibernating);
  664. display.setCursor(ax, ay);
  665. display.print(again);
  666. }
  667. while (display.nextPage());
  668. display.hibernate();
  669. //Serial.println("deepSleepTestPartialUpdate done");
  670. }
  671. void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
  672. {
  673. //Serial.println("showBox");
  674. display.setRotation(1);
  675. if (partial)
  676. {
  677. display.setPartialWindow(x, y, w, h);
  678. }
  679. else
  680. {
  681. display.setFullWindow();
  682. }
  683. display.firstPage();
  684. do
  685. {
  686. display.fillScreen(GxEPD_WHITE);
  687. display.fillRect(x, y, w, h, GxEPD_BLACK);
  688. }
  689. while (display.nextPage());
  690. //Serial.println("showBox done");
  691. }
  692. void drawCornerTest()
  693. {
  694. display.setFullWindow();
  695. display.setFont(&FreeMonoBold9pt7b);
  696. display.setTextColor(GxEPD_BLACK);
  697. for (uint16_t r = 0; r <= 4; r++)
  698. {
  699. display.setRotation(r);
  700. display.firstPage();
  701. do
  702. {
  703. display.fillScreen(GxEPD_WHITE);
  704. display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
  705. display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
  706. display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
  707. display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
  708. display.setCursor(display.width() / 2, display.height() / 2);
  709. display.print(display.getRotation());
  710. }
  711. while (display.nextPage());
  712. delay(2000);
  713. }
  714. }
  715. void showFont(const char name[], const GFXfont* f)
  716. {
  717. display.setFullWindow();
  718. display.setRotation(0);
  719. display.setTextColor(GxEPD_BLACK);
  720. display.firstPage();
  721. do
  722. {
  723. drawFont(name, f);
  724. }
  725. while (display.nextPage());
  726. }
  727. void drawFont(const char name[], const GFXfont* f)
  728. {
  729. //display.setRotation(0);
  730. display.fillScreen(GxEPD_WHITE);
  731. display.setTextColor(GxEPD_BLACK);
  732. display.setFont(f);
  733. display.setCursor(0, 0);
  734. display.println();
  735. display.println(name);
  736. display.println(" !\"#$%&'()*+,-./");
  737. display.println("0123456789:;<=>?");
  738. display.println("@ABCDEFGHIJKLMNO");
  739. display.println("PQRSTUVWXYZ[\\]^_");
  740. if (display.epd2.hasColor)
  741. {
  742. display.setTextColor(GxEPD_RED);
  743. }
  744. display.println("`abcdefghijklmno");
  745. display.println("pqrstuvwxyz{|}~ ");
  746. }
  747. // note for partial update window and setPartialWindow() method:
  748. // partial update window size and position is on byte boundary in physical x direction
  749. // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
  750. // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
  751. // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
  752. void showPartialUpdate()
  753. {
  754. // some useful background
  755. helloWorld();
  756. // use asymmetric values for test
  757. uint16_t box_x = 10;
  758. uint16_t box_y = 15;
  759. uint16_t box_w = 70;
  760. uint16_t box_h = 20;
  761. uint16_t cursor_y = box_y + box_h - 6;
  762. if (display.epd2.WIDTH < 104) cursor_y = box_y + 6;
  763. float value = 13.95;
  764. uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
  765. display.setFont(&FreeMonoBold9pt7b);
  766. if (display.epd2.WIDTH < 104) display.setFont(0);
  767. display.setTextColor(GxEPD_BLACK);
  768. // show where the update box is
  769. for (uint16_t r = 0; r < 4; r++)
  770. {
  771. display.setRotation(r);
  772. display.setPartialWindow(box_x, box_y, box_w, box_h);
  773. display.firstPage();
  774. do
  775. {
  776. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
  777. //display.fillScreen(GxEPD_BLACK);
  778. }
  779. while (display.nextPage());
  780. delay(2000);
  781. display.firstPage();
  782. do
  783. {
  784. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  785. }
  786. while (display.nextPage());
  787. delay(1000);
  788. }
  789. //return;
  790. // show updates in the update box
  791. for (uint16_t r = 0; r < 4; r++)
  792. {
  793. display.setRotation(r);
  794. display.setPartialWindow(box_x, box_y, box_w, box_h);
  795. for (uint16_t i = 1; i <= 10; i += incr)
  796. {
  797. display.firstPage();
  798. do
  799. {
  800. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  801. display.setCursor(box_x, cursor_y);
  802. display.print(value * i, 2);
  803. }
  804. while (display.nextPage());
  805. delay(500);
  806. }
  807. delay(1000);
  808. display.firstPage();
  809. do
  810. {
  811. display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  812. }
  813. while (display.nextPage());
  814. delay(1000);
  815. }
  816. }
  817. void drawGrid()
  818. {
  819. int16_t x, y;
  820. display.firstPage();
  821. do
  822. {
  823. x = 0;
  824. do
  825. {
  826. display.drawLine(x, 0, x, display.height() - 1, GxEPD_BLACK);
  827. x += 10;
  828. }
  829. while (x < display.width());
  830. y = 0;
  831. do
  832. {
  833. display.drawLine(0, y, display.width() - 1, y, GxEPD_BLACK);
  834. y += 10;
  835. }
  836. while (y < display.height());
  837. x = 0;
  838. do
  839. {
  840. display.fillCircle(x, display.height() / 2, 3, GxEPD_BLACK);
  841. x += 50;
  842. }
  843. while (x <= display.width());
  844. y = 0;
  845. do
  846. {
  847. display.fillCircle(display.width() / 2, y, 3, GxEPD_BLACK);
  848. y += 50;
  849. }
  850. while (y <= display.height());
  851. }
  852. while (display.nextPage());
  853. }
  854. void drawBitmaps()
  855. {
  856. display.setRotation(0);
  857. display.setFullWindow();
  858. #ifdef _GxBitmaps80x128_H_
  859. drawBitmaps80x128();
  860. #endif
  861. #ifdef _GxBitmaps152x152_H_
  862. drawBitmaps152x152();
  863. #endif
  864. #ifdef _GxBitmaps104x212_H_
  865. drawBitmaps104x212();
  866. #endif
  867. #ifdef _GxBitmaps200x200_H_
  868. drawBitmaps200x200();
  869. #endif
  870. #ifdef _GxBitmaps128x250_H_
  871. drawBitmaps128x250();
  872. #endif
  873. #ifdef _GxBitmaps128x296_H_
  874. drawBitmaps128x296();
  875. #endif
  876. #ifdef _GxBitmaps168x384_H_
  877. drawBitmaps168x384();
  878. #endif
  879. #ifdef _GxBitmaps152x296_H_
  880. drawBitmaps152x296();
  881. #endif
  882. #ifdef _GxBitmaps240x320_H_
  883. drawBitmaps240x320();
  884. #endif
  885. #ifdef _GxBitmaps176x264_H_
  886. drawBitmaps176x264();
  887. #endif
  888. #ifdef _GxBitmaps240x416_H_
  889. drawBitmaps240x416();
  890. #endif
  891. #ifdef _GxBitmaps400x300_H_
  892. drawBitmaps400x300();
  893. #endif
  894. #ifdef _GxBitmaps640x384_H_
  895. drawBitmaps640x384();
  896. #endif
  897. #ifdef _GxBitmaps648x480_H_
  898. drawBitmaps648x480();
  899. #endif
  900. #if defined(ESP32) && defined(_GxBitmaps800x276_H_)
  901. drawBitmaps800x276();
  902. #endif
  903. #ifdef _GxBitmaps800x480_H_
  904. drawBitmaps800x480();
  905. #endif
  906. #ifdef _WS_Bitmaps800x600_H_
  907. drawBitmaps800x600();
  908. #endif
  909. #if defined(ESP32) && defined(_GxBitmaps960x640_H_)
  910. drawBitmaps960x640();
  911. #endif
  912. #if defined(ESP32) && defined(_GxBitmaps960x680_H_)
  913. drawBitmaps960x680();
  914. #endif
  915. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  916. drawBitmaps1304x984();
  917. #endif
  918. // 3-color
  919. #ifdef _GxBitmaps3c104x212_H_
  920. drawBitmaps3c104x212();
  921. #endif
  922. #ifdef _GxBitmaps3c200x200_H_
  923. drawBitmaps3c200x200();
  924. #endif
  925. #ifdef _GxBitmaps3c128x250_H_
  926. drawBitmaps3c128x250();
  927. #endif
  928. #ifdef _GxBitmaps3c128x296_H_
  929. drawBitmaps3c128x296();
  930. #endif
  931. #ifdef _GxBitmaps3c152x296_H_
  932. drawBitmaps3c152x296();
  933. #endif
  934. #ifdef _GxBitmaps3c176x264_H_
  935. drawBitmaps3c176x264();
  936. #endif
  937. #ifdef _GxBitmaps3c400x300_H_
  938. drawBitmaps3c400x300();
  939. #endif
  940. #ifdef _GxBitmaps3c648x480_H_
  941. drawBitmaps3c648x480();
  942. #endif
  943. #ifdef _GxBitmaps3c800x480_H_
  944. drawBitmaps3c800x480();
  945. #endif
  946. #ifdef _GxBitmaps3c880x528_H_
  947. drawBitmaps3c880x528();
  948. #endif
  949. #if defined(ESP32) && defined(_GxBitmaps3c960x640_H_)
  950. drawBitmaps3c960x640();
  951. #endif
  952. #if defined(ESP32) && defined(_GxBitmaps3c960x680_H_)
  953. drawBitmaps3c960x680();
  954. #endif
  955. #if defined(ESP32) && defined(_GxBitmaps1360x480_H_)
  956. drawBitmaps1360x480();
  957. #endif
  958. // 3-color
  959. #if defined(ESP32) && defined(_GxBitmaps3c800x276_H_)
  960. drawBitmaps3c800x276();
  961. #endif
  962. // 4-color
  963. #if defined(_GxBitmaps4c200x200_H_)
  964. drawBitmaps4c200x200();
  965. #endif
  966. #if defined(_GxBitmaps4c128x250_H_)
  967. drawBitmaps4c128x250();
  968. #endif
  969. #if defined(_WS_Bitmaps4c168x168_H_)
  970. drawBitmaps4c168x168();
  971. #endif
  972. #if defined(_GxBitmaps4c168x384_H_)
  973. drawBitmaps4c168x384();
  974. #endif
  975. #if defined(_GxBitmaps4c184x360_H_)
  976. drawBitmaps4c184x360();
  977. #endif
  978. #if defined(_GxBitmaps4c184x384_H_)
  979. drawBitmaps4c184x384();
  980. #endif
  981. #if defined(_GxBitmaps4c400x300_H_)
  982. drawBitmaps4c400x300();
  983. #endif
  984. #if defined(_GxBitmaps4c800x480_H_)
  985. drawBitmaps4c800x480();
  986. #endif
  987. #if defined(_GxBitmaps4c960x640_H_)
  988. drawBitmaps4c960x640();
  989. #endif
  990. #if defined(ESP32) && defined(_GxBitmaps4c792x272_H_)
  991. drawBitmaps4c792x272();
  992. #endif
  993. // 7-color
  994. #if defined(_GxBitmaps7c600x448_H_)
  995. drawBitmaps7c600x448();
  996. #endif
  997. #if defined(_WS_Bitmaps7c192x143_H_)
  998. drawBitmaps7c192x143();
  999. #endif
  1000. #if defined(_GxBitmaps7c800x480_H_)
  1001. drawBitmaps7c800x480();
  1002. #endif
  1003. #if defined(_WS_Bitmaps7c300x180_H_)
  1004. drawBitmaps7c300x180();
  1005. #endif
  1006. #if defined(ESP32) && defined(_GxBitmaps3c1304x984_H_)
  1007. drawBitmaps3c1304x984();
  1008. #endif
  1009. }
  1010. #ifdef _GxBitmaps80x128_H_
  1011. void drawBitmaps80x128()
  1012. {
  1013. #if !defined(__AVR)
  1014. const unsigned char* bitmaps[] =
  1015. {
  1016. Bitmap80x128_1, Bitmap80x128_2, Bitmap80x128_3, Bitmap80x128_4, Bitmap80x128_5
  1017. };
  1018. #else
  1019. const unsigned char* bitmaps[] =
  1020. {
  1021. Bitmap80x128_1, Bitmap80x128_2, Bitmap80x128_3, Bitmap80x128_4, Bitmap80x128_5
  1022. };
  1023. #endif
  1024. if ((display.epd2.WIDTH == 80) && (display.epd2.HEIGHT == 128))
  1025. {
  1026. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1027. {
  1028. display.firstPage();
  1029. do
  1030. {
  1031. display.fillScreen(GxEPD_WHITE);
  1032. display.drawInvertedBitmap(0, 0, bitmaps[i], 80, 128, GxEPD_BLACK);
  1033. }
  1034. while (display.nextPage());
  1035. delay(2000);
  1036. }
  1037. display.firstPage();
  1038. do
  1039. {
  1040. display.fillScreen(GxEPD_WHITE);
  1041. display.drawBitmap(0, 0, WS_Bitmap80x128, 80, 128, GxEPD_BLACK);
  1042. }
  1043. while (display.nextPage());
  1044. delay(2000);
  1045. }
  1046. }
  1047. #endif
  1048. #ifdef _GxBitmaps152x152_H_
  1049. void drawBitmaps152x152()
  1050. {
  1051. #if !defined(__AVR)
  1052. const unsigned char* bitmaps[] =
  1053. {
  1054. Bitmap152x152_1, Bitmap152x152_2, Bitmap152x152_3
  1055. };
  1056. #else
  1057. const unsigned char* bitmaps[] =
  1058. {
  1059. Bitmap152x152_1, Bitmap152x152_2, Bitmap152x152_3
  1060. };
  1061. #endif
  1062. if ((display.epd2.WIDTH == 152) && (display.epd2.HEIGHT == 152))
  1063. {
  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], 152, 152, GxEPD_BLACK);
  1071. }
  1072. while (display.nextPage());
  1073. delay(2000);
  1074. }
  1075. }
  1076. }
  1077. #endif
  1078. #ifdef _GxBitmaps200x200_H_
  1079. void drawBitmaps200x200()
  1080. {
  1081. #if defined(ARDUINO_AVR_PRO)
  1082. const unsigned char* bitmaps[] =
  1083. {
  1084. logo200x200
  1085. };
  1086. #elif defined(__AVR)
  1087. const unsigned char* bitmaps[] =
  1088. {
  1089. logo200x200, //first200x200
  1090. };
  1091. #elif defined(_BOARD_GENERIC_STM32F103C_H_) || defined(STM32F1xx)
  1092. const unsigned char* bitmaps[] =
  1093. {
  1094. logo200x200, first200x200, second200x200, third200x200, //fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  1095. };
  1096. #else
  1097. const unsigned char* bitmaps[] =
  1098. {
  1099. logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
  1100. //logo200x200, first200x200, second200x200, fourth200x200, third200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200 // ED037TC1 test
  1101. };
  1102. #endif
  1103. if (display.epd2.hasColor) return; // to avoid many long refreshes
  1104. if ((display.epd2.WIDTH == 200) && (display.epd2.HEIGHT == 200) && !display.epd2.hasColor)
  1105. {
  1106. bool m = display.mirror(true);
  1107. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1108. {
  1109. display.firstPage();
  1110. do
  1111. {
  1112. display.fillScreen(GxEPD_WHITE);
  1113. display.drawInvertedBitmap(0, 0, bitmaps[i], 200, 200, GxEPD_BLACK);
  1114. }
  1115. while (display.nextPage());
  1116. delay(2000);
  1117. }
  1118. display.mirror(m);
  1119. }
  1120. //else
  1121. {
  1122. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  1123. display.clearScreen(); // use default for white
  1124. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  1125. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  1126. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1127. {
  1128. display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  1129. delay(2000);
  1130. }
  1131. }
  1132. bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
  1133. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1134. {
  1135. int16_t x = -60;
  1136. int16_t y = -60;
  1137. for (uint16_t j = 0; j < 10; j++)
  1138. {
  1139. display.writeScreenBuffer(); // use default for white
  1140. display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  1141. display.refresh(true);
  1142. if (display.epd2.hasFastPartialUpdate)
  1143. {
  1144. // for differential update: set previous buffer equal to current buffer in controller
  1145. display.epd2.writeScreenBufferAgain(); // use default for white
  1146. display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
  1147. }
  1148. delay(2000);
  1149. x += display.epd2.WIDTH / 4;
  1150. y += display.epd2.HEIGHT / 4;
  1151. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1152. }
  1153. if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
  1154. break; // comment out for full show
  1155. }
  1156. display.writeScreenBuffer(); // use default for white
  1157. display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  1158. display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
  1159. display.refresh(true);
  1160. // for differential update: set previous buffer equal to current buffer in controller
  1161. display.epd2.writeScreenBufferAgain(); // use default for white
  1162. display.epd2.writeImageAgain(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
  1163. 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);
  1164. delay(2000);
  1165. }
  1166. #endif
  1167. #ifdef _GxBitmaps104x212_H_
  1168. void drawBitmaps104x212()
  1169. {
  1170. #if !defined(__AVR)
  1171. const unsigned char* bitmaps[] =
  1172. {
  1173. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  1174. };
  1175. #else
  1176. const unsigned char* bitmaps[] =
  1177. {
  1178. WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
  1179. };
  1180. #endif
  1181. if ((display.epd2.WIDTH == 104) && (display.epd2.HEIGHT == 212) && !display.epd2.hasColor)
  1182. {
  1183. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1184. {
  1185. display.firstPage();
  1186. do
  1187. {
  1188. display.fillScreen(GxEPD_WHITE);
  1189. display.drawBitmap(0, 0, bitmaps[i], 104, 212, GxEPD_BLACK);
  1190. }
  1191. while (display.nextPage());
  1192. delay(2000);
  1193. }
  1194. }
  1195. }
  1196. #endif
  1197. #ifdef _GxBitmaps128x250_H_
  1198. void drawBitmaps128x250()
  1199. {
  1200. #if !defined(__AVR)
  1201. const unsigned char* bitmaps[] =
  1202. {
  1203. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  1204. };
  1205. #else
  1206. const unsigned char* bitmaps[] =
  1207. {
  1208. Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
  1209. };
  1210. #endif
  1211. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 250) && !display.epd2.hasColor)
  1212. {
  1213. bool m = display.mirror(true);
  1214. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1215. {
  1216. display.firstPage();
  1217. do
  1218. {
  1219. display.fillScreen(GxEPD_WHITE);
  1220. display.drawInvertedBitmap(0, 0, bitmaps[i], 128, 250, GxEPD_BLACK);
  1221. }
  1222. while (display.nextPage());
  1223. delay(2000);
  1224. }
  1225. display.mirror(m);
  1226. }
  1227. }
  1228. #endif
  1229. #ifdef _GxBitmaps128x296_H_
  1230. void drawBitmaps128x296()
  1231. {
  1232. #if !defined(__AVR)
  1233. const unsigned char* bitmaps[] =
  1234. {
  1235. Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
  1236. };
  1237. #else
  1238. const unsigned char* bitmaps[] =
  1239. {
  1240. Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
  1241. };
  1242. #endif
  1243. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 296) && !display.epd2.hasColor)
  1244. {
  1245. bool m = display.mirror(true);
  1246. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1247. {
  1248. display.firstPage();
  1249. do
  1250. {
  1251. display.fillScreen(GxEPD_WHITE);
  1252. display.drawInvertedBitmap(0, 0, bitmaps[i], 128, 296, GxEPD_BLACK);
  1253. }
  1254. while (display.nextPage());
  1255. delay(2000);
  1256. }
  1257. display.mirror(m);
  1258. }
  1259. }
  1260. #endif
  1261. #ifdef _GxBitmaps168x384_H_
  1262. void drawBitmaps168x384()
  1263. {
  1264. #if !defined(__AVR)
  1265. const unsigned char* bitmaps[] =
  1266. {
  1267. Bitmap168x384_1, Bitmap168x384_2, Bitmap168x384_3, Bitmap168x384_4, Bitmap168x384_5
  1268. };
  1269. #else
  1270. const unsigned char* bitmaps[] =
  1271. {
  1272. Bitmap168x384_1
  1273. };
  1274. #endif
  1275. if ((display.epd2.WIDTH == 168) && (display.epd2.HEIGHT == 384) && !display.epd2.hasColor)
  1276. {
  1277. bool mirrored = display.mirror(true);
  1278. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1279. {
  1280. display.firstPage();
  1281. do
  1282. {
  1283. display.fillScreen(GxEPD_WHITE);
  1284. display.drawInvertedBitmap(0, 0, bitmaps[i], 168, 384, GxEPD_BLACK);
  1285. }
  1286. while (display.nextPage());
  1287. delay(2000);
  1288. }
  1289. display.mirror(mirrored);
  1290. }
  1291. }
  1292. #endif
  1293. #ifdef _GxBitmaps152x296_H_
  1294. void drawBitmaps152x296()
  1295. {
  1296. #if !defined(__AVR)
  1297. const unsigned char* bitmaps[] =
  1298. {
  1299. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  1300. };
  1301. #else
  1302. const unsigned char* bitmaps[] =
  1303. {
  1304. Bitmap152x296_1, Bitmap152x296_2, Bitmap152x296_3
  1305. };
  1306. #endif
  1307. if ((display.epd2.WIDTH == 152) && (display.epd2.HEIGHT == 296) && !display.epd2.hasColor)
  1308. {
  1309. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1310. {
  1311. display.firstPage();
  1312. do
  1313. {
  1314. display.fillScreen(GxEPD_WHITE);
  1315. display.drawInvertedBitmap(0, 0, bitmaps[i], 152, 296, GxEPD_BLACK);
  1316. }
  1317. while (display.nextPage());
  1318. delay(2000);
  1319. }
  1320. }
  1321. }
  1322. #endif
  1323. #ifdef _GxBitmaps240x320_H_
  1324. void drawBitmaps240x320()
  1325. {
  1326. #if !defined(__AVR)
  1327. const unsigned char* bitmaps[] =
  1328. {
  1329. Bitmap240x320_1, Bitmap240x320_2, Bitmap240x320_3, Bitmap240x320_4, Bitmap240x320_5
  1330. };
  1331. #else
  1332. const unsigned char* bitmaps[] =
  1333. {
  1334. Bitmap240x320_1, Bitmap240x320_2
  1335. };
  1336. #endif
  1337. if ((display.epd2.WIDTH == 240) && (display.epd2.HEIGHT == 320) && !display.epd2.hasColor)
  1338. {
  1339. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1340. {
  1341. display.firstPage();
  1342. do
  1343. {
  1344. display.fillScreen(GxEPD_WHITE);
  1345. display.drawInvertedBitmap(0, 0, bitmaps[i], 240, 320, GxEPD_BLACK);
  1346. }
  1347. while (display.nextPage());
  1348. delay(2000);
  1349. }
  1350. }
  1351. }
  1352. #endif
  1353. #ifdef _GxBitmaps176x264_H_
  1354. void drawBitmaps176x264()
  1355. {
  1356. #if !defined(__AVR)
  1357. const unsigned char* bitmaps[] =
  1358. {
  1359. Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1360. };
  1361. #else
  1362. const unsigned char* bitmaps[] =
  1363. {
  1364. Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
  1365. };
  1366. #endif
  1367. if ((display.epd2.WIDTH == 176) && (display.epd2.HEIGHT == 264) && !display.epd2.hasColor)
  1368. {
  1369. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1370. {
  1371. display.firstPage();
  1372. do
  1373. {
  1374. display.fillScreen(GxEPD_WHITE);
  1375. display.drawInvertedBitmap(0, 0, bitmaps[i], 176, 264, GxEPD_BLACK);
  1376. }
  1377. while (display.nextPage());
  1378. delay(2000);
  1379. }
  1380. }
  1381. }
  1382. #endif
  1383. #ifdef _GxBitmaps240x416_H_
  1384. void drawBitmaps240x416()
  1385. {
  1386. #if !defined(__AVR)
  1387. const unsigned char* bitmaps[] =
  1388. {
  1389. Bitmap240x416_1, Bitmap240x416_2, Bitmap240x416_3
  1390. };
  1391. #else
  1392. const unsigned char* bitmaps[] =
  1393. {
  1394. Bitmap240x460_1, Bitmap240x460_2, Bitmap240x460_3
  1395. };
  1396. #endif
  1397. if ((display.epd2.WIDTH == 240) && (display.epd2.HEIGHT == 416) && !display.epd2.hasColor)
  1398. {
  1399. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1400. {
  1401. display.firstPage();
  1402. do
  1403. {
  1404. display.fillScreen(GxEPD_WHITE);
  1405. display.drawInvertedBitmap(0, 0, bitmaps[i], 240, 416, GxEPD_BLACK);
  1406. }
  1407. while (display.nextPage());
  1408. delay(2000);
  1409. }
  1410. }
  1411. }
  1412. #endif
  1413. #ifdef _GxBitmaps400x300_H_
  1414. void drawBitmaps400x300()
  1415. {
  1416. #if !defined(__AVR)
  1417. const unsigned char* bitmaps[] =
  1418. {
  1419. Bitmap400x300_1, Bitmap400x300_2
  1420. };
  1421. #else
  1422. const unsigned char* bitmaps[] = {}; // not enough code space
  1423. #endif
  1424. if ((display.epd2.WIDTH == 400) && (display.epd2.HEIGHT == 300) && !display.epd2.hasColor)
  1425. {
  1426. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1427. {
  1428. display.firstPage();
  1429. do
  1430. {
  1431. display.fillScreen(GxEPD_WHITE);
  1432. display.drawInvertedBitmap(0, 0, bitmaps[i], 400, 300, GxEPD_BLACK);
  1433. }
  1434. while (display.nextPage());
  1435. delay(2000);
  1436. }
  1437. }
  1438. }
  1439. #endif
  1440. #ifdef _GxBitmaps640x384_H_
  1441. void drawBitmaps640x384()
  1442. {
  1443. #if !defined(__AVR)
  1444. const unsigned char* bitmaps[] =
  1445. {
  1446. Bitmap640x384_1, Bitmap640x384_2
  1447. };
  1448. #else
  1449. const unsigned char* bitmaps[] = {}; // not enough code space
  1450. #endif
  1451. if ((display.epd2.WIDTH == 640) && (display.epd2.HEIGHT == 384))
  1452. {
  1453. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1454. {
  1455. display.firstPage();
  1456. do
  1457. {
  1458. display.fillScreen(GxEPD_WHITE);
  1459. display.drawInvertedBitmap(0, 0, bitmaps[i], 640, 384, GxEPD_BLACK);
  1460. }
  1461. while (display.nextPage());
  1462. delay(2000);
  1463. }
  1464. }
  1465. }
  1466. #endif
  1467. #ifdef _GxBitmaps648x480_H_
  1468. void drawBitmaps648x480()
  1469. {
  1470. #if !defined(__AVR)
  1471. const unsigned char* bitmaps[] =
  1472. {
  1473. Bitmap648x480_1, Bitmap648x480_2, Bitmap648x480_3
  1474. };
  1475. #else
  1476. const unsigned char* bitmaps[] = {}; // not enough code space
  1477. #endif
  1478. if ((display.epd2.WIDTH == 648) && (display.epd2.HEIGHT == 480) && !display.epd2.hasColor)
  1479. {
  1480. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1481. {
  1482. display.firstPage();
  1483. do
  1484. {
  1485. display.fillScreen(GxEPD_WHITE);
  1486. display.drawBitmap(0, 0, bitmaps[i], 648, 480, GxEPD_BLACK);
  1487. }
  1488. while (display.nextPage());
  1489. delay(2000);
  1490. }
  1491. }
  1492. }
  1493. #endif
  1494. #if defined(ESP32) && defined(_GxBitmaps800x276_H_)
  1495. void drawBitmaps800x276()
  1496. {
  1497. if ((display.epd2.WIDTH == 792) && (display.epd2.HEIGHT == 272) && !display.epd2.hasColor)
  1498. {
  1499. display.drawImage(Bitmap800x276_1, 0, 0, 800, 272, true, false, true); delay(2000);
  1500. display.drawImage(Bitmap800x276_2, 0, 0, 800, 272, true, false, true); delay(2000);
  1501. display.drawImage(Bitmap800x276_3, 0, 0, 800, 272, true, false, true); delay(2000);
  1502. display.clearScreen();
  1503. int16_t wp = display.epd2.WIDTH / 5;
  1504. int16_t hp = display.epd2.HEIGHT / 5;
  1505. for (int16_t i = 0; i < 5; i++)
  1506. {
  1507. for (int16_t j = 0; j < 5; j++)
  1508. {
  1509. display.writeImagePart(Bitmap800x276_1, i * wp, j * hp, 800, 272, i * wp, j * hp, wp, hp, true, false, true);
  1510. display.refresh(true);
  1511. display.epd2.writeImagePartAgain(Bitmap800x276_1, i * wp, j * hp, 800, 272, i * wp, j * hp, wp, hp, true, false, true);
  1512. delay(500);
  1513. }
  1514. }
  1515. }
  1516. }
  1517. #endif
  1518. #ifdef _GxBitmaps800x480_H_
  1519. void drawBitmaps800x480()
  1520. {
  1521. #if defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI)
  1522. const unsigned char* bitmaps[] =
  1523. {
  1524. Bitmap800x480_3, Bitmap800x480_4
  1525. };
  1526. #elif !defined(__AVR)
  1527. const unsigned char* bitmaps[] =
  1528. {
  1529. Bitmap800x480_1, Bitmap800x480_2, Bitmap800x480_3, Bitmap800x480_4
  1530. };
  1531. #else
  1532. const unsigned char* bitmaps[] = {}; // not enough code space
  1533. #endif
  1534. if ((display.epd2.WIDTH == 800) && (display.epd2.HEIGHT == 480) && !display.epd2.hasColor)
  1535. {
  1536. for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
  1537. {
  1538. display.firstPage();
  1539. do
  1540. {
  1541. display.fillScreen(GxEPD_WHITE);
  1542. display.drawBitmap(0, 0, bitmaps[i], 800, 480, GxEPD_BLACK);
  1543. }
  1544. while (display.nextPage());
  1545. delay(2000);
  1546. }
  1547. #if defined(ESP32)
  1548. if (display.epd2.panel == GxEPD2::GDEM0397T81)
  1549. {
  1550. display.drawImage(Bitmap800x480_5, 0, 0, 800, 480, false, true, true); delay(2000);
  1551. display.drawImage(Bitmap800x480_6, 0, 0, 800, 480, false, true, true); delay(2000);
  1552. display.drawImage(Bitmap800x480_7, 0, 0, 800, 480, false, true, true); delay(2000);
  1553. display.drawImage(Bitmap800x480_8, 0, 0, 800, 480, false, true, true); delay(2000);
  1554. display.drawImage(Bitmap800x480_9, 0, 0, 800, 480, false, true, true); delay(2000);
  1555. }
  1556. #endif
  1557. if ((display.epd2.panel == GxEPD2::GDEW075T7) || (display.epd2.panel == GxEPD2::GDEY075T7))
  1558. {
  1559. // avoid ghosting caused by OTP waveform
  1560. display.clearScreen();
  1561. display.refresh(false); // full update
  1562. }
  1563. }
  1564. }
  1565. #endif
  1566. #if defined(ESP32) && defined(_GxBitmaps960x640_H_)
  1567. void drawBitmaps960x640()
  1568. {
  1569. if ((display.epd2.WIDTH == 960) && (display.epd2.HEIGHT == 640) && !display.epd2.hasColor)
  1570. {
  1571. display.drawImage(Bitmap960x640_1, 0, 0, 960, 640, false, true, true); delay(5000);
  1572. display.drawImage(Bitmap960x640_2, 0, 0, 960, 640, false, true, true); delay(5000);
  1573. display.drawImage(Bitmap960x640_3, 0, 0, 960, 640, false, true, true); delay(5000);
  1574. }
  1575. }
  1576. #endif
  1577. #if defined(ESP32) && defined(_GxBitmaps960x680_H_)
  1578. void drawBitmaps960x680()
  1579. {
  1580. if ((display.epd2.WIDTH == 960) && (display.epd2.HEIGHT == 680) && !display.epd2.hasColor)
  1581. {
  1582. display.drawImage(Bitmap960x680_1, 0, 0, 960, 680, false, true, true); delay(5000);
  1583. display.drawImage(Bitmap960x680_2, 0, 0, 960, 680, false, true, true); delay(5000);
  1584. }
  1585. }
  1586. #endif
  1587. #ifdef _WS_Bitmaps800x600_H_
  1588. void drawBitmaps800x600()
  1589. {
  1590. #if defined(ESP8266) || defined(ESP32)
  1591. if ((display.epd2.panel == GxEPD2::ED060SCT) || (display.epd2.panel == GxEPD2::ED060KC1) || (display.epd2.panel == GxEPD2::ED078KC2))
  1592. {
  1593. // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
  1594. display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
  1595. delay(2000);
  1596. // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
  1597. // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
  1598. // delay(2000);
  1599. // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
  1600. // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
  1601. // delay(2000);
  1602. }
  1603. #endif
  1604. }
  1605. #endif
  1606. #if defined(ESP32) && defined(_GxBitmaps1304x984_H_)
  1607. void drawBitmaps1304x984()
  1608. {
  1609. if (display.epd2.panel == GxEPD2::GDEW1248T3)
  1610. {
  1611. display.drawImage(Bitmap1304x984, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1612. }
  1613. }
  1614. #endif
  1615. #if defined(ESP32) && defined(_GxBitmaps1360x480_H_)
  1616. void drawBitmaps1360x480()
  1617. {
  1618. if (display.epd2.panel == GxEPD2::GDEM1085T51)
  1619. {
  1620. display.drawImage(Bitmap1360x480_1, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1621. delay(2000);
  1622. display.drawImage(Bitmap1360x480_p1, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1623. delay(1000);
  1624. display.drawImage(Bitmap1360x480_p2, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1625. delay(1000);
  1626. display.drawImage(Bitmap1360x480_p3, 0, 0, display.epd2.WIDTH, display.epd2.HEIGHT, false, false, true);
  1627. delay(1000);
  1628. display.clearScreen();
  1629. int16_t wp = display.epd2.WIDTH / 5;
  1630. int16_t hp = display.epd2.HEIGHT / 5;
  1631. for (int16_t i = 0; i < 5; i++)
  1632. {
  1633. for (int16_t j = 0; j < 5; j++)
  1634. {
  1635. display.writeImagePart(Bitmap1360x480_1, i * wp, j * hp, 1360, 480, i * wp, j * hp, wp, hp, false, false, true);
  1636. display.refresh(true);
  1637. delay(500);
  1638. }
  1639. }
  1640. }
  1641. }
  1642. #endif
  1643. struct bitmap_pair
  1644. {
  1645. const unsigned char* black;
  1646. const unsigned char* red;
  1647. };
  1648. #ifdef _GxBitmaps3c200x200_H_
  1649. void drawBitmaps3c200x200()
  1650. {
  1651. bitmap_pair bitmap_pairs[] =
  1652. {
  1653. //{Bitmap3c200x200_black, Bitmap3c200x200_red},
  1654. {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
  1655. };
  1656. if (display.epd2.panel == GxEPD2::GDEW0154Z04)
  1657. {
  1658. display.firstPage();
  1659. do
  1660. {
  1661. display.fillScreen(GxEPD_WHITE);
  1662. // Bitmap3c200x200_black has 2 bits per pixel
  1663. // taken from Adafruit_GFX.cpp, modified
  1664. int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
  1665. uint8_t byte = 0;
  1666. for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
  1667. {
  1668. for (int16_t i = 0; i < display.epd2.WIDTH; i++)
  1669. {
  1670. if (i & 3) byte <<= 2;
  1671. else
  1672. {
  1673. #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
  1674. byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
  1675. #else
  1676. byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
  1677. #endif
  1678. }
  1679. if (!(byte & 0x80))
  1680. {
  1681. display.drawPixel(i, j, GxEPD_BLACK);
  1682. }
  1683. }
  1684. }
  1685. display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1686. }
  1687. while (display.nextPage());
  1688. delay(2000);
  1689. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1690. {
  1691. display.firstPage();
  1692. do
  1693. {
  1694. display.fillScreen(GxEPD_WHITE);
  1695. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1696. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1697. }
  1698. while (display.nextPage());
  1699. delay(2000);
  1700. }
  1701. }
  1702. if (display.epd2.hasColor)
  1703. {
  1704. display.clearScreen(); // use default for white
  1705. int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
  1706. int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
  1707. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1708. {
  1709. display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1710. delay(2000);
  1711. }
  1712. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1713. {
  1714. int16_t x = -60;
  1715. int16_t y = -60;
  1716. for (uint16_t j = 0; j < 10; j++)
  1717. {
  1718. display.writeScreenBuffer(); // use default for white
  1719. display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
  1720. display.refresh();
  1721. delay(1000);
  1722. x += display.epd2.WIDTH / 4;
  1723. y += display.epd2.HEIGHT / 4;
  1724. if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
  1725. }
  1726. }
  1727. display.writeScreenBuffer(); // use default for white
  1728. display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
  1729. 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);
  1730. display.refresh();
  1731. delay(2000);
  1732. }
  1733. }
  1734. #endif
  1735. #ifdef _GxBitmaps3c104x212_H_
  1736. void drawBitmaps3c104x212()
  1737. {
  1738. #if !defined(__AVR)
  1739. bitmap_pair bitmap_pairs[] =
  1740. {
  1741. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1742. {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1743. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1744. };
  1745. #else
  1746. bitmap_pair bitmap_pairs[] =
  1747. {
  1748. {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
  1749. //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
  1750. {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
  1751. };
  1752. #endif
  1753. if (display.epd2.panel == GxEPD2::GDEW0213Z16)
  1754. {
  1755. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1756. {
  1757. display.firstPage();
  1758. do
  1759. {
  1760. display.fillScreen(GxEPD_WHITE);
  1761. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1762. if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
  1763. {
  1764. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1765. }
  1766. else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1767. }
  1768. while (display.nextPage());
  1769. delay(2000);
  1770. }
  1771. }
  1772. }
  1773. #endif
  1774. #ifdef _GxBitmaps3c128x250_H_
  1775. void drawBitmaps3c128x250()
  1776. {
  1777. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 250) && display.epd2.hasColor)
  1778. {
  1779. bool mirrored = display.mirror(true);
  1780. display.firstPage();
  1781. do
  1782. {
  1783. display.fillScreen(GxEPD_WHITE);
  1784. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_1_black, 128, 250, GxEPD_BLACK);
  1785. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_1_red, 128, 250, GxEPD_RED);
  1786. }
  1787. while (display.nextPage());
  1788. delay(2000);
  1789. #if !defined(__AVR)
  1790. display.firstPage();
  1791. do
  1792. {
  1793. display.fillScreen(GxEPD_WHITE);
  1794. display.drawInvertedBitmap(0, 0, Bitmap3c128x250_2_black, 128, 250, GxEPD_BLACK);
  1795. display.drawBitmap(0, 0, Bitmap3c128x250_2_red, 128, 250, GxEPD_RED);
  1796. }
  1797. while (display.nextPage());
  1798. delay(2000);
  1799. #endif
  1800. display.mirror(mirrored);
  1801. }
  1802. }
  1803. #endif
  1804. #ifdef _GxBitmaps3c128x296_H_
  1805. void drawBitmaps3c128x296()
  1806. {
  1807. #if !defined(__AVR)
  1808. bitmap_pair bitmap_pairs[] =
  1809. {
  1810. {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1811. {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1812. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1813. };
  1814. #else
  1815. bitmap_pair bitmap_pairs[] =
  1816. {
  1817. //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
  1818. //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
  1819. {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
  1820. };
  1821. #endif
  1822. if ((display.epd2.WIDTH == 128) && (display.epd2.HEIGHT == 296) && display.epd2.hasColor)
  1823. {
  1824. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1825. {
  1826. display.firstPage();
  1827. do
  1828. {
  1829. display.fillScreen(GxEPD_WHITE);
  1830. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, 128, 296, GxEPD_BLACK);
  1831. if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
  1832. {
  1833. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 128, 296, GxEPD_RED);
  1834. }
  1835. else display.drawBitmap(0, 0, bitmap_pairs[i].red, 128, 296, GxEPD_RED);
  1836. }
  1837. while (display.nextPage());
  1838. delay(2000);
  1839. }
  1840. }
  1841. }
  1842. #endif
  1843. #ifdef _GxBitmaps3c152x296_H_
  1844. void drawBitmaps3c152x296()
  1845. {
  1846. bitmap_pair bitmap_pairs[] =
  1847. {
  1848. {Bitmap3c152x296_black, Bitmap3c152x296_red}
  1849. };
  1850. if (display.epd2.panel == GxEPD2::GDEY0266Z90)
  1851. {
  1852. bool mirrored = display.mirror(true);
  1853. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1854. {
  1855. display.firstPage();
  1856. do
  1857. {
  1858. display.fillScreen(GxEPD_WHITE);
  1859. display.drawBitmap(0, 0, bitmap_pairs[i].black, 152, 296, GxEPD_BLACK);
  1860. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 152, 296, GxEPD_RED);
  1861. }
  1862. while (display.nextPage());
  1863. delay(2000);
  1864. }
  1865. display.mirror(mirrored);
  1866. }
  1867. }
  1868. #endif
  1869. #ifdef _GxBitmaps3c176x264_H_
  1870. void drawBitmaps3c176x264()
  1871. {
  1872. bitmap_pair bitmap_pairs[] =
  1873. {
  1874. {Bitmap3c176x264_black, Bitmap3c176x264_red}
  1875. };
  1876. if (display.epd2.panel == GxEPD2::GDEW027C44)
  1877. {
  1878. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1879. {
  1880. display.firstPage();
  1881. do
  1882. {
  1883. display.fillScreen(GxEPD_WHITE);
  1884. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1885. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1886. }
  1887. while (display.nextPage());
  1888. delay(2000);
  1889. }
  1890. }
  1891. }
  1892. #endif
  1893. #ifdef _GxBitmaps3c400x300_H_
  1894. void drawBitmaps3c400x300()
  1895. {
  1896. #if !defined(__AVR)
  1897. bitmap_pair bitmap_pairs[] =
  1898. {
  1899. {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
  1900. {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
  1901. {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red},
  1902. {Bitmap3c400x300_3_black, Bitmap3c400x300_3_red},
  1903. {Bitmap3c400x300_4_black, Bitmap3c400x300_4_red},
  1904. };
  1905. #else
  1906. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1907. #endif
  1908. if ((display.epd2.WIDTH == 400) && (display.epd2.HEIGHT == 300) && display.epd2.hasColor)
  1909. {
  1910. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1911. {
  1912. display.firstPage();
  1913. do
  1914. {
  1915. display.fillScreen(GxEPD_WHITE);
  1916. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  1917. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  1918. }
  1919. while (display.nextPage());
  1920. delay(2000);
  1921. }
  1922. }
  1923. }
  1924. #endif
  1925. #ifdef _GxBitmaps3c648x480_H_
  1926. void drawBitmaps3c648x480()
  1927. {
  1928. #if !defined(__AVR)
  1929. bitmap_pair bitmap_pairs[] =
  1930. {
  1931. {Bitmap3c648x480_black, Bitmap3c648x480_red},
  1932. {Bitmap3c648x480_black_2, Bitmap3c648x480_red_2}
  1933. };
  1934. #else
  1935. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1936. #endif
  1937. if ((display.epd2.panel == GxEPD2::GDEW0583Z83) || (display.epd2.panel == GxEPD2::GDEQ0583Z31))
  1938. {
  1939. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1940. {
  1941. display.firstPage();
  1942. do
  1943. {
  1944. display.fillScreen(GxEPD_WHITE);
  1945. display.drawBitmap(0, 0, bitmap_pairs[i].black, 648, 480, GxEPD_BLACK);
  1946. display.drawBitmap(0, 0, bitmap_pairs[i].red, 648, 480, GxEPD_RED);
  1947. }
  1948. while (display.nextPage());
  1949. delay(2000);
  1950. }
  1951. }
  1952. }
  1953. #endif
  1954. #if defined(ESP32) && defined(_GxBitmaps3c800x276_H_)
  1955. void drawBitmaps3c800x276()
  1956. {
  1957. if ((display.epd2.WIDTH == 792) && (display.epd2.HEIGHT == 272) && display.epd2.hasColor)
  1958. {
  1959. display.drawImage(Bitmap3c800x276_black_1, Bitmap3c800x276_red_1, 0, 0, 800, 272, true, false, true); delay(2000);
  1960. display.drawImage(Bitmap3c800x276_black_2, Bitmap3c800x276_red_2, 0, 0, 800, 272, true, false, true); delay(2000);
  1961. int16_t wp = display.epd2.WIDTH / 5;
  1962. int16_t hp = display.epd2.HEIGHT / 5;
  1963. int16_t n = 0;
  1964. for (int16_t k = 0; k < 3; k++)
  1965. {
  1966. display.writeScreenBuffer();
  1967. for (int16_t i = 0; i < 5; i++)
  1968. {
  1969. for (int16_t j = 0; j < 5; j++)
  1970. {
  1971. if ((n++ % 2) || (k == 2))
  1972. {
  1973. display.writeImagePart(Bitmap3c800x276_black_1, Bitmap3c800x276_red_1, i * wp, j * hp, 800, 272, i * wp, j * hp, wp, hp, true, false, true);
  1974. }
  1975. }
  1976. }
  1977. display.refresh(false);
  1978. delay(2000);
  1979. }
  1980. }
  1981. }
  1982. #endif
  1983. #ifdef _GxBitmaps3c800x480_H_
  1984. void drawBitmaps3c800x480()
  1985. {
  1986. #if !defined(__AVR)
  1987. bitmap_pair bitmap_pairs[] =
  1988. {
  1989. {Bitmap3c800x480_1_black, Bitmap3c800x480_1_red}
  1990. };
  1991. #else
  1992. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  1993. #endif
  1994. if ((display.epd2.panel == GxEPD2::GDEW075Z08) || (display.epd2.panel == GxEPD2::GDEY075Z08))
  1995. {
  1996. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  1997. {
  1998. display.firstPage();
  1999. do
  2000. {
  2001. display.fillScreen(GxEPD_WHITE);
  2002. display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
  2003. display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
  2004. }
  2005. while (display.nextPage());
  2006. delay(2000);
  2007. }
  2008. }
  2009. }
  2010. #endif
  2011. #ifdef _GxBitmaps3c880x528_H_
  2012. void drawBitmaps3c880x528()
  2013. {
  2014. #if !defined(__AVR)
  2015. bitmap_pair bitmap_pairs[] =
  2016. {
  2017. {Bitmap3c880x528_black, Bitmap3c880x528_red}
  2018. };
  2019. #else
  2020. bitmap_pair bitmap_pairs[] = {}; // not enough code space
  2021. #endif
  2022. if (display.epd2.panel == GxEPD2::GDEH075Z90)
  2023. {
  2024. bool m = display.mirror(true);
  2025. for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
  2026. {
  2027. display.firstPage();
  2028. do
  2029. {
  2030. display.fillScreen(GxEPD_WHITE);
  2031. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, 880, 528, GxEPD_BLACK);
  2032. display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, 880, 528, GxEPD_RED);
  2033. }
  2034. while (display.nextPage());
  2035. delay(2000);
  2036. }
  2037. display.mirror(m);
  2038. }
  2039. }
  2040. #endif
  2041. #if defined(ESP32) && defined(_GxBitmaps3c960x640_H_)
  2042. void drawBitmaps3c960x640()
  2043. {
  2044. if ((display.epd2.WIDTH == 960) && (display.epd2.HEIGHT == 640) && display.epd2.hasColor)
  2045. {
  2046. display.drawImage(Bitmap3c960x640_black, Bitmap3c960x640_red, 0, 0, 960, 640, false, false, true);
  2047. delay(2000);
  2048. }
  2049. }
  2050. #endif
  2051. #if defined(ESP32) && defined(_GxBitmaps3c960x680_H_)
  2052. void drawBitmaps3c960x680()
  2053. {
  2054. if ((display.epd2.WIDTH == 960) && (display.epd2.HEIGHT == 680) && display.epd2.hasColor)
  2055. {
  2056. display.drawImage(Bitmap3c960x680_black, Bitmap3c960x680_red, 0, 0, 960, 680, false, true, true);
  2057. }
  2058. delay(2000);
  2059. }
  2060. #endif
  2061. #if defined(ESP32) && defined(_GxBitmaps3c1304x984_H_)
  2062. void drawBitmaps3c1304x984()
  2063. {
  2064. if (display.epd2.panel == GxEPD2::GDEY1248Z51)
  2065. {
  2066. //display.drawImage(Bitmap3c1304x984_black, Bitmap3c1304x984_red, 0, 0, 1304, 984, false, false, true);
  2067. display.writeImage(0, Bitmap3c1304x984_red, 0, 0, 1304, 984, true, false, true); // red bitmap is inverted
  2068. display.drawImage(Bitmap3c1304x984_black, 0, 0, 0, 1304, 984, true, false, true); // black bitmap is normal
  2069. }
  2070. }
  2071. #endif
  2072. #if defined(_GxBitmaps4c200x200_H_)
  2073. void drawBitmaps4c200x200()
  2074. {
  2075. if (display.epd2.panel == GxEPD2::GDEM0154F51H)
  2076. {
  2077. display.drawNative(Bitmap4c200x200, 0, 0, 0, 200, 200, true, false, true);
  2078. delay(5000);
  2079. }
  2080. }
  2081. #endif
  2082. #if defined(_GxBitmaps4c128x250_H_)
  2083. void drawBitmaps4c128x250()
  2084. {
  2085. if (display.epd2.panel == GxEPD2::GDEY0213F51)
  2086. {
  2087. display.drawNative(Bitmap4c128x250, 0, 0, 0, 128, 250, false, false, true);
  2088. delay(5000);
  2089. }
  2090. }
  2091. #endif
  2092. #if defined(_WS_Bitmaps4c168x168_H_)
  2093. void drawBitmaps4c168x168()
  2094. {
  2095. if ((display.epd2.panel == GxEPD2::Waveshare437inch4color) || (display.epd2.panel == GxEPD2::Waveshare3inch4color) ||
  2096. (display.epd2.panel == GxEPD2::GDEY0579F51) || (display.epd2.panel == GxEPD2::GDEY116F51))
  2097. {
  2098. display.drawNative(WS_Bitmap4c168x168, 0, (display.epd2.WIDTH - 168) / 2, (display.epd2.HEIGHT - 168) / 2, 168, 168, false, false, true);
  2099. delay(5000);
  2100. }
  2101. }
  2102. #endif
  2103. #if defined(_WS_Bitmaps4c168x400_H_)
  2104. void drawBitmaps4c168x400()
  2105. {
  2106. if (display.epd2.panel == GxEPD2::Waveshare3inch4color)
  2107. {
  2108. display.drawNative(WS_Bitmap4c168x400, 0, (display.epd2.WIDTH - 168) / 2, (display.epd2.HEIGHT - 400) / 2, 168, 400, false, false, true);
  2109. delay(5000);
  2110. }
  2111. }
  2112. #endif
  2113. #if defined(_GxBitmaps4c168x384_H_)
  2114. void drawBitmaps4c168x384()
  2115. {
  2116. if (display.epd2.panel == GxEPD2::GDEY029F51H)
  2117. {
  2118. display.drawNative(Bitmap4c168x384, 0, (display.epd2.WIDTH - 168) / 2, (display.epd2.HEIGHT - 384) / 2, 168, 384, false, false, true);
  2119. delay(5000);
  2120. }
  2121. }
  2122. #endif
  2123. #if defined(_GxBitmaps4c184x360_H_)
  2124. void drawBitmaps4c184x360()
  2125. {
  2126. if (display.epd2.panel == GxEPD2::GDEY0266F51H)
  2127. {
  2128. display.drawNative(Bitmap4c184x360, 0, (display.epd2.WIDTH - 184) / 2, (display.epd2.HEIGHT - 360) / 2, 184, 360, false, false, true);
  2129. delay(5000);
  2130. }
  2131. }
  2132. #endif
  2133. #if defined(_GxBitmaps4c184x384_H_)
  2134. void drawBitmaps4c184x384()
  2135. {
  2136. if (display.epd2.panel == GxEPD2::GDEM035F51)
  2137. {
  2138. display.drawNative(Bitmap4c184x384, 0, (display.epd2.WIDTH - 184) / 2, (display.epd2.HEIGHT - 384) / 2, 184, 384, true, false, true);
  2139. delay(5000);
  2140. }
  2141. }
  2142. #endif
  2143. #if defined(_GxBitmaps4c400x300_H_)
  2144. void drawBitmaps4c400x300()
  2145. {
  2146. if (display.epd2.panel == GxEPD2::GDEY0420F51)
  2147. {
  2148. display.drawNative(Bitmap4c400x300, 0, (display.epd2.WIDTH - 400) / 2, (display.epd2.HEIGHT - 300) / 2, 400, 300, false, false, true);
  2149. delay(5000);
  2150. }
  2151. }
  2152. #endif
  2153. #if defined(_GxBitmaps4c800x480_H_)
  2154. void drawBitmaps4c800x480()
  2155. {
  2156. if ((display.epd2.panel == GxEPD2::GDEM0397F81) || (display.epd2.panel == GxEPD2::GDEM075F52))
  2157. {
  2158. display.drawNative(Bitmap4c800x480_1, 0, (display.epd2.WIDTH - 800) / 2, (display.epd2.HEIGHT - 480) / 2, 800, 480, true, false, true);
  2159. delay(5000);
  2160. display.drawNative(Bitmap4c800x480_2, 0, (display.epd2.WIDTH - 800) / 2, (display.epd2.HEIGHT - 480) / 2, 800, 480, true, false, true);
  2161. delay(5000);
  2162. }
  2163. }
  2164. #endif
  2165. #if defined(_GxBitmaps4c960x640_H_)
  2166. void drawBitmaps4c960x640()
  2167. {
  2168. if (display.epd2.panel == GxEPD2::GDEY116F51)
  2169. {
  2170. display.drawNative(Bitmap4c960x640, 0, (display.epd2.WIDTH - 960) / 2, (display.epd2.HEIGHT - 640) / 2, 960, 640, true, false, true);
  2171. delay(5000);
  2172. }
  2173. }
  2174. #endif
  2175. #if defined(ESP32) && defined(_GxBitmaps4c792x272_H_)
  2176. void drawBitmaps4c792x272()
  2177. {
  2178. if (display.epd2.panel == GxEPD2::GDEY0579F51)
  2179. {
  2180. display.drawNative(Bitmap4c792x272, 0, (display.epd2.WIDTH - 792) / 2, (display.epd2.HEIGHT - 272) / 2, 792, 272, true, false, true);
  2181. delay(5000);
  2182. #if defined(GxEPD2_DRIVER_CLASS) && defined(IS_GxEPD2_DRIVER_4C)
  2183. #if IS_GxEPD2_DRIVER_4C(GxEPD2_DRIVER_CLASS)
  2184. int16_t wp = display.epd2.WIDTH / 5;
  2185. int16_t hp = display.epd2.HEIGHT / 5;
  2186. int16_t n = 0;
  2187. for (int16_t k = 0; k < 3; k++)
  2188. {
  2189. display.writeScreenBuffer();
  2190. for (int16_t i = 0; i < 5; i++)
  2191. {
  2192. for (int16_t j = 0; j < 5; j++)
  2193. {
  2194. if ((n++ % 2) || (k == 2))
  2195. {
  2196. display.epd2.writeNativePart(Bitmap4c792x272, 0, i * wp, j * hp, 792, 272, i * wp, j * hp, wp, hp, true, false, true);
  2197. }
  2198. }
  2199. }
  2200. display.refresh(false);
  2201. delay(2000);
  2202. }
  2203. #endif
  2204. #endif
  2205. }
  2206. }
  2207. #endif
  2208. #if defined(_GxBitmaps7c600x448_H_)
  2209. void drawBitmaps7c600x448()
  2210. {
  2211. if (display.epd2.panel == GxEPD2::GDEP0565D90)
  2212. {
  2213. display.epd2.drawDemoBitmap(Bitmap7c600x448, 0, 0, 0, 600, 448, 1, false, true);
  2214. delay(5000);
  2215. }
  2216. }
  2217. #endif
  2218. #if defined(_WS_Bitmaps7c192x143_H_)
  2219. void drawBitmaps7c192x143()
  2220. {
  2221. if (display.epd2.panel == GxEPD2::ACeP565)
  2222. {
  2223. display.drawNative(WS_Bitmap7c192x143, 0, (display.epd2.WIDTH - 192) / 2, (display.epd2.HEIGHT - 143) / 2, 192, 143, false, false, true);
  2224. delay(5000);
  2225. }
  2226. }
  2227. #endif
  2228. #if defined(_GxBitmaps7c800x480_H_)
  2229. void drawBitmaps7c800x480()
  2230. {
  2231. if ((display.epd2.panel == GxEPD2::GDEY073D46) || (display.epd2.panel == GxEPD2::ACeP730) || (display.epd2.panel == GxEPD2::GDEP0565D90) || (display.epd2.panel == GxEPD2::GDEP073E01))
  2232. {
  2233. display.epd2.drawDemoBitmap(Bitmap7c800x480, 0, 0, 0, 800, 480, 0, false, true); // special format
  2234. delay(5000);
  2235. display.epd2.drawDemoBitmap(Bitmap7c800x480_2, 0, 0, 0, 800, 480, 1, false, true); // special format mode 1
  2236. delay(5000);
  2237. }
  2238. }
  2239. #endif
  2240. #if defined(_WS_Bitmaps7c300x180_H_)
  2241. void drawBitmaps7c300x180()
  2242. {
  2243. if ((display.epd2.panel == GxEPD2::GDEY073D46) || (display.epd2.panel == GxEPD2::ACeP730) || (display.epd2.panel == GxEPD2::GDEP0565D90))
  2244. {
  2245. display.drawNative(WS_Bitmap7c300x180, 0, (display.epd2.WIDTH - 300) / 2, (display.epd2.HEIGHT - 180) / 2, 300, 180, false, false, true);
  2246. delay(5000);
  2247. }
  2248. }
  2249. #endif
  2250. void draw4colors()
  2251. {
  2252. display.setRotation(0);
  2253. uint16_t h = display.height() / 4;
  2254. display.firstPage();
  2255. do
  2256. {
  2257. display.fillRect(0, 0, display.width(), h, GxEPD_WHITE);
  2258. display.fillRect(0, 1 * h, display.width(), h, GxEPD_YELLOW);
  2259. display.fillRect(0, 2 * h, display.width(), h, GxEPD_RED);
  2260. display.fillRect(0, 3 * h, display.width(), h, GxEPD_BLACK);
  2261. }
  2262. while (display.nextPage());
  2263. }
  2264. void draw7colors()
  2265. {
  2266. display.setRotation(0);
  2267. uint16_t h = display.height() / 7;
  2268. display.firstPage();
  2269. do
  2270. {
  2271. display.fillRect(0, 0, display.width(), h, GxEPD_BLACK);
  2272. display.fillRect(0, h, display.width(), h, GxEPD_WHITE);
  2273. display.fillRect(0, 2 * h, display.width(), h, GxEPD_GREEN);
  2274. display.fillRect(0, 3 * h, display.width(), h, GxEPD_BLUE);
  2275. display.fillRect(0, 4 * h, display.width(), h, GxEPD_RED);
  2276. display.fillRect(0, 5 * h, display.width(), h, GxEPD_YELLOW);
  2277. display.fillRect(0, 6 * h, display.width(), h, GxEPD_ORANGE);
  2278. }
  2279. while (display.nextPage());
  2280. }
  2281. void draw7colorlines()
  2282. {
  2283. display.setRotation(0);
  2284. uint16_t h = 2;
  2285. display.firstPage();
  2286. do
  2287. {
  2288. uint16_t y = 0;
  2289. do
  2290. {
  2291. display.fillRect(0, y, display.width(), h, GxEPD_BLACK); y += h;
  2292. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  2293. display.fillRect(0, y, display.width(), h, GxEPD_GREEN); y += h;
  2294. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  2295. display.fillRect(0, y, display.width(), h, GxEPD_BLUE); y += h;
  2296. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  2297. display.fillRect(0, y, display.width(), h, GxEPD_RED); y += h;
  2298. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  2299. display.fillRect(0, y, display.width(), h, GxEPD_YELLOW); y += h;
  2300. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  2301. display.fillRect(0, y, display.width(), h, GxEPD_ORANGE); y += h;
  2302. display.fillRect(0, y, display.width(), h, GxEPD_WHITE); y += h;
  2303. }
  2304. while ((y + 12 * h) < uint16_t(display.height()));
  2305. //display.drawPixel(0, y, GxEPD_BLACK); display.drawPixel(10, y, GxEPD_GREEN);
  2306. //display.drawPixel(20, y, GxEPD_BLUE); display.drawPixel(30, y, GxEPD_RED);
  2307. //display.drawPixel(40, y, GxEPD_YELLOW); display.drawPixel(50, y, GxEPD_ORANGE);
  2308. display.fillRect(0, y, 2, 2, GxEPD_BLACK); display.fillRect(10, y, 2, 2, GxEPD_GREEN);
  2309. display.fillRect(20, y, 2, 2, GxEPD_BLUE); display.fillRect(30, y, 2, 2, GxEPD_RED);
  2310. display.fillRect(40, y, 2, 2, GxEPD_YELLOW); display.fillRect(50, y, 2, 2, GxEPD_ORANGE);
  2311. }
  2312. while (display.nextPage());
  2313. }
  2314. void drawGraphics()
  2315. {
  2316. display.setRotation(0);
  2317. display.firstPage();
  2318. do
  2319. {
  2320. display.drawRect(display.width() / 8, display.height() / 8, display.width() * 3 / 4, display.height() * 3 / 4, GxEPD_BLACK);
  2321. display.drawLine(display.width() / 8, display.height() / 8, display.width() * 7 / 8, display.height() * 7 / 8, GxEPD_BLACK);
  2322. display.drawLine(display.width() / 8, display.height() * 7 / 8, display.width() * 7 / 8, display.height() / 8, GxEPD_BLACK);
  2323. display.drawCircle(display.width() / 2, display.height() / 2, display.height() / 4, GxEPD_BLACK);
  2324. display.drawPixel(display.width() / 4, display.height() / 2 , GxEPD_BLACK);
  2325. display.drawPixel(display.width() * 3 / 4, display.height() / 2 , GxEPD_BLACK);
  2326. }
  2327. while (display.nextPage());
  2328. delay(1000);
  2329. }