Barcode or QR code generation in Espruino #6622
Replies: 1 comment
-
Posted at 2020-06-03 by @gfwilliams @MaBecker 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 https://github.com/davidshimjs/qrcodejs In the source (https://github.com/davidshimjs/qrcodejs/blob/master/qrcode.js) it actually uses a QR code generator from https://github.com/kazuhikoarase/qrcode-generator which looks pretty compact and should work - the rest of the file is more or less just boilerplate Posted at 2020-06-03 by @MaBecker Yep and there is a c implementation as well https://github.com/ricmoo/QRCode 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. Posted at 2020-06-03 by billsalt Thanks @MaBecker and @gfwilliams. 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... Posted at 2020-06-04 by @gfwilliams 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 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! Posted at 2020-06-04 by @MaBecker
Yes, something like a bitbucket to place the marks and pattern and then use xor to set the byte values. Posted at 2020-06-04 by @gfwilliams 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 :) Posted at 2020-06-04 by billsalt 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. Posted at 2020-09-14 by @MaBecker With some help there is now a qrcode lib in my custom firmware build.
Attachments: Posted at 2020-09-14 by @MaBecker It is based on https://github.com/ricmoo/QRCode Posted at 2020-09-14 by @gfwilliams Nice - so that's actually compiled-in C code? Posted at 2020-09-14 by @MaBecker
Yes, in libs/qrcode/ and available with QRCODE in board file and USE_QRCODE in Makefile. Code size depends on version, e.g. only version 3 runs without NUM_ array. Let me know if you like to be added, so I come up with a pr for this. Posted at 2020-09-16 by billsalt Really nice! It would be great to roll that into the standard build @gfwilliams. My humble opinion, of course. Posted at 2020-09-16 by @gfwilliams It's just given the lack of flash space on a lot of boards now this is a very specific bit of code to include. I think as Inline C (or even just JS - which should still be possible to do with some minor tweaking, or maybe an emscripten compile of the qrcode C) this would make a lot of sense. Posted at 2020-09-16 by @MaBecker
Ok, got a.aout.js and a.out.wasm file Not sure how to include this generated stuff? Posted at 2020-09-16 by @gfwilliams You'd have to google it - as far as I remember you can use a command-line switch to disable WASM edit: what I did for heatshrink in the browser might work: https://github.com/gfwilliams/heatshrink-js But I don't know whether your wrapped emscripten code can be squished down further with some options Posted at 2020-09-17 by @MaBecker Thanks, this look's very helpful. Posted at 2022-03-04 by user113146 Hey, I am interested in generating qr code on the fly with my pixl.js (and bangle2) Do you have more complete code I could look at ? Posted at 2022-03-05 by @MaBecker Didn't continue working on the wasm stuff. Posted at 2022-03-06 by MisterG I did successfully get QR codes "working" in Espruino, but used an ESP32 for the Wifi. Being lazy, I just got a QR code generator and put it on a server then downloaded the image to the ESP32 and displayed it as an image. There are lots of websites to generate QR codes, so that might work for you also. I couldn't get it to work on an OLED screen (128x64), but had some success with an ST7789 AND ILI9341. This could have been due to the type of QR code I was using at the time. Posted at 2022-03-06 by user113146 Thanks for the answers For my use case I need the qr code to be generated by the device itself unfortunately |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-03 by billsalt
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...
TIA!
Beta Was this translation helpful? Give feedback.
All reactions