GxEPD2_Example.ino 54 KB

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