Add menu screen REST API#703
Open
chrisgleissner wants to merge 7 commits into
Open
Conversation
…kground colors. Enhance tests.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds the ability to fetch and render the firmware menu screen as a binary “screen matrix” snapshot over the REST API, along with tooling and a PC-side test to validate the snapshot contract.
Changes:
- Introduces
GET /v1/machine:menu_screenreturning a fixed-size 40x25x2 matrix payload (chars + colour/attribute plane). - Extends the UI/screen implementation to support copying a stable “active screen matrix” snapshot.
- Adds developer tools (renderer + on-device contract/soak checker) and a PC build target/test for the snapshot logic.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/api/menu_screen_tool.py | New CLI tool to fetch and render menu_screen as ANSI output. |
| tools/api/menu_screen_test.py | New integration/soak test tool that validates API contract/auth/unavailable states. |
| target/pc/linux/screensnapshottest/Makefile | New PC target to build/run the screen snapshot unit test. |
| software/userinterface/userinterface.h | Adds constants and API for copying the active screen matrix. |
| software/userinterface/userinterface.cc | Implements active UI screen snapshot copy with safety checks. |
| software/test/user_interface/src/screen_snapshot_test.cc | Adds a focused test for Screen_MemMappedCharMatrix::copy_matrix. |
| software/io/c64/screen.h | Adds copy_matrix API and ownership for per-cell colour codes. |
| software/io/c64/screen.cc | Implements snapshot copying and tracks per-cell colour codes across output/clear/scroll. |
| software/application/ultimate/ultimate.cc | Adds a helper to push the active menu button via overlay when accessible. |
| software/api/route_machine.cc | Adds GET machine:menu_screen and improves PUT machine:menu_button behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Hi @GideonZ , here is a PR for the new REST endpoint we discussed. Thanks for your review. If there's anything you'd like me to change, let me know. I've done the usual tests: unit, E2E, soak, manual with screenshots. Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a REST endpoint for reading the currently displayed firmware menu screen:
The endpoint returns the active 40x25 text-mode screen as raw character and colour-attribute matrices. This avoids capturing the UDP video stream and converting a bitmap image back into text.
Together with the existing REST input endpoint, clients can now drive and inspect the menu entirely through REST.
Related PRs
Documentation for the new endpoint was added to GideonZ/1541u-documentation#27
API Contract
GET /v1/machine:menu_screenNormal REST API password handling applies. If the device requires authentication and the request does not provide the correct
X-Passwordheader, the shared API router returns403 Forbidden.200 OKReturned when a readable 40x25 menu screen is active.
The response body is exactly 2000 bytes:
0..9991000..1999Both matrices are row-major:
Each colour-attribute byte contains both colours:
0..34..7404 Not FoundReturned when no readable menu screen is currently available.
Content-Type: application/jsonThe JSON response contains the normal API
errorsarray, including:{ "errors": ["Menu screen unavailable."] }Related Fix
This PR also fixes
PUT /v1/machine:menu_button.The documented behaviour is toggle semantics:
On an Ultimate 64 Elite I in UI Overlay mode, the endpoint always opened the menu instead of toggling it. This PR makes the implementation match the documented REST API behaviour:
https://1541u-documentation.readthedocs.io/en/latest/api/api_calls.html
Implementation Notes
Screen_MemMappedCharMatrixnow keeps a per-cell colour-attribute shadow buffer and exposes a bounded matrix-copy method.UserInterface::copy_active_screen_matrix()selects an available active UI, verifies it is 40x25, and copies the character plane followed by the colour plane into the REST response buffer.Validation
Validation included:
menu_screen_test.pyin one-shot mode.menu_screen_test.pyin 2-minute soak-test mode while navigating the menu through REST.menu_screen_tool.pyin both UI Freeze and UI Overlay mode.Sample Images
The following side-by-side images were captured using C64 Stream:
menu_screen_tool.py, which renders data returned byGET /v1/machine:menu_screen.Freeze UI Mode
Overlay UI Mode