Pure Toit QR code generation for constrained devices.
https://pkg.toit.io/package/github.com%2Flightbug-io%2Ftoit-qr@v1.0.0
This package provides:
QrCode— encodes data into a QR matrix (0/1modules).QrBitmap— converts that matrix to a 1-bit bitmap (MSB-first, byte-aligned rows), suitable for e-ink drawing APIs.
The encoder supports:
- QR Version 3 (
29x29modules) - ECC Level L
- Byte mode
- Maximum payload: 42 bytes
If input exceeds capacity, encoding throws an error.
Add the package to your Toit project dependencies:
jag pkg install github.com/lightbug-io/toit-qrAnd import it:
import qr show QrCode QrBitmapimport qr show QrCode QrBitmap
main:
qr := QrCode.encode "https://example.com"
// Matrix (29x29), values: 0 = white, 1 = black
matrix := qr.matrix
size := qr.size
// Convert matrix to 1-bit bitmap
bmp := QrBitmap.from-matrix matrix --scale=3 --quiet=2
print "QR modules: $size x $size"
print "Bitmap: $(bmp.width)x$(bmp.height), bytes=$(bmp.data.size)"See examples/console.toit
[jaguar] INFO: program cbc4abf0-903f-4efc-fe52-7cb7357d9816 started
██████████████ ██ ██ ██ ██████████████
██ ██ ██ ██ ██ ██ ██
██ ██████ ██ ██ ██ ██ ██ ██ ██████ ██
██ ██████ ██ ██ ████ ████ ██ ██ ██████ ██
██ ██████ ██ ██ ████ ████ ██ ██ ██████ ██
██ ██ ██████ ██████ ██████ ██ ██
██████████████ ██ ██ ██ ██ ██ ██ ██ ██████████████
██ ██ ██ ██
██████ ██████████ ██ ██ ██████ ██
████ ██ ██████ ██████ ██████ ████ ██ ██ ██
██ ██ ██████ ██████ ██████ ██████ ██████ ██████
██ ████ ██ ████ ██████ ██████ ████ ██ ██
██ ██ ██████ ████ ████ ██████████ ██ ████
██ ██ ██ ████ ████ ████ ████ ██ ██
████ ██ ██ ██ ██ ██████ ████
██ ████████ ██ ████ ██ ██████ ██ ██ ██
██ ██████ ██ ██ ████████ ██ ████
████ ██ ██████ ██████ ██████ ████ ██
██ ██████████ ██████ ██████ ██ ████ ██ ████
████████ ████ ██████ ██████ ██ ██████ ██
██ ████ ██████ ████ ████ ██████████████
████████ ████ ██████ ██ ██████
██████████████ ██ ██ ██ ████ ██ ████ ████
██ ██ ██ ████ ██ ██ ████ ██
██ ██████ ██ ████ ██ ██ ██████████ ██
██ ██████ ██ ██ ██████ ██████ ████ ██ ██
██ ██████ ██ ████ ████ ██████ ██ ██ ██████ ██
██ ██ ██████ ██████ ██████████ ██ ██
██████████████ ████ ██ ████ ██████ ████ ████
[jaguar] INFO: program cbc4abf0-903f-4efc-fe52-7cb7357d9816 stopped
See examples/lightbug.toit
Example QR rendered on an e-ink screen:
