Skip to content

fix: improve sleep screen performance & fix sleep screen blank on Sleep Screen Cover Mode - #139

Open
kinland wants to merge 8 commits into
franssjz:masterfrom
kinland:fix/sleep-screen
Open

kinland wants to merge 8 commits into
franssjz:masterfrom
kinland:fix/sleep-screen

Conversation

@kinland

@kinland kinland commented Jul 8, 2026

Copy link
Copy Markdown

Summary

  • What is the goal of this PR?
    I was having two problems on my X3 that this branch addresses:
    • going to sleep took a VERY long time. About 25 seconds before the sleep image showed up, and another 45 seconds after that before the power button would respond to wake it back up
    • when Sleep Screen Cover Mode was set to crop, the sleep screen was blank (bug Sleep screen 'Cover + Custom' broken in recent builds #15 )
  • What changes are included?

Additional Context

The crop fix: Sleep screen cover crop mode skipped every row for standard bottom-up BMPs because crop bounds and screen Y were computed from file row index instead of image row-from-top. Now uses crop bottom-up BMPs using row-from-top mapping


AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? YES

kinland added 4 commits July 7, 2026 18:29
Custom sleep images with greyscale could take ~60s because drawBitmap ran for the BW compose and again for each grey plane. Stream LSB/MSB strips during a single SD read and add SleepActivity phase logging to diagnose sleep entry.
When a custom sleep image exceeds the screen, sample from the output grid instead of walking every source pixel. Keeps the single-pass grey decode and deferred strip flush.
Large custom/cover greyscale BMPs OOM when LSB/MSB strips from
drawGreyscaleBitmapForSleep are batched in RAM. Add ISleepGreyStripSink
and SleepGreyscaleStreamWriter to write strips to /.crosspoint/sleep_cache
({hash}.raw, .lsb.raw, .msb.raw) as the BMP is decoded, then flush them
back in bounded 80-row reads for the grey e-ink refresh. Add loadGreyscale
and cache-hit paths for cover, custom, and stats sleep screens so repeat
sleeps skip the ~20s decode. Keep SleepGreyStripBatch as a memory fallback
only when no source path is available.
Sleep screen cover crop mode skipped every row for standard bottom-up BMPs because crop bounds and screen Y were computed from file row index instead of image row-from-top.
@kinland kinland mentioned this pull request Jul 8, 2026
@kinland kinland changed the title improve sleep screen performance & fix sleep screen blank on Sleep Screen Cover Mode fix: improve sleep screen performance & fix sleep screen blank on Sleep Screen Cover Mode Jul 8, 2026
@kinland

kinland commented Jul 21, 2026

Copy link
Copy Markdown
Author

Worth noting (as I did on the clock PR) that I've gone through at least 100 sleep cycles with the improvements in the PR and not noticed any new issues, battery drain, etc.

@kinland

kinland commented Jul 25, 2026

Copy link
Copy Markdown
Author

Would it help get this merged if I split this into smaller PRs instead of one 760 line PR?

  1. PR 1 (~270 lines): decode grayscale sleep BMP once instead of three passes
  2. PR 2 (~110 lines): downscale oversized sleep BMP
  3. PR 3: (~425 lines): sleep grayscale cache
  4. PR 4: (~25 lines): fix X3 sleep image cover crop blank

@kinland
kinland force-pushed the fix/sleep-screen branch from affdd5f to 37f9986 Compare July 29, 2026 00:38
kinland added 4 commits July 28, 2026 17:45
Loading grey planes before displayGrayscaleBase set lsbValid and forced a clean-base path that wiped controller RAM, so cache hits skipped greyscale entirely.
Avoid allocating a full ~52KB grey plane on cache hit; read LSB/MSB from SD in bounded strips and write them with writeGrayscalePlaneStrip after the BW base refresh.
Forward-only strip flushing dropped grey pixels when phyY decreased under Portrait, leaving only the left ~9% band. Accumulate full planes when RAM allows, otherwise reload strips in any order, and bump the sleep cache format version.
Dual-plane stream encode needed ~104KB contiguous RAM, routinely OOMed, aborted partial cache writes, and forced a slow cold overlay every sleep. Snapshot BW/LSB/MSB from the overlay path instead so sleep_cache populates and later sleeps can hit the strip apply path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant