Skip to content

Add badge hardware frame overlay to simulator#94

Open
keith-oak wants to merge 1 commit into
badger:mainfrom
keith-oak:simulator-badge-frame
Open

Add badge hardware frame overlay to simulator#94
keith-oak wants to merge 1 commit into
badger:mainfrom
keith-oak:simulator-badge-frame

Conversation

@keith-oak

Copy link
Copy Markdown

Summary

Adds a --frame flag to the simulator that renders the LCD content inside an image of the actual GitHub Universe badge hardware.

Changes

  • Added badge_frame.png — image of the badge hardware
  • Added --frame CLI flag to enable the frame overlay
  • LCD content scaled and positioned to match the physical screen area
  • Dark button overlays with A/B/C/^/v labels on the hardware buttons
  • Frame scales to fit 800px window height
  • Default behaviour unchanged (no frame, existing hint bar)

Usage

# Without frame (default, unchanged)
python3 simulator/badge_simulator.py badge/apps/badge

# With badge hardware frame
python3 simulator/badge_simulator.py --frame badge/apps/badge

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
Copilot AI review requested due to automatic review settings March 31, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --frame CLI flag and plumbed it into Screen(...).
  • Implemented frame-mode rendering path that blits a scaled LCD surface into the frame and draws labeled button overlays.
  • Added the badge_frame.png hardware 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

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
_FRAME_LCD_H = 430
_FRAME_LCD_H = 420 # 4:3 aspect with width 560 to match 160x120 framebuffer

Copilot uses AI. Check for mistakes.
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))

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@martinwoodward

Copy link
Copy Markdown
Contributor

Checkout https://github.com/badger/home/blob/main/images/render_003.png - might be a cooler background image

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.

3 participants