Skip to content

feat(SDL): add screenshot function with file-based output#39

Open
al-munazzim wants to merge 1 commit intodiybitcoinhardware:micropython-upgradefrom
al-munazzim:kn/sdl-screenshot
Open

feat(SDL): add screenshot function with file-based output#39
al-munazzim wants to merge 1 commit intodiybitcoinhardware:micropython-upgradefrom
al-munazzim:kn/sdl-screenshot

Conversation

@al-munazzim
Copy link
Copy Markdown

Summary

  • Adds screenshot(filename) function to the SDL module that captures the current display and writes raw RGB565 data to a file
  • Uses chunked processing (32 rows at a time) to minimize memory usage, bypassing the MicroPython heap entirely
  • Returns a (width, height, filename) tuple on success

Details

Uses SDL_RenderReadPixels to capture the renderer content, converts RGBA8888 to RGB565 in chunks, and writes directly to file via fopen/fwrite. This avoids large heap allocations that would be problematic in MicroPython.

Test plan

  • Build the SDL simulator target and verify compilation
  • Call SDL.screenshot("/tmp/test.raw") from MicroPython and verify the output file contains valid RGB565 data
  • Verify returned tuple contains correct dimensions

🤖 Generated with Claude Code

Writes RGB565 directly to file in 32-row chunks, bypassing MicroPython heap.
Solves memory allocation failures for large buffers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants