diff --git a/src/bb_ep.inl b/src/bb_ep.inl index 6385650..9dd6fb0 100644 --- a/src/bb_ep.inl +++ b/src/bb_ep.inl @@ -1617,6 +1617,18 @@ void bbepWaitBusy(BBEPDISP *pBBEP) } } /* bbepWaitBusy() */ // +// Return if panel is busy +// +bool bbepIsBusy(BBEPDISP *pBBEP) +{ + if (!pBBEP) return false; + if (pBBEP->iBUSYPin == 0xff) return false; + delay(10); // give time for the busy status to be valid + uint8_t busy_idle = (pBBEP->chip_type == BBEP_CHIP_UC81xx) ? HIGH : LOW; + delay(1); // some panels need a short delay before testing the BUSY line + return (digitalRead(pBBEP->iBUSYPin) != busy_idle); +} /* bbepWaitBusy() */ +// // Toggle the reset line to wake up the eink from deep sleep // void bbepWakeUp(BBEPDISP *pBBEP) diff --git a/src/bb_epaper.cpp b/src/bb_epaper.cpp index 43c26a6..24aed51 100644 --- a/src/bb_epaper.cpp +++ b/src/bb_epaper.cpp @@ -517,6 +517,10 @@ void BBEPAPER::wait(bool bQuick) { bbepWaitBusy(&_bbep); } +bool BBEPAPER::isBusy(void) +{ + return bbepIsBusy(&_bbep); +} void BBEPAPER::drawString(const char *pText, int x, int y) { if (_bbep.pFont) { diff --git a/src/bb_epaper.h b/src/bb_epaper.h index 626067b..bcb83ed 100644 --- a/src/bb_epaper.h +++ b/src/bb_epaper.h @@ -474,6 +474,7 @@ class BBEPAPER void stretchAndSmooth(uint8_t *pSrc, uint8_t *pDest, int w, int h, int iSmoothType); void sleep(int bDeep); void wait(bool bQuick = false); + bool isBusy(void); void drawString(const char *pText, int x, int y); void setPlane(int iPlane); int getPlane(void);