GxEPD2_Example.ino 61 KB

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