adafruit / Adafruit_CircuitPython_PortalBase

Base Library for the Portal-style libraries.
MIT License
18 stars 17 forks source link

Increasing the size range for QR codes #48

Closed whimshot closed 3 years ago

whimshot commented 3 years ago

Howdy,

This is really more of a question than an issue.

I was working on a project with a MagTag and I wanted to display a QR code MECARD as part of a nametag. When I attempted to including anything more than name, email address and a short note the code would fail. I tracked it down to this bit of code in PortalBase

        # generate the QR code
        for qrtype in range(1, 5):
            try:
                qrcode = adafruit_miniqr.QRCode(qr_type=qrtype)
                qrcode.add_data(qr_data)
                qrcode.make()
                break
            except RuntimeError:
                pass
                # print("Trying with larger code")
        else:
            raise RuntimeError("Could not make QR code")

I changed it to for qrtype in range(1, 6): and it worked just like I wanted so I'm all good. Along the way I got to learn how to turn a .py file into an .mpy file so I consider all of this time well spent.

So I'm wondering how the particular range was selected? Maybe a memory limitation on certain boards?

Thanks!

colin j.

makermelissa commented 3 years ago

I think I grabbed the range from the original PyPortal library. I'm not sure as to the why part, but if you'd like to submit a Pull Request, that would be a welcome addition.

Thanks, Melissa