Git Product home page Git Product logo

lv_lib_qrcode's Introduction

QR code library for LVGL

This repository is merged into the lvgl repository. See https://docs.lvgl.io/master/libs/qrcode.html

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

Get started

const char * data = "Hello world";

/*Create a 100x100 QR code*/
lv_obj_t * qr = lv_qrcode_create(lv_scr_act(), 100, lv_color_hex3(0x33f), lv_color_hex3(0xeef));

/*Set data*/
lv_qrcode_update(qr, data, strlen(data));

Notes

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

lv_lib_qrcode's People

Contributors

aaron-neal avatar fan12398 avatar kisvegabor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lv_lib_qrcode's Issues

No image displayed when testing

Hello,
I am trying to test the library as suggested by the example, but it only shows "NO DATA" in my display. My hardware is a 128x64 dot monochrome, and its working fine with others objects (images and labels). Are the instructions "lv_qrcode_create" and "lv_qrcode_update" all that is needed to display the QR Code?

maybe older code style in function `lv_qrcode_create`

In lv_qrcode.c, function lv_qrcode_create calls LV_IMG_BUF_SIZE_INDEXED_1BIT and LV_ASSERT_MEM,however, I could not find the declarations or definitions in master lvgl respo.

lv_obj_t * lv_qrcode_create(lv_obj_t * parent, lv_coord_t size, lv_color_t dark_color, lv_color_t light_color)
{
    uint32_t buf_size = LV_IMG_BUF_SIZE_INDEXED_1BIT(size, size);
    uint8_t * buf = lv_mem_alloc(buf_size);
    LV_ASSERT_MEM(buf);

So, I replace them with LV_CANVAS_BUF_SIZE_INDEXED_1BIT and lv_mem_assert, is that right?

lv_obj_t * lv_qrcode_create(lv_obj_t * parent, lv_coord_t size, lv_color_t dark_color, lv_color_t light_color)
{
   uint32_t buf_size = LV_CANVAS_BUF_SIZE_INDEXED_1BIT(size, size);
   uint8_t * buf = lv_mem_alloc(buf_size);
   lv_mem_assert(buf);

Error building

I'm unable to build my firmware when adding the QR Code Lib, using the example code provided.
I get the following error:

src/lv_lib_qrcode/lv_qrcode.c:52:4: error: implicit declaration of function 'lv_mem_assert' [-Werror=implicit-function-declaration]
lv_mem_assert(buf);
^

I'm using lvl 6.1.2, and embedding the code within mongoose-os.

Lack of a user defined margin

Lack of a user defined colour pad

This bug report refers to the lack of a user defined colour pad, the empty area around a QR code.

Colour padding

Machine reading improves when codes have a large padded area around them, in the same colour as the very thin margin as defined in existing sources.

int margin = (obj_w - scaled) / 2;

Suggestion

To introduce a user defined padded area, a parameter could be added wherever graphic size is referenced (in buffers, allocation, and construction.)

Pull request pending

I've solved this problem and will submit a pull request called Colourpad Addition 1A.

Stack Overflow

I experimented with this library on an ESP32. I think it has 8K bytes of stack.
lv_qrcode_update starts by allocating two arrays (qr0 and data_tmp), each about 4K bytes, and this causes a stack overflow on the ESP32. (It did work on my Windows simultator, so I had a clue..)
data_tmp holds a copy of the data to convert into a QRcode. This is typically a URL, and they are never 4K long.
So I changed it to 128 bytes, then it worked fine on the ESP32
In fact, I think, it is not needed to make a local copy of the to-be-encoded data.

If you decide to fix this, maybe it is worthwhile adding this to the widgets. It took me quite a while to add it there and get everything properly compiling.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.