GxEPD2_Example.ino 53 KB

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