GxEPD2_Example.ino 61 KB

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