GxEPD2_Example.ino 62 KB

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