Barcode or QR code generation in Espruino

Posted on
  • There was a thread some time ago about QR codes. I'd like to generate them on the Bangle. Did anyone get a port of the javascript QR code generator working? I could potentially use a barcode, but QR would be much better...


  • @MaBe was asking about this recently as well.

    I don't know of one that has actually been used, but for the App Loader I use

    In the source (­blob/master/qrcode.js) it actually uses a QR code generator from­generator which looks pretty compact and should work - the rest of the file is more or less just boilerplate

  • Yep

    and there is a c implementation as well

    I am petty sure this should be created as JS module with at least a size a 64x64 one bit which is pretty nice readable on oled's and lcd's.

  • Thanks @MaBe and @Gordon. I'll try to dig into it; this is a demo/idea so unfortunately back burner for me at best. If anyone in this group gets there first...

  • Just had a quick look at this, and the code I suggested runs out of memory.

    I made a few quick changes to reduce RAM usage when saved to flash (eg getPatternPosition and similar can define the array inside the function) and minified, but while it's enough to load the functions it's not enough to run.

    The code itself uses normal (sparse) arrays heavily, so realistically it'd need changing to use Uint8Array to store the QR Code itself while it's being created. When that's done it might work, but that's a reasonable undertaking!

  • Uint8Array to store the QR Code itself while it's being created.

    Yes, something like a bitbucket to place the marks and pattern and then use xor to set the byte values.

  • I think it'd probably be fine even as a byte array - it's just right now as a sparse array it's 1 var per entry, so you're looking at 16x more memory than if you used a Uin8Array and 128x than if you packed it as bits :)

  • Thanks Guys! I appreciate the follow up. I'm short on time to spend on this, and lack the expertise that you clearly have. I think it would be a good and intriguing feature to have in the Espruino toolkit.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Barcode or QR code generation in Espruino

Posted by Avatar for billsalt @billsalt