From 23ef2a64cc8a3ea4ff9e8a2e4bffa96e8f4d4833 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Mon, 18 Mar 2024 17:17:04 +0100 Subject: [PATCH] Add "storage mode" to protect EPDs (lowest button while booting) --- src/lib/config.cpp | 10 ++++++++++ src/lib/epd.cpp | 21 ++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/lib/config.cpp b/src/lib/config.cpp index 8f18a84..98911e4 100644 --- a/src/lib/config.cpp +++ b/src/lib/config.cpp @@ -31,6 +31,16 @@ void setup() } } + { + if (mcp1.digitalRead(0) == LOW) + { + // Then loop forever to prevent anything else from writing to the screen + while (true) { + delay(1000); + } + } + } + tryImprovSetup(); setupWebserver(); diff --git a/src/lib/epd.cpp b/src/lib/epd.cpp index 92d13d3..d4d579b 100644 --- a/src/lib/epd.cpp +++ b/src/lib/epd.cpp @@ -155,7 +155,19 @@ void setupDisplays() 11, &tasks[i]); // create task } - epdContent = {"B", "T", "C", "L", "O", "C", "K"}; + // Hold lower button to enable "storage mode" (prevents burn-in of ePaper displays) + if (mcp1.digitalRead(0) == LOW) + { + setFgColor(GxEPD_BLACK); + setBgColor(GxEPD_WHITE); + + epdContent = {" ", " ", " ", " ", " ", " ", " "}; + } + else + { + + epdContent = {"B", "T", "C", "L", "O", "C", "K"}; + } setEpdContent(epdContent); } @@ -244,10 +256,9 @@ void prepareDisplayUpdateTask(void *pvParameters) } else { - + showDigit(epdIndex, epdContent[epdIndex].c_str()[0], updatePartial, &FONT_BIG); - } } @@ -402,9 +413,9 @@ void showDigit(const uint dispNum, char chr, bool partial, displays[dispNum].setCursor(x, y); displays[dispNum].print(str); - if (chr == '.') + if (chr == '.') { - displays[dispNum].fillRect(x,y,displays[dispNum].width(),round(displays[dispNum].height() * 0.9), getBgColor()); + displays[dispNum].fillRect(x, y, displays[dispNum].width(), round(displays[dispNum].height() * 0.9), getBgColor()); } // displays[dispNum].setCursor(10, 3);