| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310 |
- // Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
- // Requires HW SPI and Adafruit_GFX. Caution: these e-papers require 3.3V supply AND data lines!
- //
- // Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
- //
- // Author: Jean-Marc Zingg
- //
- // Version: see library.properties
- //
- // Library: https://github.com/ZinggJM/GxEPD2
- // Supporting Arduino Forum Topics:
- // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
- // Good Dispay ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0
- // mapping suggestion from Waveshare SPI e-Paper to Wemos D1 mini
- // BUSY -> D2, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V
- // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case
- // mapping suggestion from Waveshare SPI e-Paper to generic ESP8266
- // BUSY -> GPIO4, RST -> GPIO2, DC -> GPIO0, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
- // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case
- // mapping of Waveshare e-Paper ESP8266 Driver Board
- // BUSY -> GPIO16, RST -> GPIO5, DC -> GPIO4, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
- // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case
- // mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board
- // NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD
- // BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V
- // new mapping suggestion for STM32F1, e.g. STM32F103C8T6 "BluePill"
- // BUSY -> A1, RST -> A2, DC -> A3, CS-> A4, CLK -> A5, DIN -> A7
- // mapping suggestion for AVR, UNO, NANO etc.
- // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11
- // mapping of Waveshare Universal e-Paper Raw Panel Driver Shield for Arduino / NUCLEO
- // BUSY -> 7, RST -> 8, DC -> 9, CS-> 10, CLK -> 13, DIN -> 11
- // mapping suggestion for Arduino MEGA
- // BUSY -> 7, RST -> 9, DC -> 8, CS-> 53, CLK -> 52, DIN -> 51
- // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
- // enable or disable GxEPD2_GFX base class
- #define ENABLE_GxEPD2_GFX 0
- #include <GxEPD2_BW.h>
- #include <GxEPD2_3C.h>
- #include <Fonts/FreeMonoBold9pt7b.h>
- #if defined (ESP8266)
- // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
- //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDE0213B1, phased out
- //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0213B72
- //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW0213I5F
- //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEW029T5
- //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- // can use only half buffer size
- //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- // 3-color e-papers
- //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- // can use only half buffer size
- //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- // can use only quarter buffer size
- //GxEPD2_3C < GxEPD2_583c, GxEPD2_583c::HEIGHT / 4 > display(GxEPD2_583c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
- // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
- // HRDY -> 4, RST -> 2, CS -> SS(15), SCK -> SCK(14), MOSI -> MOSI(D7(13)), MISO -> MISO(D6(12)), GND -> GND, 5V -> 5V
- // note: 5V supply needs to be exact and strong; 5V pin of USB powered Wemos D1 mini doesn't work!
- //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT / 8> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 0, /*RST=*/ 2, /*BUSY=*/ 4));
- // ***** for mapping of Waveshare e-Paper ESP8266 Driver Board *****
- // select one , can use full buffer size (full HEIGHT)
- //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16)); // GDE0213B1, phased out
- //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16)); // GDEH0213B72
- //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16)); // GDEW0213I5F
- //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16)); // GDEW029T5
- //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- // can use only half buffer size
- //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- // 3-color e-papers
- //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- // can use only half buffer size
- //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT / 2> display(GxEPD2_420c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- // can use only quarter buffer size
- //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT / 4> display(GxEPD2_583c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));
- #endif
- #if defined(ESP32)
- // select one and adapt to your mapping, can use full buffer size (full HEIGHT)
- //GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_BW<GxEPD2_213, GxEPD2_213::HEIGHT> display(GxEPD2_213(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDE0213B1, phased out
- //GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B72
- //GxEPD2_BW<GxEPD2_213_flex, GxEPD2_213_flex::HEIGHT> display(GxEPD2_213_flex(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW0213I5F
- //GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_BW<GxEPD2_290_T5, GxEPD2_290_T5::HEIGHT> display(GxEPD2_290_T5(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEW029T5
- //GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_BW<GxEPD2_583, GxEPD2_583::HEIGHT> display(GxEPD2_583(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_BW<GxEPD2_750, GxEPD2_750::HEIGHT> display(GxEPD2_750(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- // 3-color e-papers
- //GxEPD2_3C<GxEPD2_154c, GxEPD2_154c::HEIGHT> display(GxEPD2_154c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_3C<GxEPD2_213c, GxEPD2_213c::HEIGHT> display(GxEPD2_213c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_3C<GxEPD2_270c, GxEPD2_270c::HEIGHT> display(GxEPD2_270c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_3C<GxEPD2_420c, GxEPD2_420c::HEIGHT> display(GxEPD2_420c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_3C<GxEPD2_583c, GxEPD2_583c::HEIGHT> display(GxEPD2_583c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- //GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT> display(GxEPD2_750c(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- // grey levels parallel IF e-papers on Waveshare e-Paper IT8951 Driver HAT
- // HRDY -> 4, RST -> 16, CS -> SS(5), SCK -> SCK(18), MOSI -> MOSI(23), MISO -> MISO(19), GND -> GND, 5V -> 5V
- // note: 5V supply needs to be exact and strong; 5V over diode from USB (e.g. Wemos D1 mini) doesn't work!
- //GxEPD2_BW<GxEPD2_it60, GxEPD2_it60::HEIGHT> display(GxEPD2_it60(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4));
- #endif
- #if defined(_BOARD_GENERIC_STM32F103C_H_)
- #define MAX_DISPAY_BUFFER_SIZE 15000ul // ~15k is a good compromise
- #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPAY_BUFFER_SIZE / (EPD::WIDTH / 8))
- // select one and adapt to your mapping
- //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDE0213B1, phased out
- //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEH0213B72
- //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW0213I5F
- //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1)); // GDEW029T5
- //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- // 3-color e-papers
- #define MAX_HEIGHT_3C(EPD) (EPD::HEIGHT <= (MAX_DISPAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
- //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=4*/ SS, /*DC=*/ 3, /*RST=*/ 2, /*BUSY=*/ 1));
- #endif
- #if defined(__AVR)
- #define MAX_DISPAY_BUFFER_SIZE 800 //
- #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPAY_BUFFER_SIZE / (EPD::WIDTH / 8))
- // select one and adapt to your mapping
- //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDE0213B1, phased out
- //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEH0213B72
- //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW0213I5F
- //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7)); // GDEW029T5
- //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- // 3-color e-papers
- #define MAX_HEIGHT_3C(EPD) (EPD::HEIGHT <= (MAX_DISPAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
- //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));
- // ***** for mapping of Waveshare Universal e-Paper Raw Panel Driver Shield for Arduino / NUCLEO *****
- // the RST line is not connected through level converter, but has a pull up resistor and a pull down diode to the Arduino pin; this is safe for 5V Arduino
- // NOTE: the 11-pinholes for pin connectors are not through level converter, and the VCC pin is 5V, only FCP connector pins are through level converter
- // select one and adapt to your mapping
- //GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_213, MAX_HEIGHT(GxEPD2_213)> display(GxEPD2_213(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDE0213B1, phased out
- //GxEPD2_BW<GxEPD2_213_B72, MAX_HEIGHT(GxEPD2_213_B72)> display(GxEPD2_213_B72(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEH0213B72
- //GxEPD2_BW<GxEPD2_213_flex, MAX_HEIGHT(GxEPD2_213_flex)> display(GxEPD2_213_flex(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW0213I5F
- //GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_290_T5, MAX_HEIGHT(GxEPD2_290_T5)> display(GxEPD2_290_T5(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // GDEW029T5
- //GxEPD2_BW<GxEPD2_270, MAX_HEIGHT(GxEPD2_270)> display(GxEPD2_270(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_420, MAX_HEIGHT(GxEPD2_420)> display(GxEPD2_420(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_583, MAX_HEIGHT(GxEPD2_583)> display(GxEPD2_583(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_BW<GxEPD2_750, MAX_HEIGHT(GxEPD2_750)> display(GxEPD2_750(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- // 3-color e-papers
- #define MAX_HEIGHT_3C(EPD) (EPD::HEIGHT <= (MAX_DISPAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
- //GxEPD2_3C<GxEPD2_154c, MAX_HEIGHT_3C(GxEPD2_154c)> display(GxEPD2_154c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_213c, MAX_HEIGHT_3C(GxEPD2_213c)> display(GxEPD2_213c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_290c, MAX_HEIGHT_3C(GxEPD2_290c)> display(GxEPD2_290c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_270c, MAX_HEIGHT_3C(GxEPD2_270c)> display(GxEPD2_270c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_420c, MAX_HEIGHT_3C(GxEPD2_420c)> display(GxEPD2_420c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_583c, MAX_HEIGHT_3C(GxEPD2_583c)> display(GxEPD2_583c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- //GxEPD2_3C<GxEPD2_750c, MAX_HEIGHT_3C(GxEPD2_750c)> display(GxEPD2_750c(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));
- #endif
- #include "GxEPD2_boards_added.h"
- //#include "GxEPD2_more_boards_added.h" // private
- #if !defined(__AVR) && !defined(_BOARD_GENERIC_STM32F103C_H_)
- // comment out unused bitmaps to reduce code space used
- #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
- #include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
- #include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
- #include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
- #include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
- #include "bitmaps/Bitmaps400x300.h" // 4.2" b/w
- #include "bitmaps/Bitmaps640x384.h" // 7.5" b/w
- // 3-color
- #include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
- #include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
- #include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
- #include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
- #include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r
- #if defined(ESP8266) || defined(ESP32)
- #include "bitmaps/WS_Bitmaps800x600.h" // 6.0" grey
- #endif
- #else
- // select only one to fit in code space
- #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
- //#include "bitmaps/Bitmaps104x212.h" // 2.13" b/w flexible GDEW0213I5F
- //#include "bitmaps/Bitmaps128x250.h" // 2.13" b/w
- //#include "bitmaps/Bitmaps128x296.h" // 2.9" b/w
- //#include "bitmaps/Bitmaps176x264.h" // 2.7" b/w
- ////#include "bitmaps/Bitmaps400x300.h" // 4.2" b/w // not enough code space
- ////#include "bitmaps/Bitmaps640x384.h" // 7.5" b/w // not enough code space
- // 3-color
- //#include "bitmaps/Bitmaps3c200x200.h" // 1.54" b/w/r
- //#include "bitmaps/Bitmaps3c104x212.h" // 2.13" b/w/r
- //#include "bitmaps/Bitmaps3c128x296.h" // 2.9" b/w/r
- //#include "bitmaps/Bitmaps3c176x264.h" // 2.7" b/w/r
- ////#include "bitmaps/Bitmaps3c400x300.h" // 4.2" b/w/r // not enough code space
- #endif
- void setup()
- {
- Serial.begin(115200);
- Serial.println();
- Serial.println("setup");
- delay(100);
- display.init(115200);
- // first update should be full refresh
- helloWorld();
- delay(1000);
- // partial refresh mode can be used to full screen,
- // effective if display panel hasFastPartialUpdate
- helloFullScreenPartialMode();
- delay(1000);
- helloArduino();
- delay(1000);
- helloEpaper();
- delay(1000);
- //helloValue(123.9, 1);
- //delay(1000);
- showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
- delay(1000);
- drawBitmaps();
- if (display.epd2.hasPartialUpdate)
- {
- showPartialUpdate();
- delay(1000);
- } // else // on GDEW0154Z04 only full update available, doesn't look nice
- //drawCornerTest();
- //showBox(16, 16, 48, 32, false);
- //showBox(16, 56, 48, 32, true);
- display.powerOff();
- deepSleepTest();
- Serial.println("setup done");
- }
- void loop()
- {
- }
- // note for partial update window and setPartialWindow() method:
- // partial update window size and position is on byte boundary in physical x direction
- // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
- // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
- const char HelloWorld[] = "Hello World!";
- const char HelloArduino[] = "Hello Arduino!";
- const char HelloEpaper[] = "Hello E-Paper!";
- void helloWorld()
- {
- //Serial.println("helloWorld");
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(GxEPD_BLACK);
- int16_t tbx, tby; uint16_t tbw, tbh;
- display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
- // center bounding box by transposition of origin:
- uint16_t x = ((display.width() - tbw) / 2) - tbx;
- uint16_t y = ((display.height() - tbh) / 2) - tby;
- display.setFullWindow();
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(x, y);
- display.print(HelloWorld);
- }
- while (display.nextPage());
- //Serial.println("helloWorld done");
- }
- void helloWorldForDummies()
- {
- //Serial.println("helloWorld");
- const char text[] = "Hello World!";
- // most e-papers have width < height (portrait) as native orientation, especially the small ones
- // in GxEPD2 rotation 0 is used for native orientation (most TFT libraries use 0 fix for portrait orientation)
- // set rotation to 1 (rotate right 90 degrees) to have enough space on small displays (landscape)
- display.setRotation(1);
- // select a suitable font in Adafruit_GFX
- display.setFont(&FreeMonoBold9pt7b);
- // on e-papers black on white is more pleasant to read
- display.setTextColor(GxEPD_BLACK);
- // Adafruit_GFX has a handy method getTextBounds() to determine the boundary box for a text for the actual font
- int16_t tbx, tby; uint16_t tbw, tbh; // boundary box window
- display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh); // it works for origin 0, 0, fortunately (negative tby!)
- // center bounding box by transposition of origin:
- uint16_t x = ((display.width() - tbw) / 2) - tbx;
- uint16_t y = ((display.height() - tbh) / 2) - tby;
- // full window mode is the initial mode, set it anyway
- display.setFullWindow();
- // here we use paged drawing, even if the processor has enough RAM for full buffer
- // so this can be used with any supported processor board.
- // the cost in code overhead and execution time penalty is marginal
- // tell the graphics class to use paged drawing mode
- display.firstPage();
- do
- {
- // this part of code is executed multiple times, as many as needed,
- // in case of full buffer it is executed once
- // IMPORTANT: each iteration needs to draw the same, to avoid strange effects
- // use a copy of values that might change, don't read e.g. from analog or pins in the loop!
- display.fillScreen(GxEPD_WHITE); // set the background to white (fill the buffer with value for white)
- display.setCursor(x, y); // set the postition to start printing text
- display.print(text); // print some text
- // end of part executed multiple times
- }
- // tell the graphics class to transfer the buffer content (page) to the controller buffer
- // the graphics class will command the controller to refresh to the screen when the last page has been transferred
- // returns true if more pages need be drawn and transferred
- // returns false if the last page has been transferred and the screen refreshed for panels without fast partial update
- // returns false for panels with fast partial update when the controller buffer has been written once more, to make the differential buffers equal
- // (for full buffered with fast partial update the (full) buffer is just transferred again, and false returned)
- while (display.nextPage());
- //Serial.println("helloWorld done");
- }
- void helloFullScreenPartialMode()
- {
- //Serial.println("helloFullScreenPartialMode");
- const char fullscreen[] = "full screen update";
- const char fpm[] = "fast partial mode";
- const char spm[] = "slow partial mode";
- const char npm[] = "no partial mode";
- display.setPartialWindow(0, 0, display.width(), display.height());
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(GxEPD_BLACK);
- const char* updatemode;
- if (display.epd2.hasFastPartialUpdate)
- {
- updatemode = fpm;
- }
- else if (display.epd2.hasPartialUpdate)
- {
- updatemode = spm;
- }
- else
- {
- updatemode = npm;
- }
- // do this outside of the loop
- int16_t tbx, tby; uint16_t tbw, tbh;
- // center update text
- display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t utx = ((display.width() - tbw) / 2) - tbx;
- uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
- // center update mode
- display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t umx = ((display.width() - tbw) / 2) - tbx;
- uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
- // center HelloWorld
- display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
- uint16_t hwy = ((display.height() - tbh) / 2) - tby;
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(hwx, hwy);
- display.print(HelloWorld);
- display.setCursor(utx, uty);
- display.print(fullscreen);
- display.setCursor(umx, umy);
- display.print(updatemode);
- }
- while (display.nextPage());
- //Serial.println("helloFullScreenPartialMode done");
- }
- void helloArduino()
- {
- //Serial.println("helloArduino");
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
- int16_t tbx, tby; uint16_t tbw, tbh;
- // align with centered HelloWorld
- display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t x = ((display.width() - tbw) / 2) - tbx;
- // height might be different
- display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
- // make the window big enough to cover (overwrite) descenders of previous text
- uint16_t wh = FreeMonoBold9pt7b.yAdvance;
- uint16_t wy = (display.height() / 4) - wh / 2;
- display.setPartialWindow(0, wy, display.width(), wh);
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- //display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
- display.setCursor(x, y);
- display.print(HelloArduino);
- }
- while (display.nextPage());
- delay(1000);
- //Serial.println("helloArduino done");
- }
- void helloEpaper()
- {
- //Serial.println("helloEpaper");
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
- int16_t tbx, tby; uint16_t tbw, tbh;
- // align with centered HelloWorld
- display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t x = ((display.width() - tbw) / 2) - tbx;
- // height might be different
- display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
- // make the window big enough to cover (overwrite) descenders of previous text
- uint16_t wh = FreeMonoBold9pt7b.yAdvance;
- uint16_t wy = (display.height() * 3 / 4) - wh / 2;
- display.setPartialWindow(0, wy, display.width(), wh);
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(x, y);
- display.print(HelloEpaper);
- }
- while (display.nextPage());
- //Serial.println("helloEpaper done");
- }
- #if defined(ESP8266) || defined(ESP32)
- #include <StreamString.h>
- #define PrintString StreamString
- #else
- class PrintString : public Print, public String
- {
- public:
- size_t write(uint8_t data) override
- {
- return concat(char(data));
- };
- };
- #endif
- void helloValue(double v, int digits)
- {
- //Serial.println("helloValue");
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
- PrintString valueString;
- valueString.print(v, digits);
- int16_t tbx, tby; uint16_t tbw, tbh;
- display.getTextBounds(valueString, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t x = ((display.width() - tbw) / 2) - tbx;
- uint16_t y = (display.height() * 3 / 4) + tbh / 2; // y is base line!
- // show what happens, if we use the bounding box for partial window
- uint16_t wx = (display.width() - tbw) / 2;
- uint16_t wy = (display.height() * 3 / 4) - tbh / 2;
- display.setPartialWindow(wx, wy, tbw, tbh);
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(x, y);
- display.print(valueString);
- }
- while (display.nextPage());
- delay(2000);
- // make the partial window big enough to cover the previous text
- uint16_t ww = tbw; // remember window width
- display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
- // adjust, because HelloEpaper was aligned, not centered (could calculate this to be precise)
- ww = max(ww, uint16_t(tbw + 12)); // 12 seems ok
- wx = (display.width() - tbw) / 2;
- // make the window big enough to cover (overwrite) descenders of previous text
- uint16_t wh = FreeMonoBold9pt7b.yAdvance;
- wy = (display.height() * 3 / 4) - wh / 2;
- display.setPartialWindow(wx, wy, ww, wh);
- // alternately use the whole width for partial window
- //display.setPartialWindow(0, wy, display.width(), wh);
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(x, y);
- display.print(valueString);
- }
- while (display.nextPage());
- //Serial.println("helloValue done");
- }
- void deepSleepTest()
- {
- //Serial.println("deepSleepTest");
- const char hibernating[] = "hibernating ...";
- const char wokeup[] = "woke up";
- const char from[] = "from deep sleep";
- const char again[] = "again";
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(GxEPD_BLACK);
- int16_t tbx, tby; uint16_t tbw, tbh;
- // center text
- display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t x = ((display.width() - tbw) / 2) - tbx;
- uint16_t y = ((display.height() - tbh) / 2) - tby;
- display.setFullWindow();
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(x, y);
- display.print(hibernating);
- }
- while (display.nextPage());
- display.hibernate();
- delay(5000);
- display.getTextBounds(wokeup, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t wx = (display.width() - tbw) / 2;
- uint16_t wy = (display.height() / 3) + tbh / 2; // y is base line!
- display.getTextBounds(from, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t fx = (display.width() - tbw) / 2;
- uint16_t fy = (display.height() * 2 / 3) + tbh / 2; // y is base line!
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(wx, wy);
- display.print(wokeup);
- display.setCursor(fx, fy);
- display.print(from);
- }
- while (display.nextPage());
- delay(5000);
- display.getTextBounds(hibernating, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t hx = (display.width() - tbw) / 2;
- uint16_t hy = (display.height() / 3) + tbh / 2; // y is base line!
- display.getTextBounds(again, 0, 0, &tbx, &tby, &tbw, &tbh);
- uint16_t ax = (display.width() - tbw) / 2;
- uint16_t ay = (display.height() * 2 / 3) + tbh / 2; // y is base line!
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(hx, hy);
- display.print(hibernating);
- display.setCursor(ax, ay);
- display.print(again);
- }
- while (display.nextPage());
- display.hibernate();
- //Serial.println("deepSleepTest done");
- }
- void showBox(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial)
- {
- //Serial.println("showBox");
- display.setRotation(1);
- if (partial)
- {
- display.setPartialWindow(x, y, w, h);
- }
- else
- {
- display.setFullWindow();
- }
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.fillRect(x, y, w, h, GxEPD_BLACK);
- }
- while (display.nextPage());
- //Serial.println("showBox done");
- }
- void drawCornerTest()
- {
- display.setFullWindow();
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(GxEPD_BLACK);
- for (uint16_t r = 0; r <= 4; r++)
- {
- display.setRotation(r);
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.fillRect(0, 0, 8, 8, GxEPD_BLACK);
- display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK);
- display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK);
- display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK);
- display.setCursor(display.width() / 2, display.height() / 2);
- display.print(display.getRotation());
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- void showFont(const char name[], const GFXfont* f)
- {
- display.setFullWindow();
- display.setRotation(0);
- display.setTextColor(GxEPD_BLACK);
- display.firstPage();
- do
- {
- drawFont(name, f);
- }
- while (display.nextPage());
- }
- void drawFont(const char name[], const GFXfont* f)
- {
- //display.setRotation(0);
- display.fillScreen(GxEPD_WHITE);
- display.setTextColor(GxEPD_BLACK);
- display.setFont(f);
- display.setCursor(0, 0);
- display.println();
- display.println(name);
- display.println(" !\"#$%&'()*+,-./");
- display.println("0123456789:;<=>?");
- display.println("@ABCDEFGHIJKLMNO");
- display.println("PQRSTUVWXYZ[\\]^_");
- if (display.epd2.hasColor)
- {
- display.setTextColor(GxEPD_RED);
- }
- display.println("`abcdefghijklmno");
- display.println("pqrstuvwxyz{|}~ ");
- }
- // note for partial update window and setPartialWindow() method:
- // partial update window size and position is on byte boundary in physical x direction
- // the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
- // see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()
- // showPartialUpdate() purposely uses values that are not multiples of 8 to test this
- void showPartialUpdate()
- {
- // some useful background
- helloWorld();
- // use asymmetric values for test
- uint16_t box_x = 10;
- uint16_t box_y = 15;
- uint16_t box_w = 70;
- uint16_t box_h = 20;
- uint16_t cursor_y = box_y + box_h - 6;
- float value = 13.95;
- uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3;
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(GxEPD_BLACK);
- // show where the update box is
- for (uint16_t r = 0; r < 4; r++)
- {
- display.setRotation(r);
- display.setPartialWindow(box_x, box_y, box_w, box_h);
- display.firstPage();
- do
- {
- display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK);
- //display.fillScreen(GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- display.firstPage();
- do
- {
- display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
- }
- while (display.nextPage());
- delay(1000);
- }
- //return;
- // show updates in the update box
- for (uint16_t r = 0; r < 4; r++)
- {
- display.setRotation(r);
- display.setPartialWindow(box_x, box_y, box_w, box_h);
- for (uint16_t i = 1; i <= 10; i += incr)
- {
- display.firstPage();
- do
- {
- display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
- display.setCursor(box_x, cursor_y);
- display.print(value * i, 2);
- }
- while (display.nextPage());
- delay(500);
- }
- delay(1000);
- display.firstPage();
- do
- {
- display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
- }
- while (display.nextPage());
- delay(1000);
- }
- }
- void drawBitmaps()
- {
- display.setFullWindow();
- #ifdef _GxBitmaps104x212_H_
- drawBitmaps104x212();
- #endif
- #ifdef _GxBitmaps128x250_H_
- drawBitmaps128x250();
- #endif
- #ifdef _GxBitmaps128x296_H_
- drawBitmaps128x296();
- #endif
- #ifdef _GxBitmaps176x264_H_
- drawBitmaps176x264();
- #endif
- #ifdef _GxBitmaps400x300_H_
- drawBitmaps400x300();
- #endif
- #ifdef _GxBitmaps640x384_H_
- drawBitmaps640x384();
- #endif
- #ifdef _WS_Bitmaps800x600_H_
- drawBitmaps800x600();
- #endif
- // 3-color
- #ifdef _GxBitmaps3c104x212_H_
- drawBitmaps3c104x212();
- #endif
- #ifdef _GxBitmaps3c128x296_H_
- drawBitmaps3c128x296();
- #endif
- #ifdef _GxBitmaps3c176x264_H_
- drawBitmaps3c176x264();
- #endif
- #ifdef _GxBitmaps3c400x300_H_
- drawBitmaps3c400x300();
- #endif
- // show these after the specific bitmaps
- #ifdef _GxBitmaps200x200_H_
- drawBitmaps200x200();
- #endif
- // 3-color
- #ifdef _GxBitmaps3c200x200_H_
- drawBitmaps3c200x200();
- #endif
- }
- #ifdef _GxBitmaps200x200_H_
- void drawBitmaps200x200()
- {
- #if defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
- };
- #elif defined(_BOARD_GENERIC_STM32F103C_H_)
- const unsigned char* bitmaps[] =
- {
- logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200
- };
- #else
- const unsigned char* bitmaps[] =
- {
- logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200
- };
- #endif
- if (display.epd2.panel == GxEPD2::GDEP015OC1)
- {
- bool m = display.mirror(true);
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- display.mirror(m);
- }
- //else
- {
- bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
- display.clearScreen(); // use default for white
- int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
- int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
- delay(2000);
- }
- }
- bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1);
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- int16_t x = -60;
- int16_t y = -60;
- for (uint16_t j = 0; j < 10; j++)
- {
- display.writeScreenBuffer(); // use default for white
- display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
- display.refresh(true);
- if (display.epd2.hasFastPartialUpdate)
- {
- // for differential update: set previous buffer equal to current buffer in controller
- display.epd2.writeScreenBufferAgain(); // use default for white
- display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true);
- }
- delay(2000);
- x += 40;
- y += 40;
- if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
- }
- if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show
- break; // comment out for full show
- }
- display.writeScreenBuffer(); // use default for white
- display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true);
- display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true);
- display.refresh(true);
- delay(2000);
- }
- #endif
- #ifdef _GxBitmaps104x212_H_
- void drawBitmaps104x212()
- {
- #if !defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
- };
- #else
- const unsigned char* bitmaps[] =
- {
- WS_Bitmap104x212, Bitmap104x212_1, Bitmap104x212_2, Bitmap104x212_3
- };
- #endif
- if (display.epd2.panel == GxEPD2::GDEW0213I5F)
- {
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _GxBitmaps128x250_H_
- void drawBitmaps128x250()
- {
- #if !defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
- };
- #else
- const unsigned char* bitmaps[] =
- {
- Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250
- };
- #endif
- if ((display.epd2.panel == GxEPD2::GDE0213B1) || (display.epd2.panel == GxEPD2::GDEH0213B72))
- {
- bool m = display.mirror(true);
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- display.mirror(m);
- }
- }
- #endif
- #ifdef _GxBitmaps128x296_H_
- void drawBitmaps128x296()
- {
- #if !defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296
- };
- #else
- const unsigned char* bitmaps[] =
- {
- Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296
- };
- #endif
- if (display.epd2.panel == GxEPD2::GDEH029A1)
- {
- bool m = display.mirror(true);
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- display.mirror(m);
- }
- }
- #endif
- #ifdef _GxBitmaps176x264_H_
- void drawBitmaps176x264()
- {
- #if !defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- Bitmap176x264_1, Bitmap176x264_2, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
- };
- #else
- const unsigned char* bitmaps[] =
- {
- Bitmap176x264_1, Bitmap176x264_2 //, Bitmap176x264_3, Bitmap176x264_4, Bitmap176x264_5
- };
- #endif
- if (display.epd2.panel == GxEPD2::GDEW027W3)
- {
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _GxBitmaps400x300_H_
- void drawBitmaps400x300()
- {
- #if !defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- Bitmap400x300_1, Bitmap400x300_2
- };
- #else
- const unsigned char* bitmaps[] = {}; // not enough code space
- #endif
- if (display.epd2.panel == GxEPD2::GDEW042T2)
- {
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _GxBitmaps640x384_H_
- void drawBitmaps640x384()
- {
- #if !defined(__AVR)
- const unsigned char* bitmaps[] =
- {
- Bitmap640x384_1, Bitmap640x384_2
- };
- #else
- const unsigned char* bitmaps[] = {}; // not enough code space
- #endif
- if ((display.epd2.panel == GxEPD2::GDEW075T8) || (display.epd2.panel == GxEPD2::GDEW075Z09))
- {
- for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _WS_Bitmaps800x600_H_
- void drawBitmaps800x600()
- {
- #if defined(ESP8266) || defined(ESP32)
- if (display.epd2.panel == GxEPD2::ED060SCT)
- {
- // Serial.print("sizeof(WS_zoo_800x600) is "); Serial.println(sizeof(WS_zoo_800x600));
- display.drawNative(WS_zoo_800x600, 0, 0, 0, 800, 600, false, false, true);
- delay(2000);
- // Serial.print("sizeof(WS_pic_1200x825) is "); Serial.println(sizeof(WS_pic_1200x825));
- // display.drawNative((const uint8_t*)WS_pic_1200x825, 0, 0, 0, 1200, 825, false, false, true);
- // delay(2000);
- // Serial.print("sizeof(WS_acaa_1024x731) is "); Serial.println(sizeof(WS_acaa_1024x731));
- // display.drawNative(WS_acaa_1024x731, 0, 0, 0, 1024, 731, false, false, true);
- // delay(2000);
- }
- #endif
- }
- #endif
- struct bitmap_pair
- {
- const unsigned char* black;
- const unsigned char* red;
- };
- #ifdef _GxBitmaps3c200x200_H_
- void drawBitmaps3c200x200()
- {
- bitmap_pair bitmap_pairs[] =
- {
- //{Bitmap3c200x200_black, Bitmap3c200x200_red},
- {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red}
- };
- if (display.epd2.panel == GxEPD2::GDEW0154Z04)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- // Bitmap3c200x200_black has 2 bits per pixel
- // taken from Adafruit_GFX.cpp, modified
- int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte
- uint8_t byte = 0;
- for (int16_t j = 0; j < display.epd2.HEIGHT; j++)
- {
- for (int16_t i = 0; i < display.epd2.WIDTH; i++)
- {
- if (i & 3) byte <<= 2;
- else
- {
- #if defined(__AVR) || defined(ESP8266) || defined(ESP32)
- byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]);
- #else
- byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4];
- #endif
- }
- if (!(byte & 0x80))
- {
- display.drawPixel(i, j, GxEPD_BLACK);
- }
- }
- }
- display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- while (display.nextPage());
- delay(2000);
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- if (display.epd2.hasColor)
- {
- display.clearScreen(); // use default for white
- int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2;
- int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2;
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
- delay(2000);
- }
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- int16_t x = -60;
- int16_t y = -60;
- for (uint16_t j = 0; j < 10; j++)
- {
- display.writeScreenBuffer(); // use default for white
- display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true);
- display.refresh();
- delay(1000);
- x += 40;
- y += 40;
- if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break;
- }
- }
- display.writeScreenBuffer(); // use default for white
- display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true);
- 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);
- display.refresh();
- delay(2000);
- }
- }
- #endif
- #ifdef _GxBitmaps3c104x212_H_
- void drawBitmaps3c104x212()
- {
- #if !defined(__AVR)
- bitmap_pair bitmap_pairs[] =
- {
- {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
- {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
- {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
- };
- #else
- bitmap_pair bitmap_pairs[] =
- {
- {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red},
- //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red},
- {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red}
- };
- #endif
- if (display.epd2.panel == GxEPD2::GDEW0213Z16)
- {
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red)
- {
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _GxBitmaps3c128x296_H_
- void drawBitmaps3c128x296()
- {
- #if !defined(__AVR)
- bitmap_pair bitmap_pairs[] =
- {
- {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
- {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
- {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
- };
- #else
- bitmap_pair bitmap_pairs[] =
- {
- //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red},
- //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red},
- {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red}
- };
- #endif
- if (display.epd2.panel == GxEPD2::GDEW029Z10)
- {
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red)
- {
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _GxBitmaps3c176x264_H_
- void drawBitmaps3c176x264()
- {
- bitmap_pair bitmap_pairs[] =
- {
- {Bitmap3c176x264_black, Bitmap3c176x264_red}
- };
- if (display.epd2.panel == GxEPD2::GDEW027C44)
- {
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
- #ifdef _GxBitmaps3c400x300_H_
- void drawBitmaps3c400x300()
- {
- #if !defined(__AVR)
- bitmap_pair bitmap_pairs[] =
- {
- {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red},
- {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red},
- {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red}
- };
- #else
- bitmap_pair bitmap_pairs[] = {}; // not enough code space
- #endif
- if (display.epd2.panel == GxEPD2::GDEW042Z15)
- {
- for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++)
- {
- display.firstPage();
- do
- {
- display.fillScreen(GxEPD_WHITE);
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
- display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED);
- }
- while (display.nextPage());
- delay(2000);
- }
- }
- }
- #endif
|