A non-hardware dependant miniature QR generator library. All native Python!

  • Author(s): ladyada

Implementation Notes


  • Any!

Software and Dependencies:

  • Python 3

class adafruit_miniqr.QRBitBuffer

Storage class for a length of individual bits


The bit value at a location


Size of bit buffer

put(num, length)

Add a number of bits from a single integer value


Insert one bit at the end of the bit buffer

class adafruit_miniqr.QRBitMatrix(width, height)

A bit-packed storage class for matrices

class adafruit_miniqr.QRCode(*, qr_type=None, error_correct=1)

The generator class for QR code matrices


Add more data to the QR code, must be bytestring stype

make(*, test=False, mask_pattern=0)

Perform the actual generation of the QR matrix. To keep things small and speedy we don’t generate all 8 mask patterns and pick the best. Instead, please pass in a desired mask_pattern, the default mask is 0.

class adafruit_miniqr.QRPolynomial(num, shift)

Structure for creating and manipulating error code polynomials


The exponent at the index location


Length of the poly


Multiply two polynomials, returns a new one

class adafruit_miniqr.QRUtil

A selection of bit manipulation tools for QR generation and BCH encoding

static get_BCH_digit(data)

Count digits in data

static get_BCH_type_info(data)

Encode with G15 BCH mask

static get_BCH_type_number(data)

Encode with G18 BCH mask

static get_error_correct_polynomial(ecc_length)

Generate a ecc polynomial

static get_mask(mask, i, j)

Perform matching calculation on two vals for given pattern mask

static get_pattern_position(qr_type)

The mask pattern position array for this QR type