From 127205de2e4acdc62e1fdb35a1be65eb96ccfe5a Mon Sep 17 00:00:00 2001 From: cottongin Date: Mon, 3 Aug 2026 11:31:36 -0400 Subject: [PATCH] fix: suppress all e-ink refreshes during boot with setAutoDisplay(false) Co-authored-by: Cursor --- src/display_manager.cpp | 15 ++++++++++++--- src/main.cpp | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/display_manager.cpp b/src/display_manager.cpp index 4062699..8ffdc69 100644 --- a/src/display_manager.cpp +++ b/src/display_manager.cpp @@ -16,6 +16,9 @@ void DisplayManager::begin(PowerManager& power) { _power = &power; _display = &M5.Display; + // Ensure no automatic e-ink refreshes happen + _display->setAutoDisplay(false); + // Set rotation for landscape (device physically rotated) _display->setRotation(3); @@ -26,10 +29,11 @@ void DisplayManager::begin(PowerManager& power) { void DisplayManager::showSetupScreen() { _power->enableEPDPower(); + // Batch all drawing — nothing hits the panel until display() at the end + _display->startWrite(); _display->fillScreen(TFT_WHITE); // Generate QR code for WiFi auto-connect - // Format: WIFI:T:nopass;S:PaperColor-Setup;; const char* qrData = "WIFI:T:nopass;S:PaperColor-Setup;;"; QRCode qrcode; uint8_t qrcodeData[qrcode_getBufferSize(6)]; @@ -37,7 +41,7 @@ void DisplayManager::showSetupScreen() { // Draw QR code centered vertically, left-of-center horizontally int qrSize = qrcode.size; - int scale = 4; // pixels per QR module + int scale = 4; int qrPixels = qrSize * scale; int qrX = (DISPLAY_WIDTH / 3) - (qrPixels / 2); int qrY = (DISPLAY_HEIGHT - qrPixels) / 2; @@ -49,7 +53,7 @@ void DisplayManager::showSetupScreen() { } } - // Draw text instructions to the right of QR code + // Text instructions to the right of QR code int textX = DISPLAY_WIDTH / 2 + 40; _display->setTextColor(TFT_BLACK); _display->setTextDatum(middle_left); @@ -64,6 +68,9 @@ void DisplayManager::showSetupScreen() { _display->drawString("Then open:", textX, DISPLAY_HEIGHT / 2 + 70); _display->drawString("192.168.4.1", textX, DISPLAY_HEIGHT / 2 + 95); + _display->endWrite(); + + // Single e-ink refresh — the only panel update during boot triggerRefresh(); _power->disableEPDPower(); } @@ -100,6 +107,7 @@ void DisplayManager::showImage(const ProcessedImage& img) { void DisplayManager::showMessage(const char* title, const char* body) { _power->enableEPDPower(); + _display->startWrite(); _display->fillScreen(TFT_WHITE); _display->setTextColor(TFT_BLACK); _display->setTextDatum(middle_center); @@ -107,6 +115,7 @@ void DisplayManager::showMessage(const char* title, const char* body) { _display->drawString(title, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2 - 30); _display->setTextSize(1); _display->drawString(body, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2 + 20); + _display->endWrite(); triggerRefresh(); _power->disableEPDPower(); diff --git a/src/main.cpp b/src/main.cpp index dfe5b88..17e10d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -173,8 +173,12 @@ void webActionCallback(const String& action) { void setup() { auto cfg = M5.config(); + cfg.clear_display = false; // Don't clear/refresh e-ink on init M5.begin(cfg); + // Prevent any automatic e-ink refreshes until we explicitly call display() + M5.Display.setAutoDisplay(false); + Serial.begin(115200); Serial.println("[main] Immich Frame v1.0 booting...");