[中文]

QR code

QR code generation with LVGL. Uses QR-Code-generator by nayuki.

Usage

Enable LV_USE_QRCODE in lv_conf.h.

Use lv_qrcode_create() to create a qrcode object, and use lv_qrcode_update() to generate a QR code.

If you need to re-modify the size and color, use lv_qrcode_set_size() and lv_qrcode_set_dark_color() or lv_qrcode_set_light_color(), and call lv_qrcode_update() again to regenerate the QR code.

Notes

  • QR codes with less data are smaller, but they scaled by an integer number to best fit to the given size.

Example

[中文]

Create a QR Code

#include "../../lv_examples.h"
#if LV_USE_QRCODE && LV_BUILD_EXAMPLES
#include <string.h>

/**
 * Create a QR Code
 */
void lv_example_qrcode_1(void)
{
    lv_color_t bg_color = lv_palette_lighten(LV_PALETTE_LIGHT_BLUE, 5);
    lv_color_t fg_color = lv_palette_darken(LV_PALETTE_BLUE, 4);

    lv_obj_t * qr = lv_qrcode_create(lv_screen_active());
    lv_qrcode_set_size(qr, 150);
    lv_qrcode_set_dark_color(qr, fg_color);
    lv_qrcode_set_light_color(qr, bg_color);

    /*Set data*/
    const char * data = "https://lvgl.io";
    lv_qrcode_update(qr, data, strlen(data));
    lv_obj_center(qr);

    /*Add a border with bg_color*/
    lv_obj_set_style_border_color(qr, bg_color, 0);
    lv_obj_set_style_border_width(qr, 5, 0);
}

#endif

API

qrcodegen.h

lv_types.h

lv_qrcode.h