Add badge hardware frame overlay to simulator#94
Conversation
Adds a --frame flag that renders the LCD content inside an image of the actual GitHub Universe badge hardware, with labelled button overlays. - Badge frame image (badge_frame.png) included - LCD content scaled and positioned to match the physical screen area - Dark button overlays with A/B/C/^/v labels cover the hardware buttons - Frame scales to fit 800px window height - Default behaviour unchanged (no frame, existing hint bar) Usage: python3 badge_simulator.py --frame badge/apps/badge
There was a problem hiding this comment.
Pull request overview
Adds an optional --frame mode to the Pygame simulator to render the app framebuffer inside a hardware badge frame image.
Changes:
- Added
--frameCLI flag and plumbed it intoScreen(...). - Implemented frame-mode rendering path that blits a scaled LCD surface into the frame and draws labeled button overlays.
- Added the
badge_frame.pnghardware frame asset used by the simulator.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| simulator/badge_simulator.py | Adds --frame flag, loads/scales the frame image, and renders the LCD surface + button overlays within the frame. |
| simulator/badge_frame.png | Provides the hardware frame image used for the overlay. |
| _FRAME_LCD_X = 130 | ||
| _FRAME_LCD_Y = 715 | ||
| _FRAME_LCD_W = 560 | ||
| _FRAME_LCD_H = 430 |
There was a problem hiding this comment.
The LCD target rectangle is 560×430, but the simulator framebuffer is 160×120 (4:3). Scaling 160×120 into a 560×430 rect will always distort the image (~2.3% aspect error). Consider either adjusting _FRAME_LCD_H to preserve 4:3 for the cutout, or letterboxing/pillarboxing by scaling to fit while preserving aspect and centering within the cutout rect.
| _FRAME_LCD_H = 430 | |
| _FRAME_LCD_H = 420 # 4:3 aspect with width 560 to match 160x120 framebuffer |
| self._window.blit(scaled_game, | ||
| (self._frame_lcd_x, self._frame_lcd_y)) | ||
| # Draw button labels over white button squares | ||
| btn_font = pygame.font.Font(None, int(24 * self._frame_scale)) |
There was a problem hiding this comment.
btn_font = pygame.font.Font(...) is created inside present(), so a new font object is allocated every frame in --frame mode. This can add avoidable overhead and churn. Cache the font on self (e.g., create it once in __init__ after _frame_scale is known) and reuse it each frame.
| btn_font = pygame.font.Font(None, int(24 * self._frame_scale)) | |
| if not hasattr(self, "_btn_font"): | |
| self._btn_font = pygame.font.Font(None, int(24 * self._frame_scale)) | |
| btn_font = self._btn_font |
|
Checkout https://github.com/badger/home/blob/main/images/render_003.png - might be a cooler background image |
Summary
Adds a
--frameflag to the simulator that renders the LCD content inside an image of the actual GitHub Universe badge hardware.Changes
badge_frame.png— image of the badge hardware--frameCLI flag to enable the frame overlayUsage