From f3bddcbd51878a89570c660917f8831525e0f59f Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 29 May 2025 10:58:39 -1000 Subject: [PATCH] Add isBusy function Allows for better task/watchdog management for panels that take longer to update Signed-off-by: Jonas Schnelli --- src/bb_ep.inl | 12 ++++++++++++ src/bb_epaper.cpp | 4 ++++ src/bb_epaper.h | 1 + 3 files changed, 17 insertions(+) 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);