From 21871179bd7e109f07058be1d43ba15f30744ceb Mon Sep 17 00:00:00 2001 From: Matt Edholm Date: Wed, 6 May 2026 13:49:08 -0400 Subject: [PATCH] feat: thinner border (4 px) and serial logging on border / recovery events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BORDER_THICKNESS_PX: 16 -> 4. Hardware-tested at 4 px on both yellow and red; yellow appears slightly thicker due to the irradiation illusion (perception, not a rendering issue) — not compensating per color absent an explicit request. - Add Serial.println at every state transition that touches the err_border lifecycle: schema migration firing, sync-fail else branch (with HTTP code, distinguishing border vs full-fill fallback), 304 recovery (with which flags triggered it), and recovery completion / abort. Lets us trace why a frame is or isn't showing a border via pio device monitor without needing to instrument anew each time. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/config.h | 2 +- src/operation.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config.h b/src/config.h index a0516a9..8b92a8f 100644 --- a/src/config.h +++ b/src/config.h @@ -38,7 +38,7 @@ #define NVS_SCHEMA_VERSION 1 // Width of the sync-fail / no-WiFi border, in pixels. -#define BORDER_THICKNESS_PX 16 +#define BORDER_THICKNESS_PX 4 // ── Network ────────────────────────────────────────────────────────────────── #define APP_BASE_URL "https://pictureframe.edholm.me" diff --git a/src/operation.h b/src/operation.h index 1e583ce..da507b0 100644 --- a/src/operation.h +++ b/src/operation.h @@ -77,6 +77,8 @@ void normal_operation_impl(const String& mac, HTTP& http, const String& url, Pre // by treating this boot as if errBorder were set, then bump schema_v so // it doesn't fire again. if (schemaV < NVS_SCHEMA_VERSION) { + Serial.println(String("[op] schema migration v") + String(schemaV) + " -> v" + + String(NVS_SCHEMA_VERSION) + ", forcing one-shot recovery redraw"); errBorder = true; prefs.begin(NVS_NAMESPACE, false); prefs.putInt(NVS_KEY_SCHEMA_V, NVS_SCHEMA_VERSION); @@ -135,6 +137,9 @@ void normal_operation_impl(const String& mac, HTTP& http, const String& url, Pre // (drawNeeded), or a sync-fail border is currently on screen and the // server is healthy again (errBorder) — repaint clean to clear it. if (drawNeeded || errBorder) { + Serial.println(String("[op] 304 with recovery flags (drawNeeded=") + + String((int)drawNeeded) + " errBorder=" + + String((int)errBorder) + ") -> repainting clean from /img.bin"); File r = LittleFS.open(IMAGE_PATH, "r"); if (r) { displayInitialized = true; @@ -145,6 +150,9 @@ void normal_operation_impl(const String& mac, HTTP& http, const String& url, Pre prefs.putInt(NVS_KEY_DRAW_NEEDED, 0); prefs.putInt(NVS_KEY_ERR_BORDER, 0); prefs.end(); + Serial.println("[op] recovery redraw complete; flags cleared"); + } else { + Serial.println("[op] recovery aborted: /img.bin not in LittleFS"); } } } else if (code == 204) { @@ -167,9 +175,13 @@ void normal_operation_impl(const String& mac, HTTP& http, const String& url, Pre epd_init(); File r = LittleFS.open(IMAGE_PATH, "r"); if (r) { + Serial.println(String("[op] sync fail code=") + String(code) + + " -> drawing image with yellow border"); epd_draw_image_with_border(r, COLOR_YELLOW, BORDER_THICKNESS_PX); r.close(); } else { + Serial.println(String("[op] sync fail code=") + String(code) + + " -> no cached image, falling back to full yellow fill"); epd_fill(COLOR_YELLOW); } prefs.begin(NVS_NAMESPACE, false);