Skip to content

Fix QR codes rendered wide/horizontal on ILI9341 displays#353

Draft
Copilot wants to merge 1 commit into
devfrom
copilot/fix-horizontal-qr-codes
Draft

Fix QR codes rendered wide/horizontal on ILI9341 displays#353
Copilot wants to merge 1 commit into
devfrom
copilot/fix-horizontal-qr-codes

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 27, 2026

On ILI9341 displays (240×320 physical), Renderer swaps canvas dimensions to canvas_width=320, canvas_height=240 so the 90° hardware rotation in show_image produces a correct portrait layout. QRDisplayScreen was blindly passing those non-square dimensions to the QR encoder, which stretched the square QR image to 320×240 — producing the wide/horizontal QR codes seen in B10.

Fix: compute qr_size = min(canvas_width, canvas_height) once before the render loop and use it for both axes.

# before
image = self.qr_encoder.next_part_image(
    self.renderer.canvas_width, self.renderer.canvas_height, ...)

# after
qr_size = min(self.renderer.canvas_width, self.renderer.canvas_height)
image = self.qr_encoder.next_part_image(qr_size, qr_size, ...)

No behavioural change on square (240×240 ST7789) displays.

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

  • I've run pytest and made sure all unit tests pass before sumbitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • No, I'm a fool
  • Yes
  • N/A

I have tested this PR on the following platforms/os:

Note: Keep your changes limited in scope; if you uncover other issues or improvements along the way, ideally submit those as a separate PR. The more complicated the PR the harder to review, test, and merge.

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