From dd16c1dc5544584ab2793e0045f322462aa196a8 Mon Sep 17 00:00:00 2001 From: Laurence Bank Date: Sat, 29 Mar 2025 20:04:20 +0000 Subject: [PATCH] Fixed full update and added more comments --- examples/CO2_EPD_Clock/CO2_EPD_Clock.ino | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/CO2_EPD_Clock/CO2_EPD_Clock.ino b/examples/CO2_EPD_Clock/CO2_EPD_Clock.ino index 5fae32c..38c29e9 100644 --- a/examples/CO2_EPD_Clock/CO2_EPD_Clock.ino +++ b/examples/CO2_EPD_Clock/CO2_EPD_Clock.ino @@ -94,7 +94,14 @@ void setup() { } else { // can't find the sensor, stop } // no sensor connected or some error rtc.getTime(&myTime); // see if the clock is set - if (myTime.tm_hour == 0 && myTime.tm_min == 0) { // time is not set, give it a time/date + // If the time is not set, give it a time/date + // This can obviously be improved with a way to get user input + // to set/correct the time. I like to use temperature compensated RTCs + // like the DS3231 and RV3032. Both will only drift by a few seconds after + // a few months of continuous usage. Lower cost RTCs like the BM8563 can drift + // several seconds per day and should not be relied upon to keep accurate time for + // long periods. + if (myTime.tm_hour == 0 && myTime.tm_min == 0) { myTime.tm_sec = 0; myTime.tm_hour = 19; myTime.tm_min = 10; @@ -120,9 +127,14 @@ int iCount = 0; delay(60000); // update once a minute epd.backupPlane(); // copy last data to "old plane" ShowInfo(0); // update plane 0 (with new data) - epd.writePlane(PLANE_BOTH); // UC8151 needs both planes written to do partial updates - // Do 15 partial (non-flashing) updates followed by a full update to remove ghosting - epd.refresh(((iCount & 15) == 0) ? REFRESH_FULL : REFRESH_PARTIAL); + if ((iCount & 15) == 0) { // do a full refresh + epd.writePlane(PLANE_DUPLICATE); + epd.refresh(REFRESH_FULL); + } else { // partial refresh + epd.writePlane(PLANE_BOTH); // UC8151 needs both planes written to do partial updates + // Do 15 partial (non-flashing) updates followed by a full update to remove ghosting + epd.refresh(REFRESH_PARTIAL); + } epd.wait(); epd.sleep(LIGHT_SLEEP); // extends the life of the panel to sleep it between updates iCount++;