# Implement Letterbox Edge Row Copy for MATCHED Mode ## Task Implement the "FrameBuffer Edge Row Copy" plan for the MATCHED letterbox fill mode. Instead of computing letterbox colors from sampled edge data, the new approach copies the cover's rendered edge row directly from the frameBuffer into the letterbox area after each `drawBitmap` call. ## Changes Made ### `src/activities/boot_sleep/SleepActivity.cpp` - **Added `#include `** for `memcpy` usage. - **Added `copyEdgeRowsToLetterbox()` helper** (anonymous namespace): Copies physical columns (horizontal letterbox) or physical rows (vertical letterbox) in the frameBuffer. For horizontal letterbox, iterates per-bit across 480 physical rows. For vertical letterbox, uses `memcpy` of 100-byte physical rows. - **Updated `renderBitmapSleepScreen()`**: - Added `scaledWidth`/`scaledHeight` computation matching `drawBitmap`'s floor logic. - Added `isMatched` flag. - MATCHED mode now skips edge sampling entirely (`sampleBitmapEdges` / cache load). - After each `drawBitmap` call (BW, LSB, MSB passes), calls `copyEdgeRowsToLetterbox` for MATCHED mode. - **Cleaned up dead code**: - Removed the entire MATCHED case from `drawLetterboxFill()` (no longer called for MATCHED). - Removed `grayToVal2bit` helper (was only used by the removed MATCHED case). - Removed `skipFillInGreyscale` flag (no longer needed — the edge copy participates in all passes naturally). ## Build Successfully compiled with `pio run` (0 errors, 0 warnings relevant to changes). ## Follow-up - Needs on-device testing to verify: 1. The letterbox blends seamlessly with the cover edge (pixel-perfect 1:1 match). 2. No scan coupling corruption (the scattered pixel distribution from dithering should cause less coupling than uniform blocks). 3. If corruption is still unacceptable, the fallback is the previous flat-fill + greyscale-skip approach (revert this change).