GxEPD2_Example.ino 50 KB

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