lv_qrcode.h
API reference for lv_qrcode.h
Functions
lv_qrcode_set_size
Set QR code size.
void lv_qrcode_set_size(lv_obj_t *obj, int32_t size)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
size | int32_t | width and height of the QR code |
lv_qrcode_set_dark_color
Set QR code dark color.
void lv_qrcode_set_dark_color(lv_obj_t *obj, lv_color_t color)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
color | lv_color_t | dark color of the QR code |
lv_qrcode_set_light_color
Set QR code light color.
void lv_qrcode_set_light_color(lv_obj_t *obj, lv_color_t color)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
color | lv_color_t | light color of the QR code |
lv_qrcode_set_data
Helper function to set the data of a QR code object from a string. The NUL terminator is not part of the encoded payload.
void lv_qrcode_set_data(lv_obj_t *obj, const char *data)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
data | const char * | data to display as a NUL terminated string |
lv_qrcode_set_quiet_zone
Enable or disable quiet zone. Quiet zone is the area around the QR code where no data is encoded.
void lv_qrcode_set_quiet_zone(lv_obj_t *obj, bool enable)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
enable | bool | true: enable quiet zone; false: disable quiet zone |
lv_qrcode_set_update_mode
Set when a property change is turned into a new QR code bitmap. With LV_QRCODE_UPDATE_MODE_IMMEDIATE (the default) changing the size or the quiet zone re-encodes the stored data right away. With LV_QRCODE_UPDATE_MODE_DEFERRED such a change only marks the bitmap as out of date and several changes are collapsed into a single re-encode on the next redraw.
void lv_qrcode_set_update_mode(lv_obj_t *obj, lv_qrcode_update_mode_t mode)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
mode | lv_qrcode_update_mode_t | the mode to use |
In deferred mode you are expected to call lv_qrcode_render() yourself once the properties are set. It encodes right away and returns the result, leaving the next redraw nothing to do. If it is forgotten, the encode is done by the redraw instead: the bitmap is still correct, but the work is charged to that refresh and its result cannot be reported to anyone, so a warning is logged. Prefer the explicit call.
Switching back to LV_QRCODE_UPDATE_MODE_IMMEDIATE while the bitmap is out of date also re-encodes it, but this function returns void, so an encode failure can only be logged, not reported. A warning is emitted in that case. Call lv_qrcode_render() first and switch the mode afterwards to get the result.
lv_qrcode_get_update_mode
Get when a property change is turned into a new QR code bitmap.
lv_qrcode_update_mode_t lv_qrcode_get_update_mode(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
Returns: lv_qrcode_update_mode_t — the update mode currently in use
lv_qrcode_create
Create an empty QR code (an lv_canvas) object.
lv_obj_t * lv_qrcode_create(lv_obj_t *parent)| Name | Type | Description |
|---|---|---|
parent | lv_obj_t * | pointer to a parent widget May be NULL.. When NULL, the widget is created as a screen on the active display. |
Returns: lv_obj_t * — pointer to the created QR code object
lv_qrcode_update
Set the data of a QR code object and generate the bitmap. A copy of the data is stored, so a later lv_qrcode_set_size() or lv_qrcode_set_quiet_zone() can re-encode it. The properties may therefore be set before or after the data, in any order. Use lv_qrcode_render() to re-encode the stored payload without passing it again.
lv_result_t lv_qrcode_update(lv_obj_t *obj, const void *data, uint32_t data_len)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
data | const void * | data to display |
data_len | uint32_t | length of data in bytes |
Returns: lv_result_t — LV_RESULT_OK: if no error; LV_RESULT_INVALID: on error
lv_qrcode_render
(Re)generate the QR code bitmap from the payload that is already stored. Unlike lv_qrcode_update() this needs no payload, so it is the way to apply property changes made in LV_QRCODE_UPDATE_MODE_DEFERRED: set the size and quiet zone, then call this once to encode them and get the result. The bitmap is regenerated whether or not anything changed.
lv_result_t lv_qrcode_render(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
Returns: lv_result_t — LV_RESULT_OK: if no error; LV_RESULT_INVALID: on error (e.g. no data set, or the payload does not fit the current size)
lv_qrcode_is_render_valid
Check whether the QR code bitmap is free of a known encode failure. Most encodes report their result directly: lv_qrcode_update() returns it. The ones that cannot are the re-encodes triggered by a property change - they happen in a void setter or, in LV_QRCODE_UPDATE_MODE_DEFERRED, in the draw pass. Use this to detect those, e.g. after shrinking the object below the size its payload needs.
bool lv_qrcode_is_render_valid(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a QR code object |
Returns: bool — true: no encode attempt is known to have failed. A property change re-arms the Widget, so this is also true while a deferred re-encode is still pending; false: the last encode attempt failed, or no data has been set yet
A failed encode leaves the bitmap marked as out of date, so it is never reported as current, and it is not retried on every redraw - only a property change makes the Widget try again. Encode failures are not logged when the caller can see the result; the one exception is the re-encode done by the redraw, which has no caller, so that one is logged.
Enums
lv_qrcode_update_mode_t
Controls when a property change is turned into a new QR code bitmap. Only the properties that require re-encoding (size, quiet zone) are affected; lv_qrcode_update() always encodes right away and the colors are always a palette-only write.
| Name | Value | Description |
|---|---|---|
LV_QRCODE_UPDATE_MODE_IMMEDIATE | 0 | Re-encode as soon as a property changes (default) |
LV_QRCODE_UPDATE_MODE_DEFERRED | Only mark the bitmap out of date and re-encode once, on the next redraw |
Used by 1 function
lv_qrcode_set_update_mode— parammode
Variables
lv_qrcode_class
const lv_obj_class_t lv_qrcode_classDependencies
lv_conf_internal.hlv_color.hlv_types.hlv_canvas.hstdbool.hstdint.h
Indirect dependencies
lv_anim.hlv_area.hlv_assert.hlv_bidi.hlv_color_op.hlv_display.hlv_draw.hlv_draw_arc.hlv_draw_blur.hlv_draw_buf.hlv_draw_image.hlv_draw_label.hlv_draw_line.hlv_draw_rect.hlv_draw_triangle.hlv_event.hlv_ext_data.hlv_flex.hlv_font.hlv_fs.hlv_grad.hlv_grid.hlv_group.hlv_image.hlv_image_decoder.hlv_image_dsc.hlv_indev.hlv_layout.hlv_ll.hlv_log.hlv_math.hlv_matrix.hlv_mem.hlv_obj.hlv_obj_class.hlv_obj_draw.hlv_obj_event.hlv_obj_pos.hlv_obj_property.hlv_obj_scroll.hlv_obj_style.hlv_obj_style_gen.hlv_obj_tree.hlv_observer.hlv_palette.hlv_profiler.hlv_profiler_builtin.hlv_sprintf.hlv_string.hlv_style.hlv_style_gen.hlv_symbol_def.hlv_text.hlv_timer.h
Last updated on