diff --git a/src/bb_ep.inl b/src/bb_ep.inl index 88e811a..e4b6a95 100644 --- a/src/bb_ep.inl +++ b/src/bb_ep.inl @@ -1081,6 +1081,20 @@ int bbepSetPanelType(BBEPDISP *pBBEP, int iPanel) return BBEP_SUCCESS; } /* bbepSetPanelType() */ +int bbepCreateVirtual(BBEPDISP *pBBEP, int iWidth, int iHeight, int iFlags) +{ + if (pBBEP) { + memset(pBBEP, 0, sizeof(BBEPDISP)); + pBBEP->native_width = pBBEP->width = iWidth; + pBBEP->native_height = pBBEP->height = iHeight; + pBBEP->iFlags = iFlags; + pBBEP->chip_type = BBEP_CHIP_NONE; + return BBEP_SUCCESS; + } else { + return BBEP_ERROR_BAD_PARAMETER; + } +} + // // Toggle the reset line to wake up the eink from deep sleep // diff --git a/src/bb_epaper.cpp b/src/bb_epaper.cpp index 4cef9ca..e93af6c 100644 --- a/src/bb_epaper.cpp +++ b/src/bb_epaper.cpp @@ -105,7 +105,13 @@ int BBEPAPER::refresh(int iMode, bool bWait) //{ // _bbep.iFlags = iFlags; //} - +// +// Create a RAM-only virtual display +// +int BBEPAPER::createVirtual(int iWidth, int iHeight, int iFlags) +{ + return bbepCreateVirtual(&_bbep, iWidth, iHeight, iFlags); +} void BBEPAPER::setBuffer(uint8_t *pBuffer) { _bbep.ucScreen = pBuffer; diff --git a/src/bb_epaper.h b/src/bb_epaper.h index 5f49532..c99b769 100644 --- a/src/bb_epaper.h +++ b/src/bb_epaper.h @@ -58,6 +58,7 @@ enum { BBEP_CHIP_NOT_DEFINED = 0, BBEP_CHIP_SSD16xx, BBEP_CHIP_UC81xx, + BBEP_CHIP_NONE, // for virtual display BBEP_CHIP_COUNT }; @@ -285,6 +286,7 @@ class BBEPAPER { public: BBEPAPER(int iPanel); + int createVirtual(int iWidth, int iHeight, int iFlags); void setAddrWindow(int x, int y, int w, int h); #ifdef ARDUINO void initIO(int iDC, int iReset, int iBusy, int iCS = SS, int iMOSI = MOSI, int iSCLK = SCK, uint32_t u32Speed = 8000000);