Skip to content

Fix simulator QR Codes#827

Open
tadeubas wants to merge 1 commit into
selfcustody:developfrom
tadeubas:fix_simulator_qr
Open

Fix simulator QR Codes#827
tadeubas wants to merge 1 commit into
selfcustody:developfrom
tadeubas:fix_simulator_qr

Conversation

@tadeubas
Copy link
Copy Markdown
Member

@tadeubas tadeubas commented Feb 7, 2026

What is this PR for?

The Simulator had issues when encoding data into QR codes and when reading QR codes via pyzbar. This PR fixes both problems and restores reliable QR round-trips 😄.

Removed the unnecessary qr_str_to_bytes that was trying to solve those issues.

How to test:

  • Use the Simulator to display a QR code.
  • Take a photo with a phone (or other camera).
  • Read the QR using the Datum tool inside the Simulator.
from krux.qr import to_qr_codes, FORMAT_NONE
from krux.themes import theme, WHITE
from krux.display import display
from krux.input import Input


qr_foreground = WHITE if theme.bg_color == WHITE else None
inp = Input()

data = " woahdi oawij dowaij ,./:[]123! áéíóú àè ìò ù©ç ãẽĩ õũ?"
code_generator = to_qr_codes(data, 999999999, FORMAT_NONE)
code, num_parts = next(code_generator)

# Draw QR code
if qr_foreground:
    display.draw_qr_code(
        code, light_color=qr_foreground
    )
else:
    display.draw_qr_code(code)

Changes made to:

  • Code
  • Tests
  • Docs
  • CHANGELOG

Did you build the code and tested on device?

  • Yes, build and tested on

What is the purpose of this pull request?

  • Bug fix
  • New feature
  • Docs update
  • Other

Copy link
Copy Markdown
Member

@qlrd qlrd left a comment

Choose a reason for hiding this comment

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

LGTM, just a nit

Comment on lines +218 to 220
return parser.result(), parser.format
return None, None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need a format and lint here

Comment thread pyproject.toml
Pillow = { version = "^11.3.0", optional = true }
pygame = { version = "^2.6.1", optional = true }
pyzbar = { version = "^0.1.9", optional = true }
pyzbar = { git = "https://github.com/tadeubas/pyzbar", tag = "v0.1.10", optional = true }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does it need a custom pyzbar module?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I stumbled on the issue with the official pyzbar repo’s when reading a QRCode using SeedQReader. It had some issues with accents! Switching to the SeedSigner pyzbar fork fixed it right away. That’s when I realized the Krux simulator was also using the same buggy official pyzbar version.

I also noticed the simulator’s QR encoder was using pyqrcode, which hasn’t been updated since 2016 (yikes 😅). It turns out that library was causing encoding issues with accents too! I swapped it out for qrcode (yes, same name as MaixPy) and everything worked flawlessly.

We could use the SeedSigner release, but it pins the same buggy pyzbar version. That means developers would need to purge the existing installation to ensure the updated version is actually used. To address this, I created a bumped version in my repository.

Copy link
Copy Markdown
Member

@qlrd qlrd May 11, 2026

Choose a reason for hiding this comment

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

I think this make sense. IMO we could use your fork as workaround just for development branch, temporarily; a merge on your pyzbar as PR on upstream repo would be a great contribution to community and when merged (🙏🏽), we could back to original setup on develop, with both baked rabbits.

@odudex
Copy link
Copy Markdown
Member

odudex commented Apr 29, 2026

Please try to use the official pyzbar repo, if there's a bug, submit a PR.
If non of these work, let me know and I'll create a selfcustody fork.

Please try to fix CI errors too.

@tadeubas
Copy link
Copy Markdown
Member Author

Please try to use the official pyzbar repo, if there's a bug, submit a PR. If non of these work, let me know and I'll create a selfcustody fork.

Please try to fix CI errors too.

Lol, the PR exists on "official" pyzbar for +5 years and counting...

@qlrd
Copy link
Copy Markdown
Member

qlrd commented May 14, 2026

Yup, isnt a well maintained repo. Even the last commit is from 5 years ago. Isn't possible to formatting while resolve this major one?

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