Macros
QRCODE_TINY_SIZE
QRCODE_TINY_BUFFER_LEN

The worst-case number of bytes needed to store one QR Code, up to and including version 40. This value equals 3918, which is just under 4 kilobytes.  Use this more convenient value to avoid calculating tighter memory bounds for buffers.

QRCODE_TINY_ECC_NAME

String of error correction level

Types
QRCODE_MODE

Describes how a segment's data bits are interpreted.

Functions
QRCode_EncodeText
bool QRCode_EncodeText(
const char *text,
u8 tempBuffer[],
u8 qrcode[]
)

Encodes the given text string to a QR Code, returning TRUE if successful.  If the data is too long to fit in any version in the given range at the given ECC level, then FALSE is returned.

The input text must be encoded in UTF-8 and contain no NULs.  Requires 1 <= minVersion <= maxVersion <= 40.

The smallest possible QR Code version within the given range is automatically chosen for the output. Iff boostEcl is TRUE, then the ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. The mask is either between QRCODE_MASK_0 to 7 to force that mask, or QRCODE_MASK_AUTO to automatically choose an appropriate mask (which may be slow).

About the arrays, letting len = QRCODE_BUFFER_LEN_FOR_VERSION(maxVersion): - Before calling the function: - The array ranges tempBuffer[0 : len] and qrcode[0 : len] must allow reading and writing; hence each array must have a length of at least len.  - The two ranges must not overlap (aliasing).  - The initial state of both ranges can be uninitialized because the function always writes before reading.  - After the function returns: - Both ranges have no guarantee on which elements are initialized and what values are stored.  - tempBuffer contains no useful data and should be treated as entirely uninitialized.  - If successful, qrcode can be passed into QRCode_GetSize() and QRCode_GetModule().

If successful, the resulting QR Code may use numeric, alphanumeric, or byte mode to encode the text.

In the most optimistic case, a QR Code at version 40 with low ECC can hold any UTF-8 string up to 2953 bytes, or any alphanumeric string up to 4296 characters, or any digit string up to 7089 characters.  These numbers represent the hard upper limit of the QR Code standard.

Please consult the QR Code specification for information on data capacities per version, ECC level, and text encoding mode.

QRCode_EncodeSegmentsAdvanced
bool QRCode_EncodeSegmentsAdvanced(
const struct QRCode_Segment segs[],
u8 len,
u8 tempBuffer[],
u8 qrcode[]
)

Encodes the given segments to a QR Code, returning TRUE if successful.  If the data is too long to fit in any version in the given range at the given ECC level, then FALSE is returned.

Requires 1 <= minVersion <= maxVersion <= 40.

The smallest possible QR Code version within the given range is automatically chosen for the output. Iff boostEcl is TRUE, then the ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. The mask is either between QRCODE_MASK_0 to 7 to force that mask, or QRCODE_MASK_AUTO to automatically choose an appropriate mask (which may be slow).

About the byte arrays, letting len = QRCODE_BUFFER_LEN_FOR_VERSION(QRCODE_VERSION_MAX): - Before calling the function: - The array ranges tempBuffer[0 : len] and qrcode[0 : len] must allow reading and writing; hence each array must have a length of at least len.  - The two ranges must not overlap (aliasing).  - The initial state of both ranges can be uninitialized because the function always writes before reading.  - The input array segs can contain segments whose data buffers overlap with tempBuffer.  - After the function returns: - Both ranges have no guarantee on which elements are initialized and what values are stored.  - tempBuffer contains no useful data and should be treated as entirely uninitialized.  - Any segment whose data buffer overlaps with tempBuffer[0 : len] must be treated as having invalid values in that array.  - If successful, qrcode can be passed into QRCode_GetSize() and QRCode_GetModule().

Please consult the QR Code specification for information on data capacities per version, ECC level, and text encoding mode.

This function allows the user to create a custom sequence of segments that switches between modes (such as alphanumeric and byte) to encode text in less space.  This is a low-level API; the high-level API is QRCode_EncodeText() and QRCode_EncodeBinary().

QRCode_GetSize
inline u8 QRCode_GetSize(
const u8 qrcode[]
)

Returns the side length of the given QR Code, assuming that encoding succeeded.  The result is in the range [21, 177]. Note that the length of the array buffer is related to the side length - every 'u8 qrcode[]' must have length at least QRCODE_BUFFER_LEN_FOR_VERSION(version), which equals ceil(size^2 / 8 + 1).

QRCode_GetModule
bool QRCode_GetModule(
const u8 qrcode[],
u8 x,
u8 y
)

Returns the color of the module (pixel) at the given coordinates, which is FALSE for light or TRUE for dark.  The top left corner has the coordinates (x=0, y=0).  Coordinates must be in bounds.

QRCode_GetByte
u8 QRCode_GetByte(
const u8 qrcode[],
u8 x,
u8 y
)

Returns colors of 8 module (byte) at the given coordinates, which is 0 for light or 1 for dark.  The top left corner has the coordinates (x=0, y=0).

QRCode_GetVersion
inline u8 QRCode_GetVersion(
const u8 qrcode[]
)